Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebHost: Round percentage of checks, fix possible 500 error #2270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebHostLib/templates/lttpMultiTracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
{%- endif -%}
{% endif %}
{%- endfor -%}
<td class="center-column">{{ percent_total_checks_done[team][player] }}</td>
<td class="center-column">{{ "{0:.2f}".format(percent_total_checks_done[team][player]) }}</td>
{%- if activity_timers[(team, player)] -%}
<td class="center-column">{{ activity_timers[(team, player)].total_seconds() }}</td>
{%- else -%}
Expand Down
10 changes: 8 additions & 2 deletions WebHostLib/templates/multiTracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<td class="center-column" data-sort="{{ checks["Total"] }}">
{{ checks["Total"] }}/{{ locations[player] | length }}
</td>
<td class="center-column">{{ percent_total_checks_done[team][player] }}</td>
<td class="center-column">{{ "{0:.2f}".format(percent_total_checks_done[team][player]) }}</td>
{%- if activity_timers[team, player] -%}
<td class="center-column">{{ activity_timers[team, player].total_seconds() }}</td>
{%- else -%}
Expand All @@ -72,7 +72,13 @@
<td>All Games</td>
<td>{{ completed_worlds }}/{{ players|length }} Complete</td>
<td class="center-column">{{ players.values()|sum(attribute='Total') }}/{{ total_locations[team] }}</td>
<td class="center-column">{{ (players.values()|sum(attribute='Total') / total_locations[team] * 100) | int }}</td>
<td class="center-column">
{% if total_locations[team] == 0 %}
100
{% else %}
{{ "{0:.2f}".format(players.values()|sum(attribute='Total') / total_locations[team] * 100) }}
{% endif %}
</td>
<td class="center-column last-activity"></td>
</tr>
</tfoot>
Expand Down
19 changes: 12 additions & 7 deletions WebHostLib/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,9 +1532,11 @@ def _get_multiworld_tracker_data(tracker: UUID) -> typing.Optional[typing.Dict[s
continue
player_locations = locations[player]
checks_done[team][player]["Total"] = len(locations_checked)
percent_total_checks_done[team][player] = int(checks_done[team][player]["Total"] /
len(player_locations) * 100) \
if player_locations else 100
percent_total_checks_done[team][player] = (
checks_done[team][player]["Total"] / len(player_locations) * 100
if player_locations
else 100
)

activity_timers = {}
now = datetime.datetime.utcnow()
Expand Down Expand Up @@ -1690,10 +1692,13 @@ def attribute_item(team: int, recipient: int, item: int):
for recipient in recipients:
attribute_item(team, recipient, item)
checks_done[team][player][player_location_to_area[player][location]] += 1
checks_done[team][player]["Total"] += 1
percent_total_checks_done[team][player] = int(
checks_done[team][player]["Total"] / len(player_locations) * 100) if \
player_locations else 100
checks_done[team][player]["Total"] = len(locations_checked)

percent_total_checks_done[team][player] = (
checks_done[team][player]["Total"] / len(player_locations) * 100
if player_locations
else 100
)

for (team, player), game_state in multisave.get("client_game_state", {}).items():
if player in groups:
Expand Down