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

@@ -95,8 +95,8 @@ fn list_platform_browse_history_rows(
let mut entries = ctx
.db
.user_browse_history()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_browse_history_user_id()
.filter(&validated_input.user_id)
.map(|row| build_runtime_browse_history_snapshot_from_row(&row))
.collect::<Vec<_>>();
@@ -165,8 +165,8 @@ fn clear_platform_browse_history_rows(
let row_ids = ctx
.db
.user_browse_history()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_browse_history_user_id()
.filter(&validated_input.user_id)
.map(|row| row.browse_history_id.clone())
.collect::<Vec<_>>();

View File

@@ -1079,8 +1079,8 @@ pub(crate) fn list_profile_save_archive_rows(
let mut entries = ctx
.db
.profile_save_archive()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_profile_save_archive_user_id()
.filter(&validated_input.user_id)
.map(|row| build_profile_save_archive_snapshot_from_row(&row))
.collect::<Vec<_>>();
@@ -1104,10 +1104,12 @@ pub(crate) fn resume_profile_save_archive_record(
let archive = ctx
.db
.profile_save_archive()
.iter()
.find(|row| {
row.user_id == validated_input.user_id && row.world_key == validated_input.world_key
})
.by_profile_save_archive_user_world_key()
.filter((
validated_input.user_id.as_str(),
validated_input.world_key.as_str(),
))
.next()
.ok_or_else(|| "profile_save_archive 对应 world_key 不存在".to_string())?;
let existing_snapshot = ctx
@@ -2052,8 +2054,8 @@ fn get_profile_dashboard_snapshot(
let played_world_count = ctx
.db
.profile_played_world()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_profile_played_world_user_id()
.filter(&validated_input.user_id)
.count() as u32;
Ok(match state {
@@ -2084,8 +2086,8 @@ fn list_profile_wallet_ledger_entries(
let mut entries = ctx
.db
.profile_wallet_ledger()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_profile_wallet_ledger_user_id()
.filter(&validated_input.user_id)
.map(|row| build_profile_wallet_ledger_snapshot_from_row(&row))
.collect::<Vec<_>>();
@@ -2114,8 +2116,8 @@ fn get_profile_play_stats_snapshot(
let mut played_works = ctx
.db
.profile_played_world()
.iter()
.filter(|row| row.user_id == validated_input.user_id)
.by_profile_played_world_user_id()
.filter(&validated_input.user_id)
.map(|row| build_profile_played_world_snapshot_from_row(&row))
.collect::<Vec<_>>();
@@ -2727,17 +2729,16 @@ fn build_profile_referral_invite_center_snapshot(
let code = ensure_profile_invite_code(ctx, user_id);
let today_inviter_reward_count =
count_today_profile_referral_inviter_rewards(ctx, user_id, ctx.timestamp);
let invited_count = ctx
let invited_relations = ctx
.db
.profile_referral_relation()
.by_profile_referral_inviter_user_id()
.filter(user_id)
.collect::<Vec<_>>();
let invited_count = invited_relations.len() as u32;
let rewarded_invite_count = invited_relations
.iter()
.filter(|row| row.inviter_user_id == user_id)
.count() as u32;
let rewarded_invite_count = ctx
.db
.profile_referral_relation()
.iter()
.filter(|row| row.inviter_user_id == user_id && row.inviter_reward_granted)
.filter(|row| row.inviter_reward_granted)
.count() as u32;
let bound_relation = ctx
.db
@@ -2918,7 +2919,8 @@ fn count_today_profile_referral_inviter_rewards(
let day_start_micros = runtime_profile_day_start_micros(now.to_micros_since_unix_epoch());
ctx.db
.profile_wallet_ledger()
.iter()
.by_profile_wallet_ledger_user_id()
.filter(user_id)
.filter(|row| {
row.user_id == user_id
&& row.source_type == RuntimeProfileWalletLedgerSourceType::InviteInviterReward
@@ -3422,7 +3424,11 @@ fn query_analytics_metric_buckets(
let stats = ctx
.db
.tracking_daily_stat()
.iter()
.by_tracking_daily_stat_scope_day()
.filter((
validated_input.scope_kind,
validated_input.scope_id.as_str(),
))
.filter(|row| {
row.event_key.trim() == validated_input.event_key
&& row.scope_kind == validated_input.scope_kind
@@ -4023,27 +4029,39 @@ fn apply_profile_wallet_signed_delta(
}
fn has_profile_points_recharged(ctx: &ReducerContext, user_id: &str) -> bool {
ctx.db.profile_recharge_order().iter().any(|row| {
row.user_id == user_id
&& row.kind == RuntimeProfileRechargeProductKind::Points
&& row.status == RuntimeProfileRechargeOrderStatus::Paid
})
ctx.db
.profile_recharge_order()
.by_profile_recharge_order_user_id()
.filter(user_id)
.any(|row| {
row.user_id == user_id
&& row.kind == RuntimeProfileRechargeProductKind::Points
&& row.status == RuntimeProfileRechargeOrderStatus::Paid
})
}
fn has_profile_product_recharged(ctx: &ReducerContext, user_id: &str, product_id: &str) -> bool {
ctx.db.profile_recharge_order().iter().any(|row| {
row.user_id == user_id
&& row.product_id == product_id
&& row.kind == RuntimeProfileRechargeProductKind::Points
&& row.status == RuntimeProfileRechargeOrderStatus::Paid
})
ctx.db
.profile_recharge_order()
.by_profile_recharge_order_user_id()
.filter(user_id)
.any(|row| {
row.user_id == user_id
&& row.product_id == product_id
&& row.kind == RuntimeProfileRechargeProductKind::Points
&& row.status == RuntimeProfileRechargeOrderStatus::Paid
})
}
fn has_profile_business_wallet_ledger(ctx: &ReducerContext, user_id: &str) -> bool {
ctx.db.profile_wallet_ledger().iter().any(|row| {
row.user_id == user_id
&& row.source_type != RuntimeProfileWalletLedgerSourceType::SnapshotSync
})
ctx.db
.profile_wallet_ledger()
.by_profile_wallet_ledger_user_id()
.filter(user_id)
.any(|row| {
row.user_id == user_id
&& row.source_type != RuntimeProfileWalletLedgerSourceType::SnapshotSync
})
}
fn latest_profile_recharge_order(
@@ -4053,8 +4071,8 @@ fn latest_profile_recharge_order(
let mut orders = ctx
.db
.profile_recharge_order()
.iter()
.filter(|row| row.user_id == user_id)
.by_profile_recharge_order_user_id()
.filter(user_id)
.collect::<Vec<_>>();
orders.sort_by(|left, right| {
right