From b0d59de8e794c84f2089515e3adf3a68703c96b8 Mon Sep 17 00:00:00 2001 From: Edward Delaporte Date: Sat, 6 Jun 2026 20:07:20 -0500 Subject: [PATCH] Show unique items from past 90 days when requested --- matrix_shop_bot/db.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matrix_shop_bot/db.py b/matrix_shop_bot/db.py index 007e758..6cacc33 100644 --- a/matrix_shop_bot/db.py +++ b/matrix_shop_bot/db.py @@ -1,6 +1,7 @@ import logging import os from datetime import datetime as dt +from datetime import timedelta from decimal import Decimal from typing import List @@ -191,9 +192,13 @@ class Data(): def list_purchases(self, store_name): with Session(self.engine) as session: - cmd = select(PurchaseRecord).where(func.lower(PurchaseRecord.store) == func.lower(store_name)) + recent = dt.now() - timedelta(days=90) + cmd = select(PurchaseRecord).where(func.lower(PurchaseRecord.store) == func.lower(store_name)).where(PurchaseRecord.purchase_date > recent) records = session.exec(cmd).all() - return records + bought = set() + for item in records: + bought.add(item.name) + return list(bought) def purchase_items(self, item_ids): results = [] -- 2.47.3