mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
fix bug in displayed rating change
This commit is contained in:
20
database.py
20
database.py
@@ -3,6 +3,7 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import player
|
import player
|
||||||
import os
|
import os
|
||||||
|
import datetime
|
||||||
import Round
|
import Round
|
||||||
|
|
||||||
DATABASE_PLAYERS = "players.sqlite"
|
DATABASE_PLAYERS = "players.sqlite"
|
||||||
@@ -148,7 +149,7 @@ class DatabaseConnection:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
cursorHist.execute('''SELECT mu,sima FROM playerHistoricalData
|
cursorHist.execute('''SELECT mu,sima FROM playerHistoricalData
|
||||||
WHERE timestamp < ? AND id = ? LIMIT 1 ''',
|
WHERE timestamp < ? AND id = ? order by timestamp DESC LIMIT 1 ''',
|
||||||
(roundObj.startTime.timestamp(), p.playerId))
|
(roundObj.startTime.timestamp(), p.playerId))
|
||||||
tupelPrev = cursorHist.fetchone()
|
tupelPrev = cursorHist.fetchone()
|
||||||
cursorHist.execute('''SELECT mu,sima FROM playerHistoricalData
|
cursorHist.execute('''SELECT mu,sima FROM playerHistoricalData
|
||||||
@@ -163,20 +164,23 @@ class DatabaseConnection:
|
|||||||
p.muChange = muAfter - muPrev
|
p.muChange = muAfter - muPrev
|
||||||
p.sigmaChange = sigmaAfter - sigmaPrev
|
p.sigmaChange = sigmaAfter - sigmaPrev
|
||||||
ratingChange = int( (muAfter-muPrev) - 2*(sigmaAfter-sigmaPrev) )
|
ratingChange = int( (muAfter-muPrev) - 2*(sigmaAfter-sigmaPrev) )
|
||||||
|
if abs(ratingChange) > 500:
|
||||||
|
p.ratingChangeString = "Placements"
|
||||||
|
continue
|
||||||
if(ratingChange < 0):
|
if(ratingChange < 0):
|
||||||
p.ratingChangeString = "- {:x>5}".format(abs(ratingChange))
|
p.ratingChangeString = "- {:x>5}".format(abs(ratingChange))
|
||||||
else:
|
else:
|
||||||
p.ratingChangeString = "+ {:x>5}".format(ratingChange)
|
p.ratingChangeString = "+ {:x>5}".format(ratingChange)
|
||||||
p.ratingChangeString = p.ratingChangeString.replace("x", " ")
|
p.ratingChangeString = p.ratingChangeString.replace("x", " ")
|
||||||
|
|
||||||
roundObj.winnerRatingTotal = sum([p.mu - 2*p.sigma for p in roundObj.winners])
|
|
||||||
roundObj.losersRatingTotal = sum([p.mu - 2*p.sigma for p in roundObj.losers])
|
|
||||||
higher = max(roundObj.winnerRatingTotal, roundObj.losersRatingTotal)
|
|
||||||
lower = min(roundObj.winnerRatingTotal, roundObj.losersRatingTotal)
|
|
||||||
if higher/lower > 2.1:
|
|
||||||
roundObj.invalid = "Not rated because of team imbalance."
|
|
||||||
else:
|
|
||||||
roundObj.invalid = ""
|
roundObj.invalid = ""
|
||||||
|
roundObj.teamPtRatio = 0
|
||||||
|
if roundObj.teamPtRatio > 2.1:
|
||||||
|
roundObj.invalid += "Not rated because of playtime imbalance."
|
||||||
|
if roundObj.duration < datetime.timedelta(seconds=120):
|
||||||
|
if roundObj.invalid:
|
||||||
|
roundObj.invalid += "<br>"
|
||||||
|
roundObj.invalid += "Not rated because too short."
|
||||||
|
|
||||||
return roundObj
|
return roundObj
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ def player():
|
|||||||
|
|
||||||
csv_month_year = []
|
csv_month_year = []
|
||||||
csv_ratings = []
|
csv_ratings = []
|
||||||
|
csv_timestamps = []
|
||||||
|
|
||||||
minRating = 3000
|
minRating = 3000
|
||||||
maxRating = 0
|
maxRating = 0
|
||||||
@@ -111,6 +112,7 @@ def player():
|
|||||||
tsMs = str(int(t.timestamp() * 1000))
|
tsMs = str(int(t.timestamp() * 1000))
|
||||||
ratingString = str(int(datapoints[dpk]["mu"]) - 2*int(datapoints[dpk]["sigma"]))
|
ratingString = str(int(datapoints[dpk]["mu"]) - 2*int(datapoints[dpk]["sigma"]))
|
||||||
ratingAmored = '{ x : ' + tsMs + ', y : ' + ratingString + '}'
|
ratingAmored = '{ x : ' + tsMs + ', y : ' + ratingString + '}'
|
||||||
|
csv_timestamps += [str(tsMs)]
|
||||||
csv_ratings += [ratingAmored]
|
csv_ratings += [ratingAmored]
|
||||||
|
|
||||||
tickCounter -= 1
|
tickCounter -= 1
|
||||||
@@ -128,6 +130,7 @@ def player():
|
|||||||
|
|
||||||
return flask.render_template("player.html", player=player, CSV_RATINGS=",".join(csv_ratings),
|
return flask.render_template("player.html", player=player, CSV_RATINGS=",".join(csv_ratings),
|
||||||
CSV_MONTH_YEAR_OF_RATINGS=",".join(csv_month_year),
|
CSV_MONTH_YEAR_OF_RATINGS=",".join(csv_month_year),
|
||||||
|
CSV_TIMESTAMPS=csv_timestamps,
|
||||||
Y_MIN=yMin, Y_MAX=yMax)
|
Y_MIN=yMin, Y_MAX=yMax)
|
||||||
|
|
||||||
@app.route('/leaderboard')
|
@app.route('/leaderboard')
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
<body class="bg-special">
|
<body class="bg-special">
|
||||||
{% include 'navbar.html' %}
|
{% include 'navbar.html' %}
|
||||||
<div class="container mt-3 mb-3" role="main">
|
<div class="container mt-3 mb-3" role="main">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm">
|
||||||
<h1>Round {{ r.id }}</h1>
|
<h1>Round {{ r.id }}</h1>
|
||||||
<h4>{{ r.startTime }}</h4>
|
<h4>{{ r.startTime }}</h4>
|
||||||
<h4>Map: {{ r.mapName }}</h4>
|
<h4>Map: {{ r.mapName }}</h4>
|
||||||
@@ -15,9 +18,14 @@
|
|||||||
|
|
||||||
{% if r.invalid %}
|
{% if r.invalid %}
|
||||||
<div>
|
<div>
|
||||||
<h5 style="color: red;">{{ r.invalid }}</h5>
|
<h5 style="color: red;">{{ r.invalid | safe }}</h5>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm">
|
||||||
|
<!-- to be used -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -69,6 +77,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="mt-3">
|
||||||
|
<small style="font-weight: bold;">Stats for nerds</small><br>
|
||||||
|
<small>Balance: {{ 100 - r.confidence }}%</small><br>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% include 'footer.html' %}
|
{% include 'footer.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user