diff --git a/MapSummary.py b/MapSummary.py
new file mode 100644
index 0000000..8eae11d
--- /dev/null
+++ b/MapSummary.py
@@ -0,0 +1,45 @@
+import json
+import datetime
+import player
+import datetime
+
+class MapSummary:
+ def __init__(self, rounds):
+ '''Create a map MapSummary from a Round-Array'''
+
+ self.securityWins = 0
+ self.insurgentWins = 0
+ self.times = []
+ self.predictions = []
+ self.totalGames = 0
+ self.confidence = []
+ self.mapName = None
+
+ for r in rounds:
+ self.mapName = r.mapName
+ self.totalGames += 1
+ if r.winnerSideString == "Insurgent":
+ self.insurgentWins += 1
+ else:
+ self.securityWins += 1
+
+ self.predictions += [r.numericPrediction]
+ self.confidence += [r.confidence]
+ self.times += [r.duration]
+
+ self.insurgentWinPercent = ""
+ self.securityWinPercent = ""
+ self.ratingSystemDeviation = "-"
+ self.averageTime = ""
+
+ try:
+ self.insurgentWinPercent = self.insurgentWins / self.totalGames*100
+ self.securityWinPercent = self.securityWins / self.totalGames*100
+ predictionPercision = 1 - sum(self.predictions)/len(self.predictions)
+ confidenceAverage = sum(self.confidence) / len(self.confidence)
+ averageSeconds = sum([t.total_seconds() for t in self.times]) / len(self.times)
+ self.averageTime = datetime.timedelta(seconds=int(averageSeconds))
+ self.ratingSystemDeviation = predictionPercision*100 - confidenceAverage
+ except ZeroDivisionError:
+ pass
+
diff --git a/Round.py b/Round.py
index 209ce30..6352e95 100644
--- a/Round.py
+++ b/Round.py
@@ -29,6 +29,7 @@ class Round:
self.mapName = "unavailiable"
self.confidence = int(confidence * 100)
+ self.numericPrediction = prediction
if prediction == 0:
self.prediction = self.winnerSideString
elif prediction == 1:
diff --git a/database.py b/database.py
index 327e251..380be68 100644
--- a/database.py
+++ b/database.py
@@ -168,4 +168,8 @@ class DatabaseConnection:
return None
return Round.Round(row)
+ def distinctMaps(self):
+ '''Get all distinct maps from rounds database'''
+ cursorRounds = self.connRounds.cursor()
+ return cursorRounds.execute('''SELECT DISTINCT map from rounds''')
diff --git a/rounds.sqlite b/rounds.sqlite
new file mode 100644
index 0000000..cd5909c
Binary files /dev/null and b/rounds.sqlite differ
diff --git a/server.py b/server.py
index 8e8ce2a..68e24e0 100755
--- a/server.py
+++ b/server.py
@@ -6,6 +6,7 @@ import datetime
import flask_caching as fcache
import json
import os
+import MapSummary
from database import DatabaseConnection
@@ -44,6 +45,23 @@ def singleRound():
return flask.render_template("single_round.html", r=r)
+@app.route("/maps")
+def maps():
+ '''Show an overview of maps'''
+
+ db = DatabaseConnection(app.config["DB_PATH"])
+ start = datetime.datetime.now() - datetime.timedelta(days=4000)
+ end = datetime.datetime.now()
+ rounds = db.roundsBetweenDates(start, end)
+ distinctMaps = db.distinctMaps()
+ maps = []
+ for mapName in [ tupel[0] for tupel in distinctMaps]:
+ roundsWithMap = list(filter(lambda r: r.mapName == mapName , rounds))
+ maps += [MapSummary.MapSummary(roundsWithMap)]
+
+ mapsFiltered = filter(lambda x: x.mapName, maps)
+ return flask.render_template("maps.html", maps=mapsFiltered)
+
@app.route("/rounds-by-timestamp")
@app.route("/rounds")
def rounds():
diff --git a/templates/maps.html b/templates/maps.html
new file mode 100644
index 0000000..5bab78b
--- /dev/null
+++ b/templates/maps.html
@@ -0,0 +1,60 @@
+
+
+
+ Maps
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% include 'navbar.html' %}
+
+
+
+
+ | Map |
+ Insurgent Win |
+ Security Win |
+ Average Time |
+ Rating System Deviation |
+
+
+
+ {% for m in maps %}
+
+ | {{ m.mapName }} |
+ {{ '%0.2f' | format(m.insurgentWinPercent) }}% |
+ {{ '%0.2f' | format(m.securityWinPercent) }}% |
+ {{ m.averageTime }} |
+ {% if m.ratingSystemDeviation >= 0 %}
+ +{{ '%0.2f' | format(m.ratingSystemDeviation) }}%
+ |
+ {% else %}
+ +{{ '%0.2f' | format(m.ratingSystemDeviation) }}%
+ |
+ {% endif %}
+
+ {% endfor %}
+
+
+
+ {% include 'footer.html' %}
+
+