cap community difficulties to 2-9 stars
This commit is contained in:
parent
9241e0b24c
commit
7ec85e78b0
|
@ -33,7 +33,7 @@ CrystalGauntlet.endpoints["/rateGJStars211.php"] = ->(context : HTTP::Server::Co
|
||||||
# todo: cache in some form?
|
# todo: cache in some form?
|
||||||
votes = DATABASE.query_all("select stars from difficulty_votes where level_id = ?", level_id, as: {Int32})
|
votes = DATABASE.query_all("select stars from difficulty_votes where level_id = ?", level_id, as: {Int32})
|
||||||
avg = votes.sum() / votes.size
|
avg = votes.sum() / votes.size
|
||||||
difficulty = stars_to_difficulty(Int32.new(avg.round()))
|
difficulty = stars_to_difficulty(Int32.new(avg.round()).clamp(2..9))
|
||||||
|
|
||||||
if difficulty
|
if difficulty
|
||||||
DATABASE.exec("update levels set community_difficulty = ? where id = ?", difficulty.value, level_id)
|
DATABASE.exec("update levels set community_difficulty = ? where id = ?", difficulty.value, level_id)
|
||||||
|
|
Loading…
Reference in New Issue