Add skill for gameplay entry type workflows
This commit is contained in:
@@ -217,6 +217,183 @@ pub fn build_runtime_profile_reward_code_redeem_record(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn runtime_profile_beijing_day_key(now_micros: i64) -> i64 {
|
||||
now_micros
|
||||
.saturating_add(PROFILE_TASK_BEIJING_OFFSET_MICROS)
|
||||
.div_euclid(PROFILE_RUNTIME_DAY_MICROS)
|
||||
}
|
||||
|
||||
pub fn build_default_runtime_profile_task_config(
|
||||
updated_at_micros: i64,
|
||||
updated_by: String,
|
||||
) -> RuntimeProfileTaskConfigSnapshot {
|
||||
RuntimeProfileTaskConfigSnapshot {
|
||||
task_id: PROFILE_TASK_ID_DAILY_LOGIN.to_string(),
|
||||
title: PROFILE_TASK_DEFAULT_TITLE_DAILY_LOGIN.to_string(),
|
||||
description: String::new(),
|
||||
event_key: PROFILE_TASK_EVENT_KEY_DAILY_LOGIN.to_string(),
|
||||
cycle: RuntimeProfileTaskCycle::Daily,
|
||||
scope_kind: RuntimeTrackingScopeKind::User,
|
||||
threshold: PROFILE_TASK_DEFAULT_THRESHOLD,
|
||||
reward_points: PROFILE_TASK_DEFAULT_REWARD_POINTS,
|
||||
enabled: true,
|
||||
sort_order: 10,
|
||||
created_by: updated_by.clone(),
|
||||
created_at_micros: updated_at_micros,
|
||||
updated_by,
|
||||
updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_runtime_profile_task_status(
|
||||
enabled: bool,
|
||||
progress_count: u32,
|
||||
threshold: u32,
|
||||
claimed: bool,
|
||||
) -> RuntimeProfileTaskStatus {
|
||||
if !enabled {
|
||||
return RuntimeProfileTaskStatus::Disabled;
|
||||
}
|
||||
if claimed {
|
||||
return RuntimeProfileTaskStatus::Claimed;
|
||||
}
|
||||
if progress_count >= threshold {
|
||||
RuntimeProfileTaskStatus::Claimable
|
||||
} else {
|
||||
RuntimeProfileTaskStatus::Incomplete
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_progress_id(
|
||||
user_id: &str,
|
||||
task_id: &str,
|
||||
day_key: i64,
|
||||
) -> String {
|
||||
format!("{}:{}:{}", user_id.trim(), task_id.trim(), day_key)
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_claim_id(user_id: &str, task_id: &str, day_key: i64) -> String {
|
||||
build_runtime_profile_task_progress_id(user_id, task_id, day_key)
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_reward_ledger_id(
|
||||
user_id: &str,
|
||||
task_id: &str,
|
||||
day_key: i64,
|
||||
) -> String {
|
||||
format!(
|
||||
"task-reward:{}:{}:{}",
|
||||
user_id.trim(),
|
||||
task_id.trim(),
|
||||
day_key
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_runtime_tracking_event_id(
|
||||
event_key: &str,
|
||||
scope_kind: RuntimeTrackingScopeKind,
|
||||
scope_id: &str,
|
||||
occurred_at_micros: i64,
|
||||
) -> String {
|
||||
format!(
|
||||
"tracking:{}:{}:{}:{}",
|
||||
event_key.trim(),
|
||||
scope_kind.as_str(),
|
||||
scope_id.trim(),
|
||||
occurred_at_micros
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_runtime_tracking_daily_stat_id(
|
||||
event_key: &str,
|
||||
scope_kind: RuntimeTrackingScopeKind,
|
||||
scope_id: &str,
|
||||
day_key: i64,
|
||||
) -> String {
|
||||
format!(
|
||||
"tracking-stat:{}:{}:{}:{}",
|
||||
event_key.trim(),
|
||||
scope_kind.as_str(),
|
||||
scope_id.trim(),
|
||||
day_key
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_config_record(
|
||||
snapshot: RuntimeProfileTaskConfigSnapshot,
|
||||
) -> RuntimeProfileTaskConfigRecord {
|
||||
RuntimeProfileTaskConfigRecord {
|
||||
task_id: snapshot.task_id,
|
||||
title: snapshot.title,
|
||||
description: snapshot.description,
|
||||
event_key: snapshot.event_key,
|
||||
cycle: snapshot.cycle,
|
||||
scope_kind: snapshot.scope_kind,
|
||||
threshold: snapshot.threshold,
|
||||
reward_points: snapshot.reward_points,
|
||||
enabled: snapshot.enabled,
|
||||
sort_order: snapshot.sort_order,
|
||||
created_by: snapshot.created_by,
|
||||
created_at: format_utc_micros(snapshot.created_at_micros),
|
||||
created_at_micros: snapshot.created_at_micros,
|
||||
updated_by: snapshot.updated_by,
|
||||
updated_at: format_utc_micros(snapshot.updated_at_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_item_record(
|
||||
snapshot: RuntimeProfileTaskItemSnapshot,
|
||||
) -> RuntimeProfileTaskItemRecord {
|
||||
RuntimeProfileTaskItemRecord {
|
||||
task_id: snapshot.task_id,
|
||||
title: snapshot.title,
|
||||
description: snapshot.description,
|
||||
event_key: snapshot.event_key,
|
||||
cycle: snapshot.cycle,
|
||||
threshold: snapshot.threshold,
|
||||
progress_count: snapshot.progress_count,
|
||||
reward_points: snapshot.reward_points,
|
||||
status: snapshot.status,
|
||||
day_key: snapshot.day_key,
|
||||
claimed_at: snapshot.claimed_at_micros.map(format_utc_micros),
|
||||
claimed_at_micros: snapshot.claimed_at_micros,
|
||||
updated_at: format_utc_micros(snapshot.updated_at_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_center_record(
|
||||
snapshot: RuntimeProfileTaskCenterSnapshot,
|
||||
) -> RuntimeProfileTaskCenterRecord {
|
||||
RuntimeProfileTaskCenterRecord {
|
||||
user_id: snapshot.user_id,
|
||||
day_key: snapshot.day_key,
|
||||
wallet_balance: snapshot.wallet_balance,
|
||||
tasks: snapshot
|
||||
.tasks
|
||||
.into_iter()
|
||||
.map(build_runtime_profile_task_item_record)
|
||||
.collect(),
|
||||
updated_at: format_utc_micros(snapshot.updated_at_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_task_claim_record(
|
||||
snapshot: RuntimeProfileTaskClaimSnapshot,
|
||||
) -> RuntimeProfileTaskClaimRecord {
|
||||
RuntimeProfileTaskClaimRecord {
|
||||
user_id: snapshot.user_id,
|
||||
task_id: snapshot.task_id,
|
||||
day_key: snapshot.day_key,
|
||||
reward_points: snapshot.reward_points,
|
||||
wallet_balance: snapshot.wallet_balance,
|
||||
ledger_entry: build_runtime_profile_wallet_ledger_entry_record(snapshot.ledger_entry),
|
||||
center: build_runtime_profile_task_center_record(snapshot.center),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_runtime_profile_redeem_code_record(
|
||||
snapshot: RuntimeProfileRedeemCodeSnapshot,
|
||||
) -> RuntimeProfileRedeemCodeRecord {
|
||||
|
||||
Reference in New Issue
Block a user