fix: handle visual novel typed SSE events
This commit is contained in:
@@ -1409,6 +1409,12 @@ fn build_public_work_like_id(source_type: &str, profile_id: &str, user_id: &str)
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn duplicate_tracking_event_ids_are_treated_as_idempotent_replays() {
|
||||
assert!(should_skip_existing_tracking_event_id(true));
|
||||
assert!(!should_skip_existing_tracking_event_id(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_public_work_play_counts_group_requested_profiles_in_window() {
|
||||
let now_micros = PUBLIC_WORK_PLAY_DAY_MICROS * 10;
|
||||
@@ -3223,6 +3229,10 @@ fn record_daily_login_tracking_event(ctx: &ReducerContext, user_id: &str) -> Res
|
||||
)
|
||||
}
|
||||
|
||||
fn should_skip_existing_tracking_event_id(event_exists: bool) -> bool {
|
||||
event_exists
|
||||
}
|
||||
|
||||
fn record_tracking_event(
|
||||
ctx: &ReducerContext,
|
||||
input: RuntimeTrackingEventInput,
|
||||
@@ -3242,6 +3252,15 @@ fn record_tracking_event(
|
||||
.map_err(|error| error.to_string())?;
|
||||
let occurred_at = Timestamp::from_micros_since_unix_epoch(validated_input.occurred_at_micros);
|
||||
let day_key = runtime_profile_beijing_day_key(validated_input.occurred_at_micros);
|
||||
if should_skip_existing_tracking_event_id(
|
||||
ctx.db
|
||||
.tracking_event()
|
||||
.event_id()
|
||||
.find(&validated_input.event_id)
|
||||
.is_some(),
|
||||
) {
|
||||
return Ok(());
|
||||
}
|
||||
// 中文注释:埋点事实与日期维表使用同一北京时间业务日桶,先幂等补齐维表,避免后续周/月/季/年聚合缺少 bucket 映射。
|
||||
ensure_analytics_date_dimension_row(ctx, day_key)?;
|
||||
ctx.db.tracking_event().insert(TrackingEvent {
|
||||
|
||||
Reference in New Issue
Block a user