diff --git a/homepage/views.php b/homepage/views.php index dd75f00..5618dad 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -46,6 +46,9 @@ body::-webkit-scrollbar {
+
+ +
@@ -90,6 +93,7 @@ if(isset($_GET['view'])){ if($_GET['view'] == "Overview"){include('overview.php');} if($_GET['view'] == "Today's Detections"){include('todays_detections.php');} if($_GET['view'] == "Species Stats"){include('stats.php');} + if($_GET['view'] == "Weekly Report"){include('weekly_report.php');} if($_GET['view'] == "Streamlit"){echo "";} if($_GET['view'] == "Daily Charts"){include('history.php');} if($_GET['view'] == "Tools"){ diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index c22d0bf..b03a0d7 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -94,6 +94,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then $HOME/BirdNET-Pi/birdnet/bin/pip3 install pytest==7.1.2 pytest-mock==3.7.0 fi +[ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted sudo systemctl daemon-reload restart_services.sh diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php new file mode 100644 index 0000000..0d8b262 --- /dev/null +++ b/scripts/weekly_report.php @@ -0,0 +1,67 @@ + +
Week ".date('W', $enddate)." Report".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."
"; +?>
prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC LIMIT 10'); +if($statement1 == False){ + echo "Database is busy"; + header("refresh: 0;"); +} +$result1 = $statement1->execute(); + +?> +
+ + + + + + + +fetchArray(SQLITE3_ASSOC)) +{ + +$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); +if($statement2 == False){ + echo "Database is busy"; + header("refresh: 0;"); +} +$result2 = $statement2->execute(); +$totalcount = $result2->fetchArray(SQLITE3_ASSOC); +$priorweekcount = $totalcount['COUNT(*)']; + +$percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + +if($percentagediff > 0) { + $percentagediff = "+".$percentagediff."%"; +} else { + $percentagediff = "-".abs($percentagediff)."%"; +} + +echo ""; +} +?> + +
"; ?>
".$detection["Com_Name"]."
".$detection["COUNT(*)"]." (".$percentagediff.")
+ +
+
+ * percentages are calculated relative to week +
\ No newline at end of file