From a6644c59aa554da094ebb974fe736a5be78c2b36 Mon Sep 17 00:00:00 2001
From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com>
Date: Sat, 14 May 2022 16:10:18 -0400
Subject: [PATCH] Allow sorting of specific species in recordings
TODO: add actual svg files for sort icons
---
scripts/play.php | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/scripts/play.php b/scripts/play.php
index f6f84f5..7825dbc 100644
--- a/scripts/play.php
+++ b/scripts/play.php
@@ -151,13 +151,36 @@ if(!isset($_GET['species']) && !isset($_GET['filename'])){
}
#Specific Species
-if(isset($_GET['species'])){
+if(isset($_GET['species'])){ ?>
+
+
+
+prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Time DESC");
+ if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
+ $statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Confidence DESC");
+ } else {
+ $statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" AND Date == \"$date\" ORDER BY Time DESC");
+ }
} else {
- $statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Date DESC, Time DESC");}
+ if(isset($_GET['sort']) && $_GET['sort'] == "confidence") {
+ $statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Confidence DESC");
+ } else {
+ $statement2 = $db->prepare("SELECT * FROM detections where Com_Name == \"$name\" ORDER BY Date DESC, Time DESC");
+ }
+ }
if($statement2 == False){
echo "Database is busy";
header("refresh: 0;");
@@ -167,6 +190,9 @@ if(isset($_GET['species'])){
$name
";
+ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
+ $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
+ $home = trim($home);
while($results=$result2->fetchArray(SQLITE3_ASSOC))
{
$comname = preg_replace('/ /', '_', $results['Com_Name']);
@@ -176,7 +202,13 @@ if(isset($_GET['species'])){
$sciname = preg_replace('/ /', '_', $results['Sci_Name']);
$sci_name = $results['Sci_Name'];
$time = $results['Time'];
- $confidence = round($results['Confidence'],2);
+ $confidence = $results['Confidence'];
+
+ // file was deleted by disk check, no need to show the detection in recordings
+ if(!file_exists($home."/BirdSongs/Extracted/".$filename)) {
+ continue;
+ }
+
echo "