Reset existing new badges on load

This commit is contained in:
2026-06-04 18:11:26 +09:00
parent c6284181b0
commit c3d2d3bcb2
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -124,6 +124,7 @@ class Logic(PluginModuleBase):
def plugin_load(self):
self._migrate_scheduler_settings()
ModelFreeGameItem.ensure_schema()
ModelFreeGameItem.reset_existing_new_flags()
def _migrate_scheduler_settings(self):
legacy_interval = str(ModelSetting.get("auto_interval") or "").strip()
+19
View File
@@ -117,6 +117,25 @@ class ModelFreeGameItem(ModelBase):
except Exception:
P.logger.exception("ff_freegame schema migration failed")
@classmethod
def reset_existing_new_flags(cls):
with F.app.app_context():
try:
cutoff = datetime.now() - timedelta(hours=49)
updated = (
F.db.session.query(cls)
.filter((cls.created_time == None) | (cls.created_time > cutoff))
.update({cls.created_time: cutoff}, synchronize_session=False)
)
F.db.session.commit()
if updated:
P.logger.info("ff_freegame reset existing NEW flags: %d", updated)
return updated
except Exception:
F.db.session.rollback()
P.logger.exception("ff_freegame reset existing NEW flags failed")
return 0
@classmethod
def delete_not_in_sources(cls, sources):
with F.app.app_context():