Skip to content

Commit

Permalink
Enforce tzinfo=timezone.utc in the schemas.
Browse files Browse the repository at this point in the history
Requires upgrading the vtjson package.
  • Loading branch information
vdbergh authored and ppigazzini committed Apr 18, 2024
1 parent c7d7d6f commit 9eb0dc9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions server/fishtest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
cond,
div,
email,
fields,
glob,
ifthen,
intersect,
Expand Down Expand Up @@ -52,6 +53,7 @@
epd_file = glob("*.epd", name="epd_file")
pgn_file = glob("*.pgn", name="pgn_file")
even = div(2, name="even")
datetime_utc = intersect(datetime, fields({"tzinfo": timezone.utc}))

uint = intersect(int, interval(0, ...))
suint = intersect(int, interval(1, ...))
Expand All @@ -62,7 +64,7 @@
"_id?": ObjectId,
"username": username,
"password": str,
"registration_time": datetime,
"registration_time": datetime_utc,
"pending": bool,
"blocked": bool,
"email": email,
Expand All @@ -77,7 +79,7 @@
"worker_name": short_worker_name,
"blocked": bool,
"message": worker_message,
"last_updated": datetime,
"last_updated": datetime_utc,
}


Expand All @@ -96,9 +98,9 @@ def first_test_before_last(x):
{
"_id?": ObjectId,
"downloads": uint,
"first_test?": {"date": datetime, "id": run_id},
"first_test?": {"date": datetime_utc, "id": run_id},
"is_master?": True,
"last_test?": {"date": datetime, "id": run_id},
"last_test?": {"date": datetime_utc, "id": run_id},
"name": net_name,
"user": username,
},
Expand All @@ -118,7 +120,7 @@ def first_test_before_last(x):
"diff": unumber,
"games": uint,
"games_per_hour": unumber,
"last_updated": datetime,
"last_updated": datetime_utc,
"str_last_updated": str,
"tests": uint,
"tests_repo": union(url, ""),
Expand Down Expand Up @@ -485,8 +487,8 @@ def final_results_must_match(run):
{
"_id?": ObjectId,
"version": uint,
"start_time": datetime,
"last_updated": datetime,
"start_time": datetime_utc,
"last_updated": datetime_utc,
"tc_base": unumber,
"base_same_as_master": bool,
"rescheduled_from?": run_id,
Expand Down Expand Up @@ -599,7 +601,7 @@ def final_results_must_match(run):
{
"num_games": intersect(uint, even),
"active": bool,
"last_updated": datetime,
"last_updated": datetime_utc,
"start": uint,
"residual?": number,
"residual_color?": str,
Expand All @@ -615,7 +617,7 @@ def final_results_must_match(run):
{
"num_games": intersect(uint, even),
"active": False,
"last_updated": datetime,
"last_updated": datetime_utc,
"start": uint,
"residual": number,
"residual_color": str,
Expand Down

0 comments on commit 9eb0dc9

Please sign in to comment.