From e8276b84388409dadb45281724df9c257b63f584 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Tue, 22 Dec 2020 16:37:44 +0100 Subject: [PATCH] fix some problems with livegames --- database.py | 10 +++++---- templates/livegames.html | 48 ++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/database.py b/database.py index bf0f78a..82dfa80 100644 --- a/database.py +++ b/database.py @@ -134,8 +134,8 @@ class DatabaseConnection: '''Get current live games''' cursor = self.connPlayers.cursor() - cursor.execute('''SELECT * FROM live WHERE time > ? LIMIT 2''', - (datetime.datetime.now().timestamp(),)) + cursor.execute('''SELECT * FROM live WHERE time > ? ORDER BY time DESC LIMIT 2''', ( + (datetime.datetime.now() - datetime.timedelta(minutes=100)).timestamp(),)) liveRounds = [] for row in cursor: @@ -150,8 +150,10 @@ class DatabaseConnection: security += [p] p.update({"active_time":-1}) - dbRow = [time, json.dumps(insurgent), json.loads(security), "N/A", 0, 0 ,0] - r = Round.Round(row) + dbRow = [time, json.dumps(insurgent), json.dumps(security), -1, "N/A", duration, 0 ,0] + r = Round.Round(dbRow) + r.winners = [ self.getPlayerById(p.playerId) for p in r.winners] + r.losers = [ self.getPlayerById(p.playerId) for p in r.losers] r.id = trackingID liveRounds += [r] diff --git a/templates/livegames.html b/templates/livegames.html index acb2a2e..3097896 100644 --- a/templates/livegames.html +++ b/templates/livegames.html @@ -19,16 +19,10 @@
-

Tracking ID {{ r.id }}

-

{{ r.startTime }}

+

Tracking ID {{ r.id }}

+

{{ r.startTime }}

Map: {{ r.mapName }}

Duration: {{ r.duration }}

- - {% if r.invalid %} -
-
{{ r.invalid | safe }}
-
- {% endif %}
@@ -41,7 +35,28 @@
Security
- +
+
+
+
+
Name
+
+
+
Rating
+
+
+
+
+
+
+
Name
+
+
+
Rating
+
+
+
+
{# WINNERS == INSURGENT for livegames #} @@ -51,11 +66,7 @@ {{ p.name }}
- {% if not r.invalid %} - - {{ p.ratingChangeString | safe }} - - {% endif %} + {{ p.rating }}
{% endfor %} @@ -68,14 +79,7 @@ {{ p.name }}
- {{ p.participation }}% -
-
- {% if not r.invalid %} - - {{ p.ratingChangeString | safe }} - - {% endif %} + {{ p.rating }}
{% endfor %}