fix: polish bark battle creation flow
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub type BarkBattleDraftCreateRecordInput = BarkBattleDraftCreateInput;
|
||||
pub type BarkBattleDraftConfigUpsertRecordInput = BarkBattleDraftConfigUpsertInput;
|
||||
@@ -44,6 +45,32 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_bark_battle_draft_config(
|
||||
&self,
|
||||
draft_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<BarkBattleDraftConfigRecord, SpacetimeClientError> {
|
||||
self.read_after_connect("get_bark_battle_draft_config", move |connection| {
|
||||
let row = connection
|
||||
.db()
|
||||
.bark_battle_draft_config()
|
||||
.draft_id()
|
||||
.find(&draft_id)
|
||||
.ok_or_else(|| {
|
||||
SpacetimeClientError::procedure_failed(Some(
|
||||
"bark_battle draft 不存在".to_string(),
|
||||
))
|
||||
})?;
|
||||
if row.owner_user_id != owner_user_id {
|
||||
return Err(SpacetimeClientError::procedure_failed(Some(
|
||||
"bark_battle draft owner 不匹配".to_string(),
|
||||
)));
|
||||
}
|
||||
Ok(map_bark_battle_draft_config_row(row))
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn publish_bark_battle_work(
|
||||
&self,
|
||||
input: BarkBattleWorkPublishRecordInput,
|
||||
@@ -142,4 +169,83 @@ impl SpacetimeClient {
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn list_bark_battle_works(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
) -> Result<Vec<serde_json::Value>, SpacetimeClientError> {
|
||||
self.read_after_connect("list_bark_battle_works", move |connection| {
|
||||
let owner_user_id = owner_user_id.as_str();
|
||||
let drafts: Vec<serde_json::Value> = connection
|
||||
.db()
|
||||
.bark_battle_draft_config()
|
||||
.iter()
|
||||
.filter(|row| row.owner_user_id == owner_user_id)
|
||||
.map(map_bark_battle_draft_config_row)
|
||||
.collect();
|
||||
let published: Vec<serde_json::Value> = connection
|
||||
.db()
|
||||
.bark_battle_published_config()
|
||||
.iter()
|
||||
.filter(|row| row.owner_user_id == owner_user_id)
|
||||
.map(map_bark_battle_published_config_row)
|
||||
.collect();
|
||||
|
||||
let mut works_by_id: HashMap<String, serde_json::Value> = HashMap::new();
|
||||
for work in published.into_iter().chain(drafts) {
|
||||
let Some(work_id) = work
|
||||
.get("workId")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.map(ToString::to_string)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
works_by_id.entry(work_id).or_insert(work);
|
||||
}
|
||||
|
||||
let mut works: Vec<serde_json::Value> = works_by_id.into_values().collect();
|
||||
works.sort_by(|left: &serde_json::Value, right: &serde_json::Value| {
|
||||
let left_updated_at = left
|
||||
.get("updatedAtMicros")
|
||||
.and_then(serde_json::Value::as_i64)
|
||||
.unwrap_or_default();
|
||||
let right_updated_at = right
|
||||
.get("updatedAtMicros")
|
||||
.and_then(serde_json::Value::as_i64)
|
||||
.unwrap_or_default();
|
||||
right_updated_at.cmp(&left_updated_at)
|
||||
});
|
||||
Ok(works)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn list_bark_battle_gallery(
|
||||
&self,
|
||||
) -> Result<Vec<serde_json::Value>, SpacetimeClientError> {
|
||||
self.read_after_connect("list_bark_battle_gallery", move |connection| {
|
||||
let recent_play_counts = public_work_recent_play_counts(connection, "bark-battle");
|
||||
let mut items = connection
|
||||
.db()
|
||||
.bark_battle_gallery_view()
|
||||
.iter()
|
||||
.collect::<Vec<_>>();
|
||||
items.sort_by(|left, right| {
|
||||
right
|
||||
.updated_at_micros
|
||||
.cmp(&left.updated_at_micros)
|
||||
.then_with(|| left.work_id.cmp(&right.work_id))
|
||||
});
|
||||
Ok(items
|
||||
.into_iter()
|
||||
.map(|item| {
|
||||
let recent_play_count_7d =
|
||||
recent_play_counts.get(&item.work_id).copied().unwrap_or(0);
|
||||
map_bark_battle_gallery_view_row(item, recent_play_count_7d)
|
||||
})
|
||||
.collect())
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,6 +550,7 @@ impl SpacetimeClient {
|
||||
) -> Result<Vec<SubscriptionHandle>, SpacetimeClientError> {
|
||||
let mut subscriptions = Vec::new();
|
||||
for query in [
|
||||
"SELECT * FROM bark_battle_gallery_view",
|
||||
"SELECT * FROM puzzle_gallery_card_view",
|
||||
"SELECT * FROM custom_world_gallery_entry",
|
||||
"SELECT * FROM match_3_d_gallery_view",
|
||||
@@ -570,6 +571,7 @@ impl SpacetimeClient {
|
||||
"SELECT * FROM public_work_play_daily_stat WHERE source_type = 'square-hole'",
|
||||
"SELECT * FROM public_work_play_daily_stat WHERE source_type = 'visual-novel'",
|
||||
"SELECT * FROM public_work_play_daily_stat WHERE source_type = 'big-fish'",
|
||||
"SELECT * FROM public_work_play_daily_stat WHERE source_type = 'bark-battle'",
|
||||
"SELECT * FROM creation_entry_config",
|
||||
"SELECT * FROM creation_entry_type_config",
|
||||
] {
|
||||
|
||||
@@ -112,8 +112,9 @@ pub(crate) use self::auth::{
|
||||
map_auth_store_snapshot_import_procedure_result, map_auth_store_snapshot_procedure_result,
|
||||
};
|
||||
pub(crate) use self::bark_battle::{
|
||||
map_bark_battle_draft_config_procedure_result, map_bark_battle_run_procedure_result,
|
||||
map_bark_battle_runtime_config_procedure_result,
|
||||
map_bark_battle_draft_config_procedure_result, map_bark_battle_draft_config_row,
|
||||
map_bark_battle_gallery_view_row, map_bark_battle_published_config_row,
|
||||
map_bark_battle_run_procedure_result, map_bark_battle_runtime_config_procedure_result,
|
||||
};
|
||||
pub(crate) use self::big_fish::{
|
||||
map_big_fish_gallery_view_row, map_big_fish_run_procedure_result,
|
||||
|
||||
@@ -36,6 +36,70 @@ pub(crate) fn map_bark_battle_run_procedure_result(
|
||||
.map(bark_battle_run_to_value)
|
||||
}
|
||||
|
||||
pub(crate) fn map_bark_battle_draft_config_row(
|
||||
row: BarkBattleDraftConfigRow,
|
||||
) -> BarkBattleDraftConfigRecord {
|
||||
serde_json::json!({
|
||||
"draftId": row.draft_id,
|
||||
"ownerUserId": row.owner_user_id,
|
||||
"workId": row.work_id,
|
||||
"configVersion": row.config_version,
|
||||
"rulesetVersion": row.ruleset_version,
|
||||
"difficultyPreset": row.difficulty_preset,
|
||||
"configJson": row.config_json,
|
||||
"editorStateJson": row.editor_state_json,
|
||||
"createdAtMicros": row.created_at.to_micros_since_unix_epoch(),
|
||||
"updatedAtMicros": row.updated_at.to_micros_since_unix_epoch(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn map_bark_battle_published_config_row(
|
||||
row: BarkBattlePublishedConfigRow,
|
||||
) -> BarkBattleRuntimeConfigRecord {
|
||||
serde_json::json!({
|
||||
"workId": row.work_id,
|
||||
"ownerUserId": row.owner_user_id,
|
||||
"sourceDraftId": row.source_draft_id,
|
||||
"configVersion": row.config_version,
|
||||
"rulesetVersion": row.ruleset_version,
|
||||
"difficultyPreset": row.difficulty_preset,
|
||||
"configJson": row.config_json,
|
||||
"publishedSnapshotJson": row.published_snapshot_json,
|
||||
"publishedAtMicros": row.published_at.to_micros_since_unix_epoch(),
|
||||
"updatedAtMicros": row.updated_at.to_micros_since_unix_epoch(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn map_bark_battle_gallery_view_row(
|
||||
row: BarkBattleGalleryViewRow,
|
||||
recent_play_count_7d: u32,
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"workId": row.work_id,
|
||||
"ownerUserId": row.owner_user_id,
|
||||
"sourceDraftId": row.source_draft_id,
|
||||
"configVersion": row.config_version,
|
||||
"rulesetVersion": row.ruleset_version,
|
||||
"difficultyPreset": row.difficulty_preset,
|
||||
"title": row.title,
|
||||
"description": row.description,
|
||||
"themeDescription": row.theme_description,
|
||||
"playerImageDescription": row.player_image_description,
|
||||
"opponentImageDescription": row.opponent_image_description,
|
||||
"onomatopoeia": row.onomatopoeia,
|
||||
"playerCharacterImageSrc": row.player_character_image_src,
|
||||
"opponentCharacterImageSrc": row.opponent_character_image_src,
|
||||
"uiBackgroundImageSrc": row.ui_background_image_src,
|
||||
"status": "published",
|
||||
"publishReady": true,
|
||||
"playCount": row.play_count,
|
||||
"finishCount": row.finish_count,
|
||||
"recentPlayCount7d": recent_play_count_7d,
|
||||
"updatedAtMicros": row.updated_at_micros,
|
||||
"publishedAtMicros": row.published_at_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn bark_battle_draft_config_to_value(snapshot: BarkBattleDraftConfigSnapshot) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"draftId": snapshot.draft_id,
|
||||
@@ -44,7 +108,6 @@ fn bark_battle_draft_config_to_value(snapshot: BarkBattleDraftConfigSnapshot) ->
|
||||
"configVersion": snapshot.config_version,
|
||||
"rulesetVersion": snapshot.ruleset_version,
|
||||
"difficultyPreset": snapshot.difficulty_preset,
|
||||
"leaderboardEnabled": snapshot.leaderboard_enabled,
|
||||
"configJson": snapshot.config_json,
|
||||
"editorStateJson": snapshot.editor_state_json,
|
||||
"createdAtMicros": snapshot.created_at_micros,
|
||||
@@ -62,7 +125,6 @@ fn bark_battle_runtime_config_to_value(
|
||||
"configVersion": snapshot.config_version,
|
||||
"rulesetVersion": snapshot.ruleset_version,
|
||||
"difficultyPreset": snapshot.difficulty_preset,
|
||||
"leaderboardEnabled": snapshot.leaderboard_enabled,
|
||||
"configJson": snapshot.config_json,
|
||||
"publishedSnapshotJson": snapshot.published_snapshot_json,
|
||||
"publishedAtMicros": snapshot.published_at_micros,
|
||||
@@ -78,7 +140,6 @@ fn bark_battle_run_to_value(snapshot: BarkBattleRunSnapshot) -> serde_json::Valu
|
||||
"configVersion": snapshot.config_version,
|
||||
"rulesetVersion": snapshot.ruleset_version,
|
||||
"difficultyPreset": snapshot.difficulty_preset,
|
||||
"leaderboardEnabled": snapshot.leaderboard_enabled,
|
||||
"status": snapshot.status,
|
||||
"clientStartedAtMicros": snapshot.client_started_at_micros,
|
||||
"serverStartedAtMicros": snapshot.server_started_at_micros,
|
||||
@@ -92,3 +153,38 @@ fn bark_battle_run_to_value(snapshot: BarkBattleRunSnapshot) -> serde_json::Valu
|
||||
"scoreId": snapshot.score_id,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bark_battle_gallery_mapper_keeps_custom_onomatopoeia() {
|
||||
let row = BarkBattleGalleryViewRow {
|
||||
work_id: "BB-33333333".to_string(),
|
||||
owner_user_id: "user-3".to_string(),
|
||||
source_draft_id: Some("bark-battle-draft-3".to_string()),
|
||||
config_version: 1,
|
||||
ruleset_version: "bark-battle-ruleset-v1".to_string(),
|
||||
difficulty_preset: "normal".to_string(),
|
||||
title: "声浪公开赛".to_string(),
|
||||
description: "画廊映射测试".to_string(),
|
||||
theme_description: "霓虹竞技场".to_string(),
|
||||
player_image_description: "星际猫骑士".to_string(),
|
||||
opponent_image_description: "机器人拳手".to_string(),
|
||||
onomatopoeia: vec!["轰!".to_string(), "炸场!".to_string()],
|
||||
player_character_image_src: Some("/assets/player.png".to_string()),
|
||||
opponent_character_image_src: Some("/assets/opponent.png".to_string()),
|
||||
ui_background_image_src: Some("/assets/background.png".to_string()),
|
||||
play_count: 8,
|
||||
finish_count: 5,
|
||||
updated_at_micros: 1_713_686_401_234_567,
|
||||
published_at_micros: 1_713_686_401_234_000,
|
||||
};
|
||||
|
||||
let value = map_bark_battle_gallery_view_row(row, 3);
|
||||
|
||||
assert_eq!(value["onomatopoeia"], serde_json::json!(["轰!", "炸场!"]));
|
||||
assert_eq!(value["recentPlayCount7d"], serde_json::json!(3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ pub mod bark_battle_draft_config_snapshot_type;
|
||||
pub mod bark_battle_draft_config_table;
|
||||
pub mod bark_battle_draft_config_upsert_input_type;
|
||||
pub mod bark_battle_draft_create_input_type;
|
||||
pub mod bark_battle_gallery_view_row_type;
|
||||
pub mod bark_battle_gallery_view_table;
|
||||
pub mod bark_battle_leaderboard_entry_row_type;
|
||||
pub mod bark_battle_leaderboard_entry_table;
|
||||
pub mod bark_battle_personal_best_projection_row_type;
|
||||
@@ -1025,6 +1027,8 @@ pub use bark_battle_draft_config_snapshot_type::BarkBattleDraftConfigSnapshot;
|
||||
pub use bark_battle_draft_config_table::*;
|
||||
pub use bark_battle_draft_config_upsert_input_type::BarkBattleDraftConfigUpsertInput;
|
||||
pub use bark_battle_draft_create_input_type::BarkBattleDraftCreateInput;
|
||||
pub use bark_battle_gallery_view_row_type::BarkBattleGalleryViewRow;
|
||||
pub use bark_battle_gallery_view_table::*;
|
||||
pub use bark_battle_leaderboard_entry_row_type::BarkBattleLeaderboardEntryRow;
|
||||
pub use bark_battle_leaderboard_entry_table::*;
|
||||
pub use bark_battle_personal_best_projection_row_type::BarkBattlePersonalBestProjectionRow;
|
||||
@@ -2143,6 +2147,7 @@ pub struct DbUpdate {
|
||||
auth_store_projection_meta: __sdk::TableUpdate<AuthStoreProjectionMeta>,
|
||||
auth_store_snapshot: __sdk::TableUpdate<AuthStoreSnapshot>,
|
||||
bark_battle_draft_config: __sdk::TableUpdate<BarkBattleDraftConfigRow>,
|
||||
bark_battle_gallery_view: __sdk::TableUpdate<BarkBattleGalleryViewRow>,
|
||||
bark_battle_leaderboard_entry: __sdk::TableUpdate<BarkBattleLeaderboardEntryRow>,
|
||||
bark_battle_personal_best_projection: __sdk::TableUpdate<BarkBattlePersonalBestProjectionRow>,
|
||||
bark_battle_published_config: __sdk::TableUpdate<BarkBattlePublishedConfigRow>,
|
||||
@@ -2272,6 +2277,9 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
|
||||
"bark_battle_draft_config" => db_update.bark_battle_draft_config.append(
|
||||
bark_battle_draft_config_table::parse_table_update(table_update)?,
|
||||
),
|
||||
"bark_battle_gallery_view" => db_update.bark_battle_gallery_view.append(
|
||||
bark_battle_gallery_view_table::parse_table_update(table_update)?,
|
||||
),
|
||||
"bark_battle_leaderboard_entry" => db_update.bark_battle_leaderboard_entry.append(
|
||||
bark_battle_leaderboard_entry_table::parse_table_update(table_update)?,
|
||||
),
|
||||
@@ -3008,6 +3016,10 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
&self.visual_novel_work_profile,
|
||||
)
|
||||
.with_updates_by_pk(|row| &row.profile_id);
|
||||
diff.bark_battle_gallery_view = cache.apply_diff_to_table::<BarkBattleGalleryViewRow>(
|
||||
"bark_battle_gallery_view",
|
||||
&self.bark_battle_gallery_view,
|
||||
);
|
||||
diff.big_fish_gallery_view = cache.apply_diff_to_table::<BigFishWorkSummarySnapshot>(
|
||||
"big_fish_gallery_view",
|
||||
&self.big_fish_gallery_view,
|
||||
@@ -3078,6 +3090,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
"bark_battle_draft_config" => db_update
|
||||
.bark_battle_draft_config
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"bark_battle_gallery_view" => db_update
|
||||
.bark_battle_gallery_view
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"bark_battle_leaderboard_entry" => db_update
|
||||
.bark_battle_leaderboard_entry
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
@@ -3376,6 +3391,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
||||
"bark_battle_draft_config" => db_update
|
||||
.bark_battle_draft_config
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"bark_battle_gallery_view" => db_update
|
||||
.bark_battle_gallery_view
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"bark_battle_leaderboard_entry" => db_update
|
||||
.bark_battle_leaderboard_entry
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
@@ -3650,6 +3668,7 @@ pub struct AppliedDiff<'r> {
|
||||
auth_store_projection_meta: __sdk::TableAppliedDiff<'r, AuthStoreProjectionMeta>,
|
||||
auth_store_snapshot: __sdk::TableAppliedDiff<'r, AuthStoreSnapshot>,
|
||||
bark_battle_draft_config: __sdk::TableAppliedDiff<'r, BarkBattleDraftConfigRow>,
|
||||
bark_battle_gallery_view: __sdk::TableAppliedDiff<'r, BarkBattleGalleryViewRow>,
|
||||
bark_battle_leaderboard_entry: __sdk::TableAppliedDiff<'r, BarkBattleLeaderboardEntryRow>,
|
||||
bark_battle_personal_best_projection:
|
||||
__sdk::TableAppliedDiff<'r, BarkBattlePersonalBestProjectionRow>,
|
||||
@@ -3805,6 +3824,11 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
||||
&self.bark_battle_draft_config,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<BarkBattleGalleryViewRow>(
|
||||
"bark_battle_gallery_view",
|
||||
&self.bark_battle_gallery_view,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<BarkBattleLeaderboardEntryRow>(
|
||||
"bark_battle_leaderboard_entry",
|
||||
&self.bark_battle_leaderboard_entry,
|
||||
@@ -4876,6 +4900,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
||||
auth_store_projection_meta_table::register_table(client_cache);
|
||||
auth_store_snapshot_table::register_table(client_cache);
|
||||
bark_battle_draft_config_table::register_table(client_cache);
|
||||
bark_battle_gallery_view_table::register_table(client_cache);
|
||||
bark_battle_leaderboard_entry_table::register_table(client_cache);
|
||||
bark_battle_personal_best_projection_table::register_table(client_cache);
|
||||
bark_battle_published_config_table::register_table(client_cache);
|
||||
@@ -4973,6 +4998,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
||||
"auth_store_projection_meta",
|
||||
"auth_store_snapshot",
|
||||
"bark_battle_draft_config",
|
||||
"bark_battle_gallery_view",
|
||||
"bark_battle_leaderboard_entry",
|
||||
"bark_battle_personal_best_projection",
|
||||
"bark_battle_published_config",
|
||||
|
||||
@@ -13,7 +13,6 @@ pub struct BarkBattleDraftConfigSnapshot {
|
||||
pub config_version: u64,
|
||||
pub ruleset_version: String,
|
||||
pub difficulty_preset: String,
|
||||
pub leaderboard_enabled: bool,
|
||||
pub config_json: String,
|
||||
pub editor_state_json: String,
|
||||
pub created_at_micros: i64,
|
||||
|
||||
@@ -13,7 +13,6 @@ pub struct BarkBattleDraftConfigUpsertInput {
|
||||
pub config_version: u64,
|
||||
pub ruleset_version: String,
|
||||
pub difficulty_preset: String,
|
||||
pub leaderboard_enabled: bool,
|
||||
pub config_json: String,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ pub struct BarkBattleDraftCreateInput {
|
||||
pub work_id: String,
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub theme_preset: String,
|
||||
pub player_dog_skin_preset: String,
|
||||
pub opponent_dog_skin_preset: String,
|
||||
pub theme_description: String,
|
||||
pub player_image_description: String,
|
||||
pub opponent_image_description: String,
|
||||
pub difficulty_preset: Option<String>,
|
||||
pub leaderboard_enabled: Option<bool>,
|
||||
pub editor_state_json: Option<String>,
|
||||
pub created_at_micros: i64,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct BarkBattleGalleryViewRow {
|
||||
pub work_id: String,
|
||||
pub owner_user_id: String,
|
||||
pub source_draft_id: Option<String>,
|
||||
pub config_version: u64,
|
||||
pub ruleset_version: String,
|
||||
pub difficulty_preset: String,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub theme_description: String,
|
||||
pub player_image_description: String,
|
||||
pub opponent_image_description: String,
|
||||
pub onomatopoeia: Vec<String>,
|
||||
pub player_character_image_src: Option<String>,
|
||||
pub opponent_character_image_src: Option<String>,
|
||||
pub ui_background_image_src: Option<String>,
|
||||
pub play_count: u64,
|
||||
pub finish_count: u64,
|
||||
pub updated_at_micros: i64,
|
||||
pub published_at_micros: i64,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for BarkBattleGalleryViewRow {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
/// Column accessor struct for the table `BarkBattleGalleryViewRow`.
|
||||
///
|
||||
/// Provides typed access to columns for query building.
|
||||
pub struct BarkBattleGalleryViewRowCols {
|
||||
pub work_id: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub owner_user_id: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub source_draft_id: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, Option<String>>,
|
||||
pub config_version: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, u64>,
|
||||
pub ruleset_version: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub difficulty_preset: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub title: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub description: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub theme_description: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub player_image_description: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub opponent_image_description: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, String>,
|
||||
pub onomatopoeia: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, Vec<String>>,
|
||||
pub player_character_image_src:
|
||||
__sdk::__query_builder::Col<BarkBattleGalleryViewRow, Option<String>>,
|
||||
pub opponent_character_image_src:
|
||||
__sdk::__query_builder::Col<BarkBattleGalleryViewRow, Option<String>>,
|
||||
pub ui_background_image_src:
|
||||
__sdk::__query_builder::Col<BarkBattleGalleryViewRow, Option<String>>,
|
||||
pub play_count: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, u64>,
|
||||
pub finish_count: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, u64>,
|
||||
pub updated_at_micros: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, i64>,
|
||||
pub published_at_micros: __sdk::__query_builder::Col<BarkBattleGalleryViewRow, i64>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasCols for BarkBattleGalleryViewRow {
|
||||
type Cols = BarkBattleGalleryViewRowCols;
|
||||
fn cols(table_name: &'static str) -> Self::Cols {
|
||||
BarkBattleGalleryViewRowCols {
|
||||
work_id: __sdk::__query_builder::Col::new(table_name, "work_id"),
|
||||
owner_user_id: __sdk::__query_builder::Col::new(table_name, "owner_user_id"),
|
||||
source_draft_id: __sdk::__query_builder::Col::new(table_name, "source_draft_id"),
|
||||
config_version: __sdk::__query_builder::Col::new(table_name, "config_version"),
|
||||
ruleset_version: __sdk::__query_builder::Col::new(table_name, "ruleset_version"),
|
||||
difficulty_preset: __sdk::__query_builder::Col::new(table_name, "difficulty_preset"),
|
||||
title: __sdk::__query_builder::Col::new(table_name, "title"),
|
||||
description: __sdk::__query_builder::Col::new(table_name, "description"),
|
||||
theme_description: __sdk::__query_builder::Col::new(table_name, "theme_description"),
|
||||
player_image_description: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"player_image_description",
|
||||
),
|
||||
opponent_image_description: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"opponent_image_description",
|
||||
),
|
||||
onomatopoeia: __sdk::__query_builder::Col::new(table_name, "onomatopoeia"),
|
||||
player_character_image_src: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"player_character_image_src",
|
||||
),
|
||||
opponent_character_image_src: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"opponent_character_image_src",
|
||||
),
|
||||
ui_background_image_src: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"ui_background_image_src",
|
||||
),
|
||||
play_count: __sdk::__query_builder::Col::new(table_name, "play_count"),
|
||||
finish_count: __sdk::__query_builder::Col::new(table_name, "finish_count"),
|
||||
updated_at_micros: __sdk::__query_builder::Col::new(table_name, "updated_at_micros"),
|
||||
published_at_micros: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"published_at_micros",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::bark_battle_gallery_view_row_type::BarkBattleGalleryViewRow;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `bark_battle_gallery_view`.
|
||||
///
|
||||
/// Obtain a handle from the [`BarkBattleGalleryViewTableAccess::bark_battle_gallery_view`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.bark_battle_gallery_view()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.bark_battle_gallery_view().on_insert(...)`.
|
||||
pub struct BarkBattleGalleryViewTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BarkBattleGalleryViewRow>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `bark_battle_gallery_view`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BarkBattleGalleryViewTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BarkBattleGalleryViewTableHandle`], which mediates access to the table `bark_battle_gallery_view`.
|
||||
fn bark_battle_gallery_view(&self) -> BarkBattleGalleryViewTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BarkBattleGalleryViewTableAccess for super::RemoteTables {
|
||||
fn bark_battle_gallery_view(&self) -> BarkBattleGalleryViewTableHandle<'_> {
|
||||
BarkBattleGalleryViewTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<BarkBattleGalleryViewRow>("bark_battle_gallery_view"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BarkBattleGalleryViewInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BarkBattleGalleryViewDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BarkBattleGalleryViewTableHandle<'ctx> {
|
||||
type Row = BarkBattleGalleryViewRow;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BarkBattleGalleryViewRow> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BarkBattleGalleryViewInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BarkBattleGalleryViewInsertCallbackId {
|
||||
BarkBattleGalleryViewInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BarkBattleGalleryViewInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BarkBattleGalleryViewDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BarkBattleGalleryViewDeleteCallbackId {
|
||||
BarkBattleGalleryViewDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BarkBattleGalleryViewDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<BarkBattleGalleryViewRow>("bark_battle_gallery_view");
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BarkBattleGalleryViewRow>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BarkBattleGalleryViewRow>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BarkBattleGalleryViewRow`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait bark_battle_gallery_viewQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BarkBattleGalleryViewRow`.
|
||||
fn bark_battle_gallery_view(&self) -> __sdk::__query_builder::Table<BarkBattleGalleryViewRow>;
|
||||
}
|
||||
|
||||
impl bark_battle_gallery_viewQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn bark_battle_gallery_view(&self) -> __sdk::__query_builder::Table<BarkBattleGalleryViewRow> {
|
||||
__sdk::__query_builder::Table::new("bark_battle_gallery_view")
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ pub struct BarkBattleRunSnapshot {
|
||||
pub config_version: u64,
|
||||
pub ruleset_version: String,
|
||||
pub difficulty_preset: String,
|
||||
pub leaderboard_enabled: bool,
|
||||
pub status: String,
|
||||
pub client_started_at_micros: i64,
|
||||
pub server_started_at_micros: i64,
|
||||
|
||||
@@ -13,7 +13,6 @@ pub struct BarkBattleRuntimeConfigSnapshot {
|
||||
pub config_version: u64,
|
||||
pub ruleset_version: String,
|
||||
pub difficulty_preset: String,
|
||||
pub leaderboard_enabled: bool,
|
||||
pub config_json: String,
|
||||
pub published_snapshot_json: String,
|
||||
pub published_at_micros: i64,
|
||||
|
||||
@@ -81,7 +81,9 @@ fn spacetime_metrics() -> &'static SpacetimeMetrics {
|
||||
read_duration_ms: meter
|
||||
.f64_histogram("genarrative.spacetime.read.duration_ms")
|
||||
.with_unit("ms")
|
||||
.with_description("SpacetimeDB local subscription cache read duration in milliseconds")
|
||||
.with_description(
|
||||
"SpacetimeDB local subscription cache read duration in milliseconds",
|
||||
)
|
||||
.build(),
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user