1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::big_fish::tables::{big_fish_agent_message, big_fish_creation_session};
|
||||
use crate::runtime::{
|
||||
ProfilePlayedWorkUpsertInput, add_profile_observed_play_time, upsert_profile_played_work,
|
||||
ProfilePlayedWorkUpsertInput, PublicWorkPlayRecordInput, add_profile_observed_play_time,
|
||||
count_recent_public_work_plays, record_public_work_play, upsert_profile_played_work,
|
||||
};
|
||||
use crate::*;
|
||||
|
||||
@@ -288,6 +289,7 @@ pub(crate) fn list_big_fish_works_tx(
|
||||
input: BigFishWorksListInput,
|
||||
) -> Result<Vec<BigFishWorkSummarySnapshot>, String> {
|
||||
validate_works_list_input(&input).map_err(|error| error.to_string())?;
|
||||
let now_micros = ctx.timestamp.to_micros_since_unix_epoch();
|
||||
|
||||
let mut items = ctx
|
||||
.db
|
||||
@@ -300,7 +302,7 @@ pub(crate) fn list_big_fish_works_tx(
|
||||
|
||||
row.owner_user_id == input.owner_user_id && should_include_big_fish_work(ctx, row)
|
||||
})
|
||||
.map(|row| build_big_fish_work_summary(ctx, &row))
|
||||
.map(|row| build_big_fish_work_summary(ctx, &row, now_micros))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
items.sort_by(|left, right| {
|
||||
@@ -676,6 +678,15 @@ pub(crate) fn record_big_fish_play_tx(
|
||||
input.elapsed_ms,
|
||||
input.played_at_micros,
|
||||
)?;
|
||||
record_public_work_play(
|
||||
ctx,
|
||||
PublicWorkPlayRecordInput {
|
||||
source_type: "big-fish".to_string(),
|
||||
owner_user_id: session.owner_user_id.clone(),
|
||||
profile_id: session.session_id.clone(),
|
||||
played_at_micros: input.played_at_micros,
|
||||
},
|
||||
)?;
|
||||
let next_session = BigFishCreationSession {
|
||||
session_id: session.session_id.clone(),
|
||||
owner_user_id: session.owner_user_id.clone(),
|
||||
@@ -698,13 +709,7 @@ pub(crate) fn record_big_fish_play_tx(
|
||||
};
|
||||
replace_big_fish_session(ctx, &session, next_session);
|
||||
|
||||
list_big_fish_works_tx(
|
||||
ctx,
|
||||
BigFishWorksListInput {
|
||||
owner_user_id: String::new(),
|
||||
published_only: true,
|
||||
},
|
||||
)
|
||||
list_big_fish_works_tx(ctx, build_public_big_fish_gallery_list_input())
|
||||
}
|
||||
|
||||
fn remix_big_fish_work_tx(
|
||||
@@ -876,6 +881,7 @@ pub(crate) fn build_big_fish_session_snapshot(
|
||||
pub(crate) fn build_big_fish_work_summary(
|
||||
ctx: &ReducerContext,
|
||||
row: &BigFishCreationSession,
|
||||
now_micros: i64,
|
||||
) -> Result<BigFishWorkSummarySnapshot, String> {
|
||||
let draft = row
|
||||
.draft_json
|
||||
@@ -940,6 +946,12 @@ pub(crate) fn build_big_fish_work_summary(
|
||||
play_count: row.play_count,
|
||||
remix_count: row.remix_count,
|
||||
like_count: row.like_count,
|
||||
recent_play_count_7d: count_recent_public_work_plays(
|
||||
ctx,
|
||||
"big-fish",
|
||||
&row.session_id,
|
||||
now_micros,
|
||||
),
|
||||
published_at_micros: row
|
||||
.published_at
|
||||
.or_else(|| (row.stage == BigFishCreationStage::Published).then_some(row.updated_at))
|
||||
@@ -947,6 +959,14 @@ pub(crate) fn build_big_fish_work_summary(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_public_big_fish_gallery_list_input() -> BigFishWorksListInput {
|
||||
BigFishWorksListInput {
|
||||
// 中文注释:published_only 分支不会按 owner 过滤;非空占位用于兼容旧部署模块的前置校验。
|
||||
owner_user_id: PUBLIC_BIG_FISH_GALLERY_OWNER_USER_ID.to_string(),
|
||||
published_only: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn replace_big_fish_session(
|
||||
ctx: &ReducerContext,
|
||||
current: &BigFishCreationSession,
|
||||
|
||||
Reference in New Issue
Block a user