From 63e44c5ad3d0cd82607000b5ad04616267ed946a Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sat, 24 Nov 2018 17:33:26 -0800 Subject: [PATCH] Thanksgiving Signed-off-by: James Ketrenos --- frontend/src/ketr-photos/ketr-photos.html | 6 +++ server/routes/photos.js | 56 ++++++++--------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index a362c13..2d966cf 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -13,6 +13,7 @@ + @@ -313,6 +314,7 @@ + @@ -384,6 +386,7 @@
[[item.name]] /
+
Thanksgiving!
time
Photos taken on [[memoryDate]]
@@ -1692,6 +1695,8 @@ path = ""; } else if (mode == "memories") { path = "memories/" + (this.date.replace(this.year + "-", "") || ""); + } else if (mode == "thanksgiving") { + path = "thanksgiving/"; } } var username = this.user ? this.user.username : ""; @@ -1706,6 +1711,7 @@ if ((username != (this.user ? this.user.username : "")) || (mode != this.mode) || ((mode == "albums") && (path != (this.path || ""))) || + ((mode == "thanksgiving") && (path != ("thanksgiving/"))) || ((mode == "memories") && (path != ("memories/" + (this.date.replace(this.year + "-", "") || ""))))) { console.log("Skipping results for old query. Triggering re-fetch of photos for new path or mode."); this._loadPhotos(); diff --git a/server/routes/photos.js b/server/routes/photos.js index be68040..0b5ed48 100755 --- a/server/routes/photos.js +++ b/server/routes/photos.js @@ -565,34 +565,29 @@ router.get("/thanksgiving", function(req, res/*, next*/) { "2017-11-23", "2018-11-22", "2019-11-28", - "2020-11-26", + "2020-11-26" + ]; - ] + let dayIsThanksgiving = ""; + thanksgiving.forEach(function(date) { + let comparison = "strftime('%Y-%m-%d',taken)='" + date + "'"; + if (!dayIsThanksgiving) { + dayIsThanksgiving = comparison; + } else { + dayIsThanksgiving += " OR " + comparison; + } + }); - index = "strftime('%m-%d',taken)=strftime('%m-%d',:date)"; - } else { - index = "((strftime('%Y-%m-%d',taken)=strftime('%Y-%m-%d',:cursor) AND photos.id<"+id+ ") OR " + - "(strftime('%m-%d',taken)=strftime('%m-%d',:cursor) AND strftime('%Y',taken) limit; /* We queried one extra item to see if there are more than LIMIT available */ + return res.status(200).json({ + items: photos + }); - let last; - if (more) { - photos.splice(limit); - last = photos[photos.length - 1]; - } - - let results = { - items: photos.sort(function(a, b) { - return new Date(b.taken) - new Date(a.taken); - }) - }; - - if (more) { - results.cursor = new Date(last.taken).toISOString().replace(/T.*/, "") + "_" + last.id; - results.more = true; - } - return res.status(200).json(results); }).catch(function(error) { console.error("Query failed: " + query); return Promise.reject(error);