支持统一版本回退与重复提交
Project CI / Backend tests (pull_request) Failing after 54s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m22s
Project CI / Frontend tests (pull_request) Successful in 2m8s
Project CI / Repository checks (pull_request) Failing after 17s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 4m23s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 4m27s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m3s
Project CI / Native shell tests (pull_request) Successful in 5m18s

以 projectVersion 作为唯一用户版本标签,允许同版本重复提交和版本回退。

按 versionId 保持提交实例不可变,取消同版本旧 pending 提交并按最近提交排序。
This commit is contained in:
2026-10-03 16:55:00 +08:00
parent 3aa3e33ceb
commit 7bf7d6b10e
@@ -1990,6 +1990,24 @@ fn create_game_distribution_version_tx(
let version_number =
resolve_game_distribution_version_number(max_existing_version, input.version_number)?;
let now = Timestamp::from_micros_since_unix_epoch(input.now_micros);
for mut pending in ctx
.db
.game_distribution_version()
.by_game_distribution_version_game_id()
.filter(&game_id)
.filter(|version| {
version.version_number == version_number
&& version.status == GAME_DISTRIBUTION_VERSION_PENDING_REVIEW
})
{
pending.status = GAME_DISTRIBUTION_VERSION_CANCELLED.to_string();
pending.review_reason = Some("被同一项目版本的新提交替代".to_string());
pending.updated_at = now;
ctx.db
.game_distribution_version()
.version_id()
.update(pending);
}
ctx.db
.game_distribution_version()
.insert(GameDistributionVersion {
@@ -2855,8 +2873,8 @@ fn restore_game_distribution_game_tx(
.collect::<Vec<_>>();
candidates.sort_by(|left, right| {
right
.version_number
.cmp(&left.version_number)
.updated_at
.cmp(&left.updated_at)
.then_with(|| right.version_id.cmp(&left.version_id))
});
let mut version = candidates
@@ -3189,8 +3207,8 @@ fn admin_game_distribution_game_snapshot(
let version_count = versions.len() as u64;
versions.sort_by(|left, right| {
right
.version_number
.cmp(&left.version_number)
.updated_at
.cmp(&left.updated_at)
.then_with(|| right.version_id.cmp(&left.version_id))
});
versions.truncate(GAME_DISTRIBUTION_ADMIN_VERSION_HISTORY_LIMIT);
@@ -3347,8 +3365,8 @@ fn list_owner_game_distribution_games_tx(
.collect::<Vec<_>>();
versions.sort_by(|left, right| {
right
.version_number
.cmp(&left.version_number)
.updated_at
.cmp(&left.updated_at)
.then_with(|| right.version_id.cmp(&left.version_id))
});
versions.truncate(GAME_DISTRIBUTION_MAX_OWNER_VERSIONS_PER_GAME);