2 parents ed4eb4c + 42eb8c3 commit 1e039a6Copy full SHA for 1e039a6
1 file changed
backend/models/mongo_models.py
@@ -1026,7 +1026,13 @@ def is_count_cache_valid(self):
1026
if not self.last_count_update:
1027
return False
1028
1029
- cache_age = (datetime.now(UTC) - self.last_count_update).total_seconds()
+ # Handle timezone-aware/naive datetime compatibility
1030
+ last_update = self.last_count_update
1031
+ if last_update.tzinfo is None:
1032
+ # Convert naive datetime to timezone-aware
1033
+ last_update = last_update.replace(tzinfo=UTC)
1034
+
1035
+ cache_age = (datetime.now(UTC) - last_update).total_seconds()
1036
return cache_age < self.count_cache_ttl
1037
1038
def update_count_cache(self, model_class):
0 commit comments