Skip to content

A live bird collage card for your Home Assistant dashboard.

Set custom duration for minigraphs

Alexandref9d166d4f080
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index 06b0753a..b00951eb 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -59,9 +59,11 @@ $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC);
if(isset($_GET['comname'])) {
$birdName = htmlspecialchars_decode($_GET['comname'], ENT_QUOTES);
+// Set default days to 30 if not provided
+$days = isset($_GET['days']) ? intval($_GET['days']) : 30;
// Prepare a SQL statement to retrieve the detection data for the specified bird
-$stmt = $db->prepare('SELECT Date, COUNT(*) AS Detections FROM detections WHERE Com_Name = :com_name AND Date BETWEEN DATE("now", "-30 days") AND DATE("now") GROUP BY Date');
+$stmt = $db->prepare('SELECT Date, COUNT(*) AS Detections FROM detections WHERE Com_Name = :com_name AND Date BETWEEN DATE("now", "-' . $days . ' days") AND DATE("now") GROUP BY Date');
// Bind the bird name parameter to the SQL statement
$stmt->bindValue(':com_name', $birdName);