Skip to content

Commit

Permalink
WARSTATS: ensure the last wish for any realm is populated ...
Browse files Browse the repository at this point in the history
... even if a realm has not made any wish in the last 90 days (Hello
Alsius). It's not tested in the field, i'll fix later if needed.
  • Loading branch information
mascaldotfr committed Jun 6, 2024
1 parent 9732b1a commit 8fbdfee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/menu.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions warstatus/stats/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def statistics(events, db_file, force_rewrite = False):
full_report[0]["gems"] = reporter.get_gems()
full_report[0]["wishes"] = reporter.get_wishes()
full_report[0]["fortsheld"] = reporter.get_fortsheld()
for realm in ("Alsius", "Ignis", "Syrtis"):
# No wish the last 90 days?
if full_report[-1][realm]["wishes"]["last"] == None:
full_report[-1][realm]["wishes"]["last"] = reporter.get_last_wish_further(realm)
end_time = timer()
full_report[0]["generation_time"] = end_time - start_time;

Expand Down Expand Up @@ -176,6 +180,15 @@ def get_wishes(self):

return wishes

def get_last_wish_further(self, realm):
self.sql.execute(f"""select location, date
from events
where type="wish"
and location = "{realm}"
order by date desc limit 1""")
r = self.sql.fetchone()
return r["date"]

def get_fortsheld(self):
forts_held = {
"Aggersborg": {}, "Trelleborg": {}, "Imperia": {},
Expand Down

0 comments on commit 8fbdfee

Please sign in to comment.