Merge branch 'codex/container-simulate'
# Conflicts: # .hermes/shared-memory/decision-log.md # server-rs/crates/api-server/src/puzzle.rs # server-rs/crates/spacetime-client/src/mapper.rs
This commit is contained in:
@@ -558,6 +558,33 @@ pub fn record_tracking_event_and_return(
|
||||
}
|
||||
}
|
||||
|
||||
// 高频 route tracking 由 api-server 本机 outbox 批量写入,减少公开列表热路径上的 procedure 调用次数。
|
||||
#[spacetimedb::procedure]
|
||||
pub fn record_tracking_events_and_return(
|
||||
ctx: &mut ProcedureContext,
|
||||
inputs: Vec<RuntimeTrackingEventInput>,
|
||||
) -> RuntimeTrackingEventBatchProcedureResult {
|
||||
match ctx.try_with_tx(|tx| {
|
||||
let mut accepted_count = 0u32;
|
||||
for input in &inputs {
|
||||
record_tracking_event(tx, input.clone())?;
|
||||
accepted_count = accepted_count.saturating_add(1);
|
||||
}
|
||||
Ok(accepted_count)
|
||||
}) {
|
||||
Ok(accepted_count) => RuntimeTrackingEventBatchProcedureResult {
|
||||
ok: true,
|
||||
accepted_count,
|
||||
error_message: None,
|
||||
},
|
||||
Err(message) => RuntimeTrackingEventBatchProcedureResult {
|
||||
ok: false,
|
||||
accepted_count: 0,
|
||||
error_message: Some(message),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 登录成功埋点由认证链路主动调用;任务中心只负责读取和刷新任务进度。
|
||||
#[spacetimedb::procedure]
|
||||
pub fn record_daily_login_tracking_event_and_return(
|
||||
@@ -1539,6 +1566,19 @@ mod tests {
|
||||
assert!(!should_skip_existing_tracking_event_id(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tracking_batch_result_reports_accepted_count() {
|
||||
let result = RuntimeTrackingEventBatchProcedureResult {
|
||||
ok: true,
|
||||
accepted_count: 2,
|
||||
error_message: None,
|
||||
};
|
||||
|
||||
assert!(result.ok);
|
||||
assert_eq!(result.accepted_count, 2);
|
||||
assert!(result.error_message.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_public_work_play_counts_group_requested_profiles_in_window() {
|
||||
let now_micros = PUBLIC_WORK_PLAY_DAY_MICROS * 10;
|
||||
|
||||
Reference in New Issue
Block a user