From 898701a2e3be108de7e50af90355076960e595f5 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 1 Mar 2023 00:59:43 -0800 Subject: sort photos by uploadedAt --- _data/photos.json | 2 +- bot/bot.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/_data/photos.json b/_data/photos.json index 602ddbe..0a4d8c9 100644 --- a/_data/photos.json +++ b/_data/photos.json @@ -1 +1 @@ -[{"guid": "61881B2D-1B87-4C7B-B4EB-063836F10C90", "fileId": "2023-02-28-23-39-47-IMG_0070.webp", "width": 5280, "height": 3512, "ratio": 1.5034168564920274, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-39-47-IMG_0070.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:39:47.000Z", "uploadedAt": "2023-02-28T23:39:47.000Z"}, {"guid": "B77DFD0A-342F-41F6-97ED-4FB289149A77", "fileId": "2023-02-28-23-43-55-IMG_0021.webp", "width": 5928, "height": 3992, "ratio": 1.4849699398797596, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-43-55-IMG_0021.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:43:55.000Z", "uploadedAt": "2023-02-28T23:43:55.000Z"}, {"guid": "E3A61BC5-F07C-4681-94B0-AB4CCE4AB843", "fileId": "2023-03-01-00-52-37-IMG_0016.webp", "width": 3548, "height": 5268, "ratio": 0.6735003796507213, "orientation": "portrait", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-52-37-IMG_0016.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:52:37.000Z", "uploadedAt": "2023-03-01T00:52:37.000Z"}, {"guid": "D997B634-063F-4E32-B290-809D53DABFD2", "fileId": "2023-03-01-00-54-08-IMG_0134.webp", "width": 5328, "height": 3548, "ratio": 1.5016910935738443, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-54-08-IMG_0134.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:54:08.000Z", "uploadedAt": "2023-03-01T00:54:08.000Z"}] \ No newline at end of file +[{"guid": "480EDD16-EC60-4773-96BB-05C5643D6AA7", "fileId": "2023-03-01-00-59-03-IMG_0140.webp", "width": 3548, "height": 5268, "ratio": 0.6735003796507213, "orientation": "portrait", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-59-03-IMG_0140.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:59:03.000Z", "uploadedAt": "2023-03-01T00:59:03.000Z"}, {"guid": "D997B634-063F-4E32-B290-809D53DABFD2", "fileId": "2023-03-01-00-54-08-IMG_0134.webp", "width": 5328, "height": 3548, "ratio": 1.5016910935738443, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-54-08-IMG_0134.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:54:08.000Z", "uploadedAt": "2023-03-01T00:54:08.000Z"}, {"guid": "E3A61BC5-F07C-4681-94B0-AB4CCE4AB843", "fileId": "2023-03-01-00-52-37-IMG_0016.webp", "width": 3548, "height": 5268, "ratio": 0.6735003796507213, "orientation": "portrait", "path": "https://pixelstatic.jinwei.me/2023-03-01-00-52-37-IMG_0016.webp", "caption": "", "alt": "", "createdAt": "2023-03-01T00:52:37.000Z", "uploadedAt": "2023-03-01T00:52:37.000Z"}, {"guid": "B77DFD0A-342F-41F6-97ED-4FB289149A77", "fileId": "2023-02-28-23-43-55-IMG_0021.webp", "width": 5928, "height": 3992, "ratio": 1.4849699398797596, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-43-55-IMG_0021.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:43:55.000Z", "uploadedAt": "2023-02-28T23:43:55.000Z"}, {"guid": "61881B2D-1B87-4C7B-B4EB-063836F10C90", "fileId": "2023-02-28-23-39-47-IMG_0070.webp", "width": 5280, "height": 3512, "ratio": 1.5034168564920274, "orientation": "landscape", "path": "https://pixelstatic.jinwei.me/2023-02-28-23-39-47-IMG_0070.webp", "caption": "", "alt": "", "createdAt": "2023-02-28T23:39:47.000Z", "uploadedAt": "2023-02-28T23:39:47.000Z"}] \ No newline at end of file diff --git a/bot/bot.py b/bot/bot.py index 9d9b322..f379e95 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -73,6 +73,7 @@ def write_json() -> bool: "createdAt": photo.createdAt.strftime("%Y-%m-%dT%H:%M:%S.000Z"), "uploadedAt": photo.uploadedAt.strftime("%Y-%m-%dT%H:%M:%S.000Z") }) + results.sort(key=lambda x: x["uploadedAt"], reverse=True) with open("database/photos.json", "w") as f: f.write(json.dumps(results)) return True -- cgit v1.2.3