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

@@ -55,21 +55,14 @@ pub fn list_big_fish_works(
input: BigFishWorksListInput,
) -> BigFishWorksProcedureResult {
match ctx.try_with_tx(|tx| list_big_fish_works_tx(tx, input.clone())) {
Ok(items) => match serde_json::to_string(&items) {
Ok(items_json) => BigFishWorksProcedureResult {
ok: true,
items_json: Some(items_json),
error_message: None,
},
Err(error) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
error_message: Some(error.to_string()),
},
Ok(items) => BigFishWorksProcedureResult {
ok: true,
items,
error_message: None,
},
Err(message) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -81,21 +74,14 @@ pub fn delete_big_fish_work(
input: BigFishWorkDeleteInput,
) -> BigFishWorksProcedureResult {
match ctx.try_with_tx(|tx| delete_big_fish_work_tx(tx, input.clone())) {
Ok(items) => match serde_json::to_string(&items) {
Ok(items_json) => BigFishWorksProcedureResult {
ok: true,
items_json: Some(items_json),
error_message: None,
},
Err(error) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
error_message: Some(error.to_string()),
},
Ok(items) => BigFishWorksProcedureResult {
ok: true,
items,
error_message: None,
},
Err(message) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -107,21 +93,14 @@ pub fn record_big_fish_play(
input: BigFishPlayRecordInput,
) -> BigFishWorksProcedureResult {
match ctx.try_with_tx(|tx| record_big_fish_play_tx(tx, input.clone())) {
Ok(items) => match serde_json::to_string(&items) {
Ok(items_json) => BigFishWorksProcedureResult {
ok: true,
items_json: Some(items_json),
error_message: None,
},
Err(error) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
error_message: Some(error.to_string()),
},
Ok(items) => BigFishWorksProcedureResult {
ok: true,
items,
error_message: None,
},
Err(message) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -133,21 +112,14 @@ pub fn record_big_fish_like(
input: BigFishWorkLikeRecordInput,
) -> BigFishWorksProcedureResult {
match ctx.try_with_tx(|tx| record_big_fish_like_tx(tx, input.clone())) {
Ok(items) => match serde_json::to_string(&items) {
Ok(items_json) => BigFishWorksProcedureResult {
ok: true,
items_json: Some(items_json),
error_message: None,
},
Err(error) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
error_message: Some(error.to_string()),
},
Ok(items) => BigFishWorksProcedureResult {
ok: true,
items,
error_message: None,
},
Err(message) => BigFishWorksProcedureResult {
ok: false,
items_json: None,
items: Vec::new(),
error_message: Some(message),
},
}
@@ -321,16 +293,20 @@ pub(crate) fn list_big_fish_works_tx(
validate_works_list_input(&input).map_err(|error| error.to_string())?;
let now_micros = ctx.timestamp.to_micros_since_unix_epoch();
let mut items = ctx
let rows = ctx
.db
.big_fish_creation_session()
.by_big_fish_session_owner_user_id()
.filter(&input.owner_user_id)
.collect::<Vec<_>>();
let mut items = rows
.iter()
.filter(|row| {
if input.published_only {
return row.stage == BigFishCreationStage::Published;
}
row.owner_user_id == input.owner_user_id && should_include_big_fish_work(ctx, row)
should_include_big_fish_work(ctx, row)
})
.map(|row| build_big_fish_work_summary(ctx, &row, now_micros))
.collect::<Result<Vec<_>, _>>()?;
@@ -349,10 +325,11 @@ fn should_include_big_fish_work(ctx: &ReducerContext, row: &BigFishCreationSessi
return true;
}
ctx.db.big_fish_agent_message().iter().any(|message| {
message.session_id == row.session_id
&& matches!(message.role, BigFishAgentMessageRole::User)
})
ctx.db
.big_fish_agent_message()
.by_big_fish_message_session_id()
.filter(&row.session_id)
.any(|message| matches!(message.role, BigFishAgentMessageRole::User))
}
fn big_fish_session_has_direct_work_content(row: &BigFishCreationSession) -> bool {
@@ -387,8 +364,8 @@ pub(crate) fn delete_big_fish_work_tx(
for message in ctx
.db
.big_fish_agent_message()
.iter()
.filter(|row| row.session_id == input.session_id)
.by_big_fish_message_session_id()
.filter(&input.session_id)
.collect::<Vec<_>>()
{
ctx.db
@@ -399,8 +376,8 @@ pub(crate) fn delete_big_fish_work_tx(
for slot in ctx
.db
.big_fish_asset_slot()
.iter()
.filter(|row| row.session_id == input.session_id)
.by_big_fish_asset_session_id()
.filter(&input.session_id)
.collect::<Vec<_>>()
{
ctx.db.big_fish_asset_slot().slot_id().delete(&slot.slot_id);
@@ -408,8 +385,8 @@ pub(crate) fn delete_big_fish_work_tx(
for run in ctx
.db
.big_fish_runtime_run()
.iter()
.filter(|row| row.session_id == input.session_id)
.by_big_fish_run_session_id()
.filter(&input.session_id)
.collect::<Vec<_>>()
{
ctx.db.big_fish_runtime_run().run_id().delete(&run.run_id);
@@ -952,8 +929,8 @@ pub(crate) fn build_big_fish_session_snapshot(
let mut messages = ctx
.db
.big_fish_agent_message()
.iter()
.filter(|message| message.session_id == row.session_id)
.by_big_fish_message_session_id()
.filter(&row.session_id)
.map(|message| BigFishAgentMessageSnapshot {
message_id: message.message_id,
session_id: message.session_id,