mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
fix various problem reported by users
This commit is contained in:
12
api.py
12
api.py
@@ -75,13 +75,14 @@ def getPlayerRatingFromApi(playerName, WATCHER):
|
|||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
# not found #
|
# not found #
|
||||||
if e.response.status_code == 404:
|
if e.response.status_code == 404:
|
||||||
addToDB(playerName, 0)
|
addToDB(playerName, DEFAULT_RATING)
|
||||||
return DEFAULT_RATING
|
return DEFAULT_RATING
|
||||||
# rate limit
|
# rate limit
|
||||||
elif e.response.status_code == 429:
|
elif e.response.status_code == 429:
|
||||||
print("Ratelimit reached")
|
print("Ratelimit reached")
|
||||||
time.sleep(120)
|
#time.sleep(120)
|
||||||
continue
|
#continue
|
||||||
|
return DEFAULT_RATING
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
if not pTmp:
|
if not pTmp:
|
||||||
@@ -95,8 +96,9 @@ def getPlayerRatingFromApi(playerName, WATCHER):
|
|||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
if e.response.status_code == 429:
|
if e.response.status_code == 429:
|
||||||
print("Ratelimit reached")
|
print("Ratelimit reached")
|
||||||
time.sleep(120)
|
return DEFAULT_RATING
|
||||||
continue
|
#time.sleep(120)
|
||||||
|
#continue
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|||||||
@@ -323,8 +323,11 @@ def balanceTool():
|
|||||||
retDict["left"].update( { positions[i] : bestOptionWithRating[i].name })
|
retDict["left"].update( { positions[i] : bestOptionWithRating[i].name })
|
||||||
retDict["right"].update({ positions[i] : bestOptionWithRating[i+5].name })
|
retDict["right"].update({ positions[i] : bestOptionWithRating[i+5].name })
|
||||||
|
|
||||||
|
import sys
|
||||||
|
print(flask.request.json, file=sys.stderr)
|
||||||
|
print(retDict, file=sys.stderr)
|
||||||
renderContent = flask.render_template("balance_response_partial.html", d=retDict,
|
renderContent = flask.render_template("balance_response_partial.html", d=retDict,
|
||||||
requests=flask.request.json,
|
reqJson=flask.request.json,
|
||||||
positions=positions,
|
positions=positions,
|
||||||
ratings=bestOptionRatings,
|
ratings=bestOptionRatings,
|
||||||
qualityPositions=int(theoMin/best*100),
|
qualityPositions=int(theoMin/best*100),
|
||||||
|
|||||||
@@ -11,12 +11,16 @@
|
|||||||
{{ positions[x] }}
|
{{ positions[x] }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm"
|
<div class="col-sm"
|
||||||
{% if requests[leftP][x] | int >= 4 %}style="background: red;"{% endif %}>
|
{% if reqJson.get(leftP) and reqJson.get(leftP)[x] | int >= 4 %}
|
||||||
{{ leftP }} ({{ ratings[x] }})
|
style="background: red;"
|
||||||
|
{% endif %}>
|
||||||
|
{{ leftP }} ({{ ratings[x] }})
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm"
|
<div class="col-sm"
|
||||||
{% if requests[rightP][x] | int >= 4 %}style="background: red;"{% endif %}>
|
{% if reqJson.get(rightP) and reqJson.get(rightP)[x] | int >= 4 %}
|
||||||
{{ rightP }} ({{ ratings[x+5] }})
|
style="background: red;"
|
||||||
|
{% endif %}>
|
||||||
|
{{ rightP }} ({{ ratings[x+5] }})
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user