Codex worktree snapshot: settings-delete-targeted
Co-authored-by: Codex
This commit is contained in:
@@ -436,7 +436,8 @@ fn delete_custom_world_agent_session_tx(
|
||||
let published_profile = ctx
|
||||
.db
|
||||
.custom_world_profile()
|
||||
.iter()
|
||||
.by_custom_world_profile_owner_user_id()
|
||||
.filter(&input.owner_user_id)
|
||||
.find(|row| {
|
||||
row.owner_user_id == input.owner_user_id
|
||||
&& row.source_agent_session_id.as_deref() == Some(input.session_id.as_str())
|
||||
@@ -471,8 +472,8 @@ fn delete_custom_world_agent_session_tx(
|
||||
for message in ctx
|
||||
.db
|
||||
.custom_world_agent_message()
|
||||
.iter()
|
||||
.filter(|row| row.session_id == input.session_id)
|
||||
.by_custom_world_agent_message_session_id()
|
||||
.filter(&input.session_id)
|
||||
.collect::<Vec<_>>()
|
||||
{
|
||||
ctx.db
|
||||
@@ -483,8 +484,8 @@ fn delete_custom_world_agent_session_tx(
|
||||
for operation in ctx
|
||||
.db
|
||||
.custom_world_agent_operation()
|
||||
.iter()
|
||||
.filter(|row| row.session_id == input.session_id)
|
||||
.by_custom_world_agent_operation_session_id()
|
||||
.filter(&input.session_id)
|
||||
.collect::<Vec<_>>()
|
||||
{
|
||||
ctx.db
|
||||
@@ -495,8 +496,8 @@ fn delete_custom_world_agent_session_tx(
|
||||
for card in ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.iter()
|
||||
.filter(|row| row.session_id == input.session_id)
|
||||
.by_custom_world_draft_card_session_id()
|
||||
.filter(&input.session_id)
|
||||
.collect::<Vec<_>>()
|
||||
{
|
||||
ctx.db
|
||||
@@ -1184,9 +1185,17 @@ fn upsert_custom_world_profile_record(
|
||||
.source_agent_session_id
|
||||
.as_ref()
|
||||
.and_then(|session_id| {
|
||||
ctx.db.custom_world_profile().iter().find(|row| {
|
||||
is_same_agent_draft_profile_candidate(row, &input.owner_user_id, session_id)
|
||||
})
|
||||
ctx.db
|
||||
.custom_world_profile()
|
||||
.by_custom_world_profile_owner_user_id()
|
||||
.filter(&input.owner_user_id)
|
||||
.find(|row| {
|
||||
is_same_agent_draft_profile_candidate(
|
||||
row,
|
||||
&input.owner_user_id,
|
||||
session_id,
|
||||
)
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1534,8 +1543,9 @@ fn list_custom_world_profile_snapshots(
|
||||
let mut entries = ctx
|
||||
.db
|
||||
.custom_world_profile()
|
||||
.iter()
|
||||
.filter(|row| row.owner_user_id == input.owner_user_id && row.deleted_at.is_none())
|
||||
.by_custom_world_profile_owner_user_id()
|
||||
.filter(&input.owner_user_id)
|
||||
.filter(|row| row.deleted_at.is_none())
|
||||
.map(|row| build_custom_world_profile_snapshot(&row))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -1676,8 +1686,9 @@ fn get_custom_world_gallery_detail_record_by_code(
|
||||
let gallery_entry = ctx
|
||||
.db
|
||||
.custom_world_gallery_entry()
|
||||
.iter()
|
||||
.find(|row| row.public_work_code == normalized_public_work_code);
|
||||
.by_custom_world_gallery_public_work_code()
|
||||
.filter(&normalized_public_work_code)
|
||||
.next();
|
||||
|
||||
let profile = gallery_entry.as_ref().and_then(|row| {
|
||||
ctx.db
|
||||
@@ -1974,9 +1985,14 @@ fn list_custom_world_work_snapshots(
|
||||
let mut items = Vec::new();
|
||||
let mut active_agent_session_ids = HashSet::new();
|
||||
|
||||
for session in ctx.db.custom_world_agent_session().iter().filter(|row| {
|
||||
row.owner_user_id == input.owner_user_id
|
||||
&& row.stage != RpgAgentStage::Published
|
||||
let sessions = ctx
|
||||
.db
|
||||
.custom_world_agent_session()
|
||||
.by_custom_world_agent_session_owner_user_id()
|
||||
.filter(&input.owner_user_id)
|
||||
.collect::<Vec<_>>();
|
||||
for session in sessions.iter().filter(|row| {
|
||||
row.stage != RpgAgentStage::Published
|
||||
&& should_include_custom_world_agent_session_work(ctx, row)
|
||||
}) {
|
||||
active_agent_session_ids.insert(session.session_id.clone());
|
||||
@@ -2021,8 +2037,9 @@ fn list_custom_world_work_snapshots(
|
||||
for profile in ctx
|
||||
.db
|
||||
.custom_world_profile()
|
||||
.iter()
|
||||
.filter(|row| row.owner_user_id == input.owner_user_id && row.deleted_at.is_none())
|
||||
.by_custom_world_profile_owner_user_id()
|
||||
.filter(&input.owner_user_id)
|
||||
.filter(|row| row.deleted_at.is_none())
|
||||
.filter(|row| should_include_custom_world_profile_work(row, &active_agent_session_ids))
|
||||
{
|
||||
items.push(CustomWorldWorkSummarySnapshot {
|
||||
@@ -2086,16 +2103,20 @@ fn should_include_custom_world_agent_session_work(
|
||||
return true;
|
||||
}
|
||||
|
||||
if ctx.db.custom_world_agent_message().iter().any(|message| {
|
||||
message.session_id == session.session_id
|
||||
&& matches!(message.role, RpgAgentMessageRole::User)
|
||||
}) {
|
||||
if ctx
|
||||
.db
|
||||
.custom_world_agent_message()
|
||||
.by_custom_world_agent_message_session_id()
|
||||
.filter(&session.session_id)
|
||||
.any(|message| matches!(message.role, RpgAgentMessageRole::User))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ctx.db
|
||||
.custom_world_draft_card()
|
||||
.iter()
|
||||
.by_custom_world_draft_card_session_id()
|
||||
.filter(&session.session_id)
|
||||
.any(|card| card.session_id == session.session_id)
|
||||
}
|
||||
|
||||
@@ -3446,10 +3467,12 @@ fn update_role_asset_cards(
|
||||
label: &str,
|
||||
updated_at_micros: i64,
|
||||
) {
|
||||
for card in
|
||||
ctx.db.custom_world_draft_card().iter().filter(|row| {
|
||||
row.session_id == session_id && row.kind == RpgAgentDraftCardKind::Character
|
||||
})
|
||||
for card in ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.by_custom_world_draft_card_session_id()
|
||||
.filter(&session_id.to_string())
|
||||
.filter(|row| row.kind == RpgAgentDraftCardKind::Character)
|
||||
{
|
||||
replace_custom_world_draft_card(
|
||||
ctx,
|
||||
@@ -4590,8 +4613,8 @@ fn resolve_session_work_counts(
|
||||
for card in ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.iter()
|
||||
.filter(|row| row.session_id == session.session_id)
|
||||
.by_custom_world_draft_card_session_id()
|
||||
.filter(&session.session_id)
|
||||
{
|
||||
match card.kind {
|
||||
RpgAgentDraftCardKind::Character => {
|
||||
@@ -4827,11 +4850,9 @@ fn sync_missing_custom_world_gallery_entries(ctx: &ReducerContext) -> Result<(),
|
||||
let published_profiles = ctx
|
||||
.db
|
||||
.custom_world_profile()
|
||||
.iter()
|
||||
.filter(|profile| {
|
||||
profile.publication_status == CustomWorldPublicationStatus::Published
|
||||
&& profile.deleted_at.is_none()
|
||||
})
|
||||
.by_custom_world_profile_publication_status()
|
||||
.filter(CustomWorldPublicationStatus::Published)
|
||||
.filter(|profile| profile.deleted_at.is_none())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for profile in published_profiles {
|
||||
@@ -4973,8 +4994,8 @@ fn build_custom_world_agent_session_snapshot(
|
||||
let mut messages = ctx
|
||||
.db
|
||||
.custom_world_agent_message()
|
||||
.iter()
|
||||
.filter(|message| message.session_id == row.session_id)
|
||||
.by_custom_world_agent_message_session_id()
|
||||
.filter(&row.session_id)
|
||||
.map(|message| build_custom_world_agent_message_snapshot(&message))
|
||||
.collect::<Vec<_>>();
|
||||
messages.sort_by_key(|message| (message.created_at_micros, message.message_id.clone()));
|
||||
@@ -4982,8 +5003,8 @@ fn build_custom_world_agent_session_snapshot(
|
||||
let mut draft_cards = ctx
|
||||
.db
|
||||
.custom_world_draft_card()
|
||||
.iter()
|
||||
.filter(|card| card.session_id == row.session_id)
|
||||
.by_custom_world_draft_card_session_id()
|
||||
.filter(&row.session_id)
|
||||
.map(|card| build_custom_world_draft_card_snapshot(&card))
|
||||
.collect::<Vec<_>>();
|
||||
draft_cards.sort_by_key(|card| (card.created_at_micros, card.card_id.clone()));
|
||||
@@ -4991,8 +5012,8 @@ fn build_custom_world_agent_session_snapshot(
|
||||
let mut operations = ctx
|
||||
.db
|
||||
.custom_world_agent_operation()
|
||||
.iter()
|
||||
.filter(|operation| operation.session_id == row.session_id)
|
||||
.by_custom_world_agent_operation_session_id()
|
||||
.filter(&row.session_id)
|
||||
.map(|operation| build_custom_world_agent_operation_snapshot(&operation))
|
||||
.collect::<Vec<_>>();
|
||||
operations
|
||||
|
||||
Reference in New Issue
Block a user