From 4c14264dfea451f8620fef391365fd4d4df3f024 Mon Sep 17 00:00:00 2001 From: Bruce Wang Date: Tue, 31 Dec 2024 17:03:34 +0800 Subject: [PATCH] v2.4.3 get users only if within last 45 days (#58) --- bot/database_service/firestore_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/database_service/firestore_service.py b/bot/database_service/firestore_service.py index a3c776f..7398a77 100644 --- a/bot/database_service/firestore_service.py +++ b/bot/database_service/firestore_service.py @@ -99,7 +99,8 @@ def get_user_sheet_id(self, telegram_id, telegram_username): # Get all user IDs def get_all_user_id(self): try: - users_ref = self.db.collection(self.collection_name) + two_months_ago = datetime.now() - timedelta(days=45) + users_ref = self.db.collection(self.collection_name).where('last_accessed', '>=', two_months_ago) user_ids = [int(user.id) for user in users_ref.stream()] return user_ids except Exception as e: