From 923103c5ef2dbb7a06aa9eef64da280b9144d254 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Thu, 21 Nov 2024 10:19:16 -0800 Subject: [PATCH] add query and data types in prep for bulk record json response --- queries/records/get_records.sql | 6 ++++++ queries/records/get_records_page.sql | 7 +++++++ src/views/templates.rs | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 queries/records/get_records.sql create mode 100644 queries/records/get_records_page.sql diff --git a/queries/records/get_records.sql b/queries/records/get_records.sql new file mode 100644 index 0000000..1a62878 --- /dev/null +++ b/queries/records/get_records.sql @@ -0,0 +1,6 @@ +SELECT + cache_name, + uploaded, + downloads, + max_downloads +FROM records; diff --git a/queries/records/get_records_page.sql b/queries/records/get_records_page.sql new file mode 100644 index 0000000..25e59b5 --- /dev/null +++ b/queries/records/get_records_page.sql @@ -0,0 +1,7 @@ +SELECT + cache_name, + uploaded, + downloads, + max_downloads +FROM records +LIMIT ? OFFSET ?; diff --git a/src/views/templates.rs b/src/views/templates.rs index 5487d18..4ee7f5e 100644 --- a/src/views/templates.rs +++ b/src/views/templates.rs @@ -39,6 +39,12 @@ pub struct DownloadLinkFragment { pub record: UploadRecord, } +#[derive(Template)] +#[template(path = "link.html", block = "downloads_remaining")] +pub struct DownloadsRemainingFragment { + pub record: UploadRecord, +} + #[derive(Template)] #[template(path = "linklist.html")] pub struct LinkListTemplate {