Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Commit

Permalink
"Fix" replay buckets not being chosen correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
xnyo authored and r33int committed Oct 28, 2020
1 parent 56eaffe commit 498959b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions helpers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ def getWriteReplayBucketName():

def getReadReplayBucketName(scoreID):
r = objects.glob.db.fetch(
"SELECT `name`, max_score_id FROM s3_replay_buckets WHERE max_score_id IS NOT NULL "
"ORDER BY abs(max_score_id - %s) LIMIT 1",
(scoreID,)
"""SELECT name FROM (
SELECT `name`,
IFNULL((SELECT max_score_id + 1 FROM s3_replay_buckets WHERE id = x.id - 1), 0) AS min_score_id,
IFNULL(max_score_id, ~0) AS max_score_id
FROM s3_replay_buckets AS x
) AS x
WHERE %s > min_score_id AND %s < max_score_id
LIMIT 1""",
(scoreID, scoreID)
)
if r is not None and scoreID <= r["max_score_id"]:
if r is not None:
log.debug("s3 replay buckets resolve: {} -> {}".format(scoreID, r["name"]))
return r["name"]
log.debug("s3 replay buckets resolve: {} -> WRITE BUCKET".format(scoreID))
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.27.1
1.27.2

0 comments on commit 498959b

Please sign in to comment.