implement map overview

This commit is contained in:
Yannik Schmidt
2020-10-14 00:25:40 +02:00
parent 868346ad90
commit c3bb6f0e04
6 changed files with 128 additions and 0 deletions

View File

@@ -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():