diff --git a/queries/records/delete_expired_records.sql b/queries/records/delete_expired_records.sql new file mode 100644 index 0000000..0022bc2 --- /dev/null +++ b/queries/records/delete_expired_records.sql @@ -0,0 +1,5 @@ +DELETE FROM records +WHERE + downloads >= max_downloads + OR julianday('now') - julianday(uploaded) > 3 +RETURNING cache_name; diff --git a/queries/records/get_expired_records.sql b/queries/records/get_expired_records.sql new file mode 100644 index 0000000..ca719fb --- /dev/null +++ b/queries/records/get_expired_records.sql @@ -0,0 +1,7 @@ +SELECT + cache_name, + downloads, + max_downloads, + julianday('now') - julianday(uploaded) AS age +FROM records +WHERE downloads >= max_downloads OR age > 5;