From a3f2fe943ca18603ab170eeffb560d1122521e14 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:27:04 -0400 Subject: [PATCH 1/5] JS refresh of most recent detection Hello! I've gone ahead and implemented some JS into overview.php that will automatically refresh the most recent audio detection, if there is a newer one. This means you don't have to manually refresh overview anymore. Open to feedback/suggestions! -Ethan --- scripts/overview.php | 92 +++++++++++++++++++++++++++++------ scripts/todays_detections.php | 1 - 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/scripts/overview.php b/scripts/overview.php index c622faa..2a14563 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -1,5 +1,5 @@ execute(); $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC); + + +if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) { + if($_GET['previous_detection_identifier'] != $filename || $_GET['previous_detection_identifier'] == "undefined") { + // check to make sure the image actually exists, sometimes it takes a minute to be created + $headers = @get_headers("http://".$_SERVER['HTTP_HOST'].$filename.".png"); + if(strpos($headers[0],'200')) { + ?> + + +

Most Recent Detection:

+ + + + +
+
+ + + +
Confidence:
+
@@ -113,20 +156,41 @@ if (file_exists('./Charts/'.$chart)) { } ?> - -

Most Recent Detection:

- - - - -
-
- - - -
Confidence:
-
+ +
+

Currently Analyzing

+ + + diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index e50a2e7..f9b4319 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -143,7 +143,6 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse

Currently Analyzing

- +"; +?> + + From 0a9ee65a2bbc272876deade7eef90899fc7ed279 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sat, 16 Apr 2022 11:49:58 -0400 Subject: [PATCH 4/5] daily_plot has a better call to the database and updates every 60 seconds instead of 5 minutes as it takes about 13 seconds and doesn't seem to bother things --- scripts/daily_plot.py | 2 +- scripts/install_services.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/daily_plot.py b/scripts/daily_plot.py index 6762393..e2147b0 100755 --- a/scripts/daily_plot.py +++ b/scripts/daily_plot.py @@ -12,7 +12,7 @@ userDir = os.path.expanduser('~') conn = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db') df = pd.read_sql_query("SELECT * from detections", conn) cursor = conn.cursor() -cursor.execute('SELECT * FROM detections') +cursor.execute('SELECT * FROM detections WHERE Date = DATE(\'now\', \'localtime\')') table_rows = cursor.fetchall() diff --git a/scripts/install_services.sh b/scripts/install_services.sh index 8ef7cff..399cca6 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -320,7 +320,7 @@ install_chart_viewer_service() { Description=BirdNET-Pi Chart Viewer Service [Service] Restart=always -RestartSec=300 +RestartSec=60 Type=simple User=$USER ExecStart=/usr/local/bin/daily_plot.py From 5ec41162281f19aa3c9d48329c9bdfcc2b96cdbf Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Sat, 16 Apr 2022 11:51:11 -0400 Subject: [PATCH 5/5] removed the refresh --- scripts/overview.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/overview.php b/scripts/overview.php index d84a7ac..2af64f8 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -1,5 +1,4 @@