Codex worktree snapshot: settings-delete-targeted

Co-authored-by: Codex
This commit is contained in:
kdletters
2026-05-16 22:52:10 +08:00
parent 7f16e88e57
commit 01af298c07
115 changed files with 2831 additions and 1324 deletions

View File

@@ -105,12 +105,12 @@ pub fn list_match3d_works(
match ctx.try_with_tx(|tx| list_match3d_works_tx(tx, input.clone())) {
Ok(items) => Match3DWorksProcedureResult {
ok: true,
items_json: Some(to_json_string(&items)),
items,
error_message: None,
},
Err(message) => Match3DWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -135,12 +135,12 @@ pub fn delete_match3d_work(
match ctx.try_with_tx(|tx| delete_match3d_work_tx(tx, input.clone())) {
Ok(items) => Match3DWorksProcedureResult {
ok: true,
items_json: Some(to_json_string(&items)),
items,
error_message: None,
},
Err(message) => Match3DWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -178,7 +178,7 @@ pub fn click_match3d_item(
Err(message) => Match3DClickItemProcedureResult {
ok: false,
status: MATCH3D_CLICK_REJECTED_NOT_CLICKABLE.to_string(),
run_json: None,
run: None,
accepted_item_instance_id: None,
cleared_item_instance_ids: Vec::new(),
failure_reason: None,
@@ -632,17 +632,22 @@ fn list_match3d_works_tx(
ctx: &ReducerContext,
input: Match3DWorksListInput,
) -> Result<Vec<Match3DWorkSnapshot>, String> {
let mut items = ctx
.db
.match3d_work_profile()
let rows = if input.published_only {
ctx.db
.match3d_work_profile()
.by_match3d_work_publication_status()
.filter(&MATCH3D_PUBLICATION_PUBLISHED.to_string())
.collect::<Vec<_>>()
} else {
require_non_empty(&input.owner_user_id, "match3d owner_user_id")?;
ctx.db
.match3d_work_profile()
.by_match3d_work_owner_user_id()
.filter(&input.owner_user_id)
.collect::<Vec<_>>()
};
let mut items = rows
.iter()
.filter(|row| {
if input.published_only {
row.publication_status == MATCH3D_PUBLICATION_PUBLISHED
} else {
row.owner_user_id == input.owner_user_id
}
})
.map(|row| build_work_snapshot(&row))
.collect::<Result<Vec<_>, _>>()?;
items.sort_by(|left, right| {
@@ -683,10 +688,9 @@ fn delete_match3d_work_tx(
for run in ctx
.db
.match3d_runtime_run()
.iter()
.filter(|row| {
row.profile_id == input.profile_id && row.owner_user_id == input.owner_user_id
})
.by_match3d_run_profile_id()
.filter(&input.profile_id)
.filter(|row| row.owner_user_id == input.owner_user_id)
.collect::<Vec<_>>()
{
ctx.db.match3d_runtime_run().run_id().delete(&run.run_id);
@@ -929,8 +933,8 @@ fn build_session_snapshot(
let mut messages = ctx
.db
.match3d_agent_message()
.iter()
.filter(|message| message.session_id == row.session_id)
.by_match3d_agent_message_session_id()
.filter(&row.session_id)
.map(|message| Match3DAgentMessageSnapshot {
message_id: message.message_id,
session_id: message.session_id,
@@ -1154,10 +1158,10 @@ fn click_result(
Match3DClickItemProcedureResult {
ok: true,
status: status.to_string(),
run_json: Some(to_json_string(&snapshot)),
failure_reason: snapshot.failure_reason.clone(),
run: Some(snapshot),
accepted_item_instance_id,
cleared_item_instance_ids,
failure_reason: snapshot.failure_reason,
error_message: None,
}
}
@@ -1715,7 +1719,7 @@ fn to_json_string<T: Serialize>(value: &T) -> String {
fn session_result(session: Match3DAgentSessionSnapshot) -> Match3DAgentSessionProcedureResult {
Match3DAgentSessionProcedureResult {
ok: true,
session_json: Some(to_json_string(&session)),
session: Some(session),
error_message: None,
}
}
@@ -1723,7 +1727,7 @@ fn session_result(session: Match3DAgentSessionSnapshot) -> Match3DAgentSessionPr
fn session_error(message: String) -> Match3DAgentSessionProcedureResult {
Match3DAgentSessionProcedureResult {
ok: false,
session_json: None,
session: None,
error_message: Some(message),
}
}
@@ -1731,7 +1735,7 @@ fn session_error(message: String) -> Match3DAgentSessionProcedureResult {
fn work_result(work: Match3DWorkSnapshot) -> Match3DWorkProcedureResult {
Match3DWorkProcedureResult {
ok: true,
work_json: Some(to_json_string(&work)),
work: Some(work),
error_message: None,
}
}
@@ -1739,7 +1743,7 @@ fn work_result(work: Match3DWorkSnapshot) -> Match3DWorkProcedureResult {
fn work_error(message: String) -> Match3DWorkProcedureResult {
Match3DWorkProcedureResult {
ok: false,
work_json: None,
work: None,
error_message: Some(message),
}
}
@@ -1747,7 +1751,7 @@ fn work_error(message: String) -> Match3DWorkProcedureResult {
fn run_result(run: Match3DRunSnapshot) -> Match3DRunProcedureResult {
Match3DRunProcedureResult {
ok: true,
run_json: Some(to_json_string(&run)),
run: Some(run),
error_message: None,
}
}
@@ -1755,7 +1759,7 @@ fn run_result(run: Match3DRunSnapshot) -> Match3DRunProcedureResult {
fn run_error(message: String) -> Match3DRunProcedureResult {
Match3DRunProcedureResult {
ok: false,
run_json: None,
run: None,
error_message: Some(message),
}
}

View File

@@ -182,43 +182,43 @@ pub struct Match3DRunTimeUpInput {
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct Match3DAgentSessionProcedureResult {
pub ok: bool,
pub session_json: Option<String>,
pub session: Option<Match3DAgentSessionSnapshot>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct Match3DWorkProcedureResult {
pub ok: bool,
pub work_json: Option<String>,
pub work: Option<Match3DWorkSnapshot>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct Match3DWorksProcedureResult {
pub ok: bool,
pub items_json: Option<String>,
pub items: Vec<Match3DWorkSnapshot>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
#[derive(Clone, Debug, PartialEq, SpacetimeType)]
pub struct Match3DRunProcedureResult {
pub ok: bool,
pub run_json: Option<String>,
pub run: Option<Match3DRunSnapshot>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
#[derive(Clone, Debug, PartialEq, SpacetimeType)]
pub struct Match3DClickItemProcedureResult {
pub ok: bool,
pub status: String,
pub run_json: Option<String>,
pub run: Option<Match3DRunSnapshot>,
pub accepted_item_instance_id: Option<String>,
pub cleared_item_instance_ids: Vec<String>,
pub failure_reason: Option<String>,
pub error_message: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DCreatorConfigSnapshot {
pub theme_text: String,
@@ -235,7 +235,7 @@ pub struct Match3DCreatorConfigSnapshot {
pub generate_click_sound: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DAgentMessageSnapshot {
pub message_id: String,
@@ -246,7 +246,7 @@ pub struct Match3DAgentMessageSnapshot {
pub created_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DDraftSnapshot {
pub profile_id: String,
@@ -258,7 +258,7 @@ pub struct Match3DDraftSnapshot {
pub difficulty: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DAgentSessionSnapshot {
pub session_id: String,
@@ -276,7 +276,7 @@ pub struct Match3DAgentSessionSnapshot {
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DWorkSnapshot {
pub profile_id: String,
@@ -300,7 +300,7 @@ pub struct Match3DWorkSnapshot {
pub generated_item_assets_json: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DItemSnapshot {
pub item_instance_id: String,
@@ -314,7 +314,7 @@ pub struct Match3DItemSnapshot {
pub clickable: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DTraySlotSnapshot {
pub slot_index: u32,
@@ -323,7 +323,7 @@ pub struct Match3DTraySlotSnapshot {
pub visual_key: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, SpacetimeType)]
#[serde(rename_all = "camelCase")]
pub struct Match3DRunSnapshot {
pub run_id: String,