Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
biuti committed Aug 19, 2024
1 parent e3b8257 commit dbb9ba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions airscore/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,20 @@ class CompResult(object):
def to_html(json_file: str) -> (str, dict or list):
""" create a HTML file from json result file"""
import re

from frontendUtils import get_pretty_data

res = get_pretty_data(open_json_file(json_file), export=True)
comp_name = f"{res['info']['comp_name']}"
rankings = res['rankings']
formula = res['formula']

if len(res['rankings']) > 1:
zipfile = f"{re.sub(r'[ ,.-]', '_', comp_name)}_after_{res['tasks'][-1]['task_code']}.zip"
else:
zipfile = False

'''Tasks table'''
tasks = []
tbody = []
thead = [' ', ' ', 'Dist.', 'Validity']
right_align = [2, 3]
for t in res['tasks']:
Expand All @@ -482,8 +483,8 @@ def to_html(json_file: str) -> (str, dict or list):
t['opt_dist'],
t['ftv_validity'] if res['formula']['overall_validity'] == 'ftv' else t['day_quality'],
]
tasks.append(row)
tasks = dict(title='Tasks', css_class='simple', right_align=right_align, thead=thead, tbody=tasks)
tbody.append(row)
tasks = dict(title='Tasks', css_class='simple', right_align=right_align, thead=thead, tbody=tbody)

'''Main results table'''
thead = ['#', 'Id', 'Name', 'Nat', 'Glider', 'Sponsor', 'Total']
Expand Down
2 changes: 1 addition & 1 deletion airscore/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
REDIS_URL = env.str("REDIS_URL") or 'redis://'
REDIS_PORT = env.int("REDIS_PORT", default=6379)
REDIS_SSL = env.bool("REDIS_SSL", default=False)
REDIS_SSL_CERT_REQS = env.str("REDIS_SSL_CERT_REQS") or None
REDIS_SSL_CERT_REQS = env.str("REDIS_SSL_CERT_REQS", "")
WEB_SERVER_CONTAINER = env.str("WEB_SERVER_CONTAINER")
FLASK_CONTAINER = env.str("FLASK_CONTAINER")
FLASK_PORT = env.str("FLASK_PORT")
Expand Down

0 comments on commit dbb9ba8

Please sign in to comment.