diff --git a/Round.py b/Round.py
new file mode 100644
index 0000000..6ed3fce
--- /dev/null
+++ b/Round.py
@@ -0,0 +1,22 @@
+import json
+import datetime
+
+class Round:
+ def __init__(self, dbRow):
+ '''Create Round Object from cursor database row'''
+
+ timestamp, winners, losers, winnerSide, mapName, duration, prediction, confidence = dbRow
+ startTime = datetime.datetime.fromtimestamp(int(float(timestamp)))
+ winnersParsed = json.loads(winners)
+ losersParsed = json.loads(losers)
+
+ self.startTime = startTime
+ self.winners = winners
+ self.losers = losers
+ self.winnerSide = winnerSide
+ if winnerSide == 2:
+ self.winnerSideString = "Insurgent"
+ else:
+ self.winnerSideString = "Security"
+ self.mapName = mapName
+ self.duration = datetime.timedelta(seconds=int(duration))
diff --git a/database.py b/database.py
index ecb4bd7..ac1ec97 100644
--- a/database.py
+++ b/database.py
@@ -3,6 +3,7 @@ import json
import sqlite3
import player
import os
+import Round
DATABASE_PLAYERS = "players.sqlite"
DATABASE_ROUNDS = "rounds.sqlite"
@@ -120,3 +121,18 @@ class DatabaseConnection:
(player.mu, player.sigma))
rank = cursor.fetchone()[0]
return rank
+
+ def roundsBetweenDates(self, start, end):
+ '''Get rounds played between two times'''
+
+ cursor = self.connRounds.cursor()
+ cursor.execute('''SELECT * FROM rounds WHERE timestamp between ? and ?''',
+ (start.timestamp(), end.timestamp()))
+
+ print('''SELECT * FROM rounds WHERE timestamp between {} and {}'''.format(
+ start.timestamp(), end.timestamp()))
+
+ rounds = []
+ for row in cursor:
+ rounds += [Round.Round(row)]
+ return rounds
diff --git a/server.py b/server.py
index 7258514..34d9c32 100755
--- a/server.py
+++ b/server.py
@@ -28,6 +28,32 @@ def prettifyMinMaxY(computedMin, computedMax):
else:
return (computedMin - 100, 4000)
+@app.route("/rounds-by-timestamp")
+def rounds():
+ '''Show rounds played on the server'''
+
+ start = flask.request.args.get("start")
+ end = flask.request.args.get("end")
+
+ if not start or not end:
+ start = datetime.datetime.now() - datetime.timedelta(days=4000)
+ end = datetime.datetime.now()
+ else:
+ start = datetime.datetime.fromtimestamp(start)
+ end = datetime.datetime.fromtimestamp(end)
+
+ db = DatabaseConnection(app.config["DB_PATH"])
+ rounds = db.roundsBetweenDates(start, end)
+
+ return flask.render_template("rounds.html", rounds=rounds)
+
+
+ # get timestamp
+ # display players
+ # display rating change
+ # display outcome
+ # display map
+
@app.route("/player")
def player():
'''Show Info about Player'''
diff --git a/templates/rounds.html b/templates/rounds.html
new file mode 100644
index 0000000..35b4b5c
--- /dev/null
+++ b/templates/rounds.html
@@ -0,0 +1,52 @@
+
+
+
+ Rounds Played
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% include 'navbar.html' %}
+
+
+
+
+ | Map |
+ Winner |
+ Duration |
+ Start Time |
+
+
+
+ {% for r in rounds %}
+
+ | {{ r.mapName }} |
+ {{ r.winnerSideString }} |
+ {{ r.duration }} |
+ {{ r.startTime.strftime('%H:%M %d.%m.%Y') }} |
+
+ {% endfor %}
+
+
+
+ {% include 'footer.html' %}
+
+