better hourly record
[scannr.git] / purgeArchived.php
blob:a/purgeArchived.php -> blob:b/purgeArchived.php
--- a/purgeArchived.php
+++ b/purgeArchived.php
@@ -1,1 +1,13 @@
+<?php
+include('common.inc.php');
+// delete archived calls
+$sth = $conn->prepare("select tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings group by tgid, ahour, aday order by  aday DESC, ahour, tgid;");
+// TODO use tgid categories instead, tgid too specific
+$sth->execute();
+$hourlies = $sth->fetchAll(PDO::FETCH_ASSOC);
+foreach($hourlies as $hourly) {
+    processHourly($hourly);
+}
 
+// delete uninteresting compilations
+