|
for (player, score) in scores.player_scores { |
|
players::Entity::update(players::ActiveModel { |
|
id: Set(player.inner.id), |
|
score: Set(score), |
|
..Default::default() |
|
}) |
|
.exec(txn) |
|
.await?; |
|
|
|
pipe.zadd(player_ranking(), player.inner.id, score); |
|
} |
|
|
|
for (map, score) in scores.map_scores { |
|
maps::Entity::update(maps::ActiveModel { |
|
id: Set(map.inner.id), |
|
score: Set(score), |
|
..Default::default() |
|
}) |
|
.exec(txn) |
|
.await?; |
|
|
|
pipe.zadd(map_ranking(), map.inner.id, score); |
|
} |
This is bad and should be changed into a bulk update. The update could be made through the UPDATE FROM (VALUES ...) syntax, available in Postgres, or with a CASE WHEN for each entry for MariaDB/MySQL.
Obstacle-API/crates/socc/src/player_ranking.rs
Lines 31 to 53 in d068a5c
This is bad and should be changed into a bulk update. The update could be made through the
UPDATE FROM (VALUES ...)syntax, available in Postgres, or with aCASE WHENfor each entry for MariaDB/MySQL.