fix(jump-hop): isolate draft runs from public leaderboard

This commit is contained in:
kdletters
2026-06-05 01:19:49 +08:00
parent 1b39c0c5d7
commit cb08c9ad20
17 changed files with 167 additions and 34 deletions

View File

@@ -238,11 +238,16 @@ impl SpacetimeClient {
payload: JumpHopStartRunRequest,
owner_user_id: String,
) -> Result<JumpHopRuntimeRunSnapshotResponse, SpacetimeClientError> {
let profile_id = payload.profile_id;
let work = self
.get_jump_hop_work_profile(profile_id.clone(), String::new())
.await?;
let runtime_mode = normalize_jump_hop_runtime_mode(payload.runtime_mode.as_deref());
let profile_id = payload.profile_id;
let work_owner_user_id = if runtime_mode == "draft" {
owner_user_id.clone()
} else {
String::new()
};
let work = self
.get_jump_hop_work_profile(profile_id.clone(), work_owner_user_id)
.await?;
validate_jump_hop_runtime_ready(&work, runtime_mode)?;
let run_id = build_prefixed_uuid_id("jump-hop-run-");
let procedure_input = JumpHopRunStartInput {

View File

@@ -84,13 +84,18 @@ pub(crate) fn map_jump_hop_leaderboard_procedure_result(
pub(crate) fn map_jump_hop_gallery_card_view_row(
row: JumpHopGalleryCardViewRow,
) -> JumpHopGalleryCardResponse {
let theme_text = if row.theme_text.trim().is_empty() {
row.work_title.clone()
} else {
row.theme_text.clone()
};
JumpHopGalleryCardResponse {
public_work_code: row.public_work_code,
work_id: row.work_id,
profile_id: row.profile_id,
owner_user_id: row.owner_user_id,
author_display_name: row.author_display_name,
theme_text: row.work_title.clone(),
theme_text,
work_title: row.work_title,
work_description: row.work_description,
cover_image_src: empty_string_to_none(row.cover_image_src),
@@ -125,11 +130,16 @@ fn map_jump_hop_session_snapshot(
fn map_jump_hop_work_snapshot(
snapshot: JumpHopWorkSnapshot,
) -> Result<JumpHopWorkProfileResponse, SpacetimeClientError> {
let theme_text = if snapshot.theme_text.trim().is_empty() {
snapshot.work_title.clone()
} else {
snapshot.theme_text.clone()
};
let draft = JumpHopDraftResponse {
template_id: "jump-hop".to_string(),
template_name: "跳一跳".to_string(),
profile_id: Some(snapshot.profile_id.clone()),
theme_text: snapshot.work_title.clone(),
theme_text: theme_text.clone(),
work_title: snapshot.work_title.clone(),
work_description: snapshot.work_description.clone(),
theme_tags: snapshot.theme_tags.clone(),
@@ -166,7 +176,7 @@ fn map_jump_hop_work_snapshot(
profile_id: snapshot.profile_id,
owner_user_id: snapshot.owner_user_id,
source_session_id: empty_string_to_none(snapshot.source_session_id),
theme_text: snapshot.work_title.clone(),
theme_text,
work_title: snapshot.work_title,
work_description: snapshot.work_description,
theme_tags: snapshot.theme_tags,
@@ -195,7 +205,11 @@ fn map_jump_hop_work_snapshot(
}
fn map_jump_hop_draft_snapshot(snapshot: JumpHopDraftSnapshot) -> JumpHopDraftResponse {
let theme_text = snapshot.work_title.clone();
let theme_text = if snapshot.theme_text.trim().is_empty() {
snapshot.work_title.clone()
} else {
snapshot.theme_text.clone()
};
JumpHopDraftResponse {
template_id: snapshot.template_id,
template_name: snapshot.template_name,

View File

@@ -14,6 +14,7 @@ pub struct JumpHopDraftSnapshot {
pub template_id: String,
pub template_name: String,
pub profile_id: Option<String>,
pub theme_text: String,
pub work_title: String,
pub work_description: String,
pub theme_tags: Vec<String>,

View File

@@ -12,6 +12,7 @@ pub struct JumpHopGalleryCardViewRow {
pub profile_id: String,
pub owner_user_id: String,
pub author_display_name: String,
pub theme_text: String,
pub work_title: String,
pub work_description: String,
pub theme_tags: Vec<String>,
@@ -38,6 +39,7 @@ pub struct JumpHopGalleryCardViewRowCols {
pub profile_id: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub owner_user_id: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub author_display_name: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub theme_text: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub work_title: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub work_description: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, String>,
pub theme_tags: __sdk::__query_builder::Col<JumpHopGalleryCardViewRow, Vec<String>>,
@@ -63,6 +65,7 @@ impl __sdk::__query_builder::HasCols for JumpHopGalleryCardViewRow {
table_name,
"author_display_name",
),
theme_text: __sdk::__query_builder::Col::new(table_name, "theme_text"),
work_title: __sdk::__query_builder::Col::new(table_name, "work_title"),
work_description: __sdk::__query_builder::Col::new(table_name, "work_description"),
theme_tags: __sdk::__query_builder::Col::new(table_name, "theme_tags"),

View File

@@ -16,6 +16,7 @@ pub struct JumpHopGalleryViewRow {
pub owner_user_id: String,
pub source_session_id: String,
pub author_display_name: String,
pub theme_text: String,
pub work_title: String,
pub work_description: String,
pub theme_tags: Vec<String>,
@@ -51,6 +52,7 @@ pub struct JumpHopGalleryViewRowCols {
pub owner_user_id: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub source_session_id: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub author_display_name: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub theme_text: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub work_title: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub work_description: __sdk::__query_builder::Col<JumpHopGalleryViewRow, String>,
pub theme_tags: __sdk::__query_builder::Col<JumpHopGalleryViewRow, Vec<String>>,
@@ -88,6 +90,7 @@ impl __sdk::__query_builder::HasCols for JumpHopGalleryViewRow {
table_name,
"author_display_name",
),
theme_text: __sdk::__query_builder::Col::new(table_name, "theme_text"),
work_title: __sdk::__query_builder::Col::new(table_name, "work_title"),
work_description: __sdk::__query_builder::Col::new(table_name, "work_description"),
theme_tags: __sdk::__query_builder::Col::new(table_name, "theme_tags"),

View File

@@ -19,6 +19,7 @@ pub struct JumpHopRuntimeRunRow {
pub snapshot_json: String,
pub created_at: __sdk::Timestamp,
pub updated_at: __sdk::Timestamp,
pub runtime_mode: Option<String>,
}
impl __sdk::InModule for JumpHopRuntimeRunRow {
@@ -41,6 +42,7 @@ pub struct JumpHopRuntimeRunRowCols {
pub snapshot_json: __sdk::__query_builder::Col<JumpHopRuntimeRunRow, String>,
pub created_at: __sdk::__query_builder::Col<JumpHopRuntimeRunRow, __sdk::Timestamp>,
pub updated_at: __sdk::__query_builder::Col<JumpHopRuntimeRunRow, __sdk::Timestamp>,
pub runtime_mode: __sdk::__query_builder::Col<JumpHopRuntimeRunRow, Option<String>>,
}
impl __sdk::__query_builder::HasCols for JumpHopRuntimeRunRow {
@@ -62,6 +64,7 @@ impl __sdk::__query_builder::HasCols for JumpHopRuntimeRunRow {
snapshot_json: __sdk::__query_builder::Col::new(table_name, "snapshot_json"),
created_at: __sdk::__query_builder::Col::new(table_name, "created_at"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
runtime_mode: __sdk::__query_builder::Col::new(table_name, "runtime_mode"),
}
}
}

View File

@@ -32,6 +32,7 @@ pub struct JumpHopWorkProfileRow {
pub updated_at: __sdk::Timestamp,
pub published_at: Option<__sdk::Timestamp>,
pub visible: bool,
pub theme_text: Option<String>,
}
impl __sdk::InModule for JumpHopWorkProfileRow {
@@ -67,6 +68,7 @@ pub struct JumpHopWorkProfileRowCols {
pub updated_at: __sdk::__query_builder::Col<JumpHopWorkProfileRow, __sdk::Timestamp>,
pub published_at: __sdk::__query_builder::Col<JumpHopWorkProfileRow, Option<__sdk::Timestamp>>,
pub visible: __sdk::__query_builder::Col<JumpHopWorkProfileRow, bool>,
pub theme_text: __sdk::__query_builder::Col<JumpHopWorkProfileRow, Option<String>>,
}
impl __sdk::__query_builder::HasCols for JumpHopWorkProfileRow {
@@ -107,6 +109,7 @@ impl __sdk::__query_builder::HasCols for JumpHopWorkProfileRow {
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
published_at: __sdk::__query_builder::Col::new(table_name, "published_at"),
visible: __sdk::__query_builder::Col::new(table_name, "visible"),
theme_text: __sdk::__query_builder::Col::new(table_name, "theme_text"),
}
}
}

View File

@@ -16,6 +16,7 @@ pub struct JumpHopWorkSnapshot {
pub owner_user_id: String,
pub source_session_id: String,
pub author_display_name: String,
pub theme_text: String,
pub work_title: String,
pub work_description: String,
pub theme_tags: Vec<String>,