修复按号查版本在 created_at 相同时结果不确定
- get_game_distribution_version_by_number_tx 的 max_by_key 改为 max_by - created_at 相同再用 version_id 兜底成全序,同一查询不再随索引顺序返回不同版本
This commit is contained in:
@@ -7626,7 +7626,14 @@ fn get_game_distribution_version_by_number_tx(
|
||||
.game_distribution_version()
|
||||
.by_game_distribution_version_game_and_number()
|
||||
.filter((game_id.as_str(), input.version_number))
|
||||
.max_by_key(|version| version.created_at.to_micros_since_unix_epoch());
|
||||
// `created_at` 可能相同,必须再用 `version_id` 兜底成全序:否则同一份 REST 查询会随索引
|
||||
// 迭代顺序在多个同号版本之间摇摆,版本身份不稳定。
|
||||
.max_by(|left, right| {
|
||||
left.created_at
|
||||
.to_micros_since_unix_epoch()
|
||||
.cmp(&right.created_at.to_micros_since_unix_epoch())
|
||||
.then_with(|| left.version_id.cmp(&right.version_id))
|
||||
});
|
||||
match version {
|
||||
Some(version) => Ok(Some(game_distribution_version_snapshot_for_game(
|
||||
ctx, &version,
|
||||
|
||||
Reference in New Issue
Block a user