Skip to content

Commit

Permalink
Give referees acces for two hours, but also add all teams after an ho…
Browse files Browse the repository at this point in the history
…ur again, if no other match scheduled
  • Loading branch information
g3force committed Jun 21, 2021
1 parent 8f6c5f1 commit 31c7449
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config/referee-access/update_referee_caddy_passwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
config_dir = script_dir + "/.."
offset_before_seconds = 15 * 60
duration_seconds = 120 * 60
extra_duration_seconds = 120 * 60
admin_users = {"guacadmin"}
root_domain_file = config_dir + "/root_domain"
tournament_path = "/tournament_json"
Expand Down Expand Up @@ -57,7 +58,7 @@ def current_field():
return file.read().strip().replace("field-", "").upper()


def find_referees():
def find_referees(max_duration):
schedule = json.loads(fetch_tournament())
field = current_field()
now = datetime.utcnow().timestamp()
Expand All @@ -66,7 +67,7 @@ def find_referees():
if row["field"] == field:
start_timestamp = datetime.strptime(row["day"] + "_" + row["starttime"], '%Y-%m-%d_%H:%M').timestamp()
timestamp_diff = now - start_timestamp
if -offset_before_seconds < timestamp_diff < duration_seconds:
if -offset_before_seconds < timestamp_diff < max_duration:
referees += row["referee"].split(",")
return referees

Expand All @@ -83,7 +84,15 @@ def write_caddy_passwords(teams):


if __name__ == '__main__':
refs = find_referees()
# Get referees for next hour
refs = find_referees(duration_seconds)
if len(refs) == 0:
# If there are none: Take all (below)
refs = []
else:
# Else: Get those, but also for one more hour
refs = find_referees(extra_duration_seconds)

team_map = team_name_map()
users = set()
for ref in refs:
Expand Down

0 comments on commit 31c7449

Please sign in to comment.