From 6ef889fc06fb3adb149d94ffe4b67c6c397b3b62 Mon Sep 17 00:00:00 2001 From: Correl Date: Thu, 8 Dec 2022 15:37:40 -0500 Subject: [PATCH] Fix collection stats query Only include latest prices so the card count and value totals are reported correctly. --- tutor/database.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutor/database.py b/tutor/database.py index 81c72c4..41d60a1 100644 --- a/tutor/database.py +++ b/tutor/database.py @@ -373,6 +373,8 @@ async def collection_stats(db: psycopg.Cursor) -> dict: FROM "copies" JOIN "cards" USING ("scryfall_id") LEFT JOIN "card_prices" USING ("scryfall_id") + WHERE "card_prices"."date" = + (SELECT "value" FROM "vars" where "key" = 'last_update') """ ) return await db.fetchone()