Add public work read model and smooth puzzle transitions
This commit is contained in:
115
server-rs/crates/spacetime-client/src/mapper/public_work.rs
Normal file
115
server-rs/crates/spacetime-client/src/mapper/public_work.rs
Normal file
@@ -0,0 +1,115 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct PublicWorkGalleryEntryRecord {
|
||||
pub source_type: String,
|
||||
pub work_id: String,
|
||||
pub profile_id: String,
|
||||
pub source_session_id: Option<String>,
|
||||
pub public_work_code: String,
|
||||
pub owner_user_id: String,
|
||||
pub author_display_name: String,
|
||||
pub world_name: String,
|
||||
pub subtitle: String,
|
||||
pub summary_text: String,
|
||||
pub cover_image_src: Option<String>,
|
||||
pub cover_asset_id: Option<String>,
|
||||
pub theme_tags: Vec<String>,
|
||||
pub play_count: u32,
|
||||
pub remix_count: u32,
|
||||
pub like_count: u32,
|
||||
pub recent_play_count_7d: u32,
|
||||
pub published_at: Option<String>,
|
||||
pub updated_at: String,
|
||||
pub sort_time_micros: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct PublicWorkDetailEntryRecord {
|
||||
pub entry: PublicWorkGalleryEntryRecord,
|
||||
pub detail_payload_json: String,
|
||||
}
|
||||
|
||||
pub(crate) fn map_public_work_gallery_entry(
|
||||
snapshot: PublicWorkGalleryEntry,
|
||||
recent_play_count_7d: u32,
|
||||
) -> PublicWorkGalleryEntryRecord {
|
||||
PublicWorkGalleryEntryRecord {
|
||||
source_type: snapshot.source_type,
|
||||
work_id: snapshot.work_id,
|
||||
profile_id: snapshot.profile_id,
|
||||
source_session_id: snapshot.source_session_id,
|
||||
public_work_code: snapshot.public_work_code,
|
||||
owner_user_id: snapshot.owner_user_id,
|
||||
author_display_name: snapshot.author_display_name,
|
||||
world_name: snapshot.world_name,
|
||||
subtitle: snapshot.subtitle,
|
||||
summary_text: snapshot.summary_text,
|
||||
cover_image_src: snapshot.cover_image_src,
|
||||
cover_asset_id: snapshot.cover_asset_id,
|
||||
theme_tags: snapshot.theme_tags,
|
||||
play_count: snapshot.play_count,
|
||||
remix_count: snapshot.remix_count,
|
||||
like_count: snapshot.like_count,
|
||||
recent_play_count_7d,
|
||||
published_at: snapshot.published_at_micros.map(format_timestamp_micros),
|
||||
updated_at: format_timestamp_micros(snapshot.updated_at_micros),
|
||||
sort_time_micros: snapshot.sort_time_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn map_public_work_gallery_entry_to_detail_entry(
|
||||
snapshot: PublicWorkDetailEntry,
|
||||
recent_play_count_7d: u32,
|
||||
) -> PublicWorkDetailEntryRecord {
|
||||
let PublicWorkDetailEntry {
|
||||
source_type,
|
||||
work_id,
|
||||
profile_id,
|
||||
source_session_id,
|
||||
public_work_code,
|
||||
owner_user_id,
|
||||
author_display_name,
|
||||
world_name,
|
||||
subtitle,
|
||||
summary_text,
|
||||
cover_image_src,
|
||||
cover_asset_id,
|
||||
theme_tags,
|
||||
play_count,
|
||||
remix_count,
|
||||
like_count,
|
||||
published_at_micros,
|
||||
updated_at_micros,
|
||||
sort_time_micros,
|
||||
detail_payload_json,
|
||||
} = snapshot;
|
||||
|
||||
PublicWorkDetailEntryRecord {
|
||||
entry: map_public_work_gallery_entry(
|
||||
PublicWorkGalleryEntry {
|
||||
source_type,
|
||||
work_id,
|
||||
profile_id,
|
||||
source_session_id,
|
||||
public_work_code,
|
||||
owner_user_id,
|
||||
author_display_name,
|
||||
world_name,
|
||||
subtitle,
|
||||
summary_text,
|
||||
cover_image_src,
|
||||
cover_asset_id,
|
||||
theme_tags,
|
||||
play_count,
|
||||
remix_count,
|
||||
like_count,
|
||||
published_at_micros,
|
||||
updated_at_micros,
|
||||
sort_time_micros,
|
||||
},
|
||||
recent_play_count_7d,
|
||||
),
|
||||
detail_payload_json,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user