1
This commit is contained in:
@@ -511,7 +511,13 @@ pub(crate) fn compile_big_fish_draft_tx(
|
||||
.ok_or_else(|| "big_fish_creation_session 不存在".to_string())?;
|
||||
let anchor_pack =
|
||||
deserialize_anchor_pack(&session.anchor_pack_json).map_err(|error| error.to_string())?;
|
||||
let draft = compile_default_draft(&anchor_pack);
|
||||
let draft = input
|
||||
.draft_json
|
||||
.as_deref()
|
||||
.map(deserialize_draft)
|
||||
.transpose()
|
||||
.map_err(|error| format!("big_fish.draft_json 非法: {error}"))?
|
||||
.unwrap_or_else(|| compile_default_draft(&anchor_pack));
|
||||
let asset_slots = list_big_fish_asset_slots(ctx, &session.session_id);
|
||||
let coverage = build_asset_coverage(Some(&draft), &asset_slots);
|
||||
let compiled_at = Timestamp::from_micros_since_unix_epoch(input.compiled_at_micros);
|
||||
|
||||
@@ -2189,7 +2189,7 @@ fn execute_sync_result_profile_action(
|
||||
input: &CustomWorldAgentActionExecuteInput,
|
||||
payload: &JsonMap<String, JsonValue>,
|
||||
) -> Result<CustomWorldAgentOperationSnapshot, String> {
|
||||
ensure_refining_stage(session.stage, "sync_result_profile")?;
|
||||
ensure_result_profile_sync_stage(session.stage, "sync_result_profile")?;
|
||||
let mut profile = payload
|
||||
.get("profile")
|
||||
.and_then(JsonValue::as_object)
|
||||
@@ -3692,6 +3692,22 @@ fn ensure_refining_stage(stage: RpgAgentStage, action: &str) -> Result<(), Strin
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_result_profile_sync_stage(stage: RpgAgentStage, action: &str) -> Result<(), String> {
|
||||
if matches!(
|
||||
stage,
|
||||
RpgAgentStage::ObjectRefining
|
||||
| RpgAgentStage::VisualRefining
|
||||
| RpgAgentStage::LongTailReview
|
||||
| RpgAgentStage::ReadyToPublish
|
||||
) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!(
|
||||
"{action} is only available during object_refining, visual_refining, long_tail_review or ready_to_publish"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_long_tail_stage(stage: RpgAgentStage, action: &str) -> Result<(), String> {
|
||||
if matches!(
|
||||
stage,
|
||||
|
||||
@@ -3405,7 +3405,7 @@ fn execute_sync_result_profile_action(
|
||||
input: &CustomWorldAgentActionExecuteInput,
|
||||
payload: &JsonMap<String, JsonValue>,
|
||||
) -> Result<CustomWorldAgentOperationSnapshot, String> {
|
||||
ensure_refining_stage(session.stage, "sync_result_profile")?;
|
||||
ensure_result_profile_sync_stage(session.stage, "sync_result_profile")?;
|
||||
let mut profile = payload
|
||||
.get("profile")
|
||||
.and_then(JsonValue::as_object)
|
||||
@@ -4606,6 +4606,22 @@ fn ensure_refining_stage(stage: RpgAgentStage, action: &str) -> Result<(), Strin
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_result_profile_sync_stage(stage: RpgAgentStage, action: &str) -> Result<(), String> {
|
||||
if matches!(
|
||||
stage,
|
||||
RpgAgentStage::ObjectRefining
|
||||
| RpgAgentStage::VisualRefining
|
||||
| RpgAgentStage::LongTailReview
|
||||
| RpgAgentStage::ReadyToPublish
|
||||
) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!(
|
||||
"{action} is only available during object_refining, visual_refining, long_tail_review or ready_to_publish"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_long_tail_stage(stage: RpgAgentStage, action: &str) -> Result<(), String> {
|
||||
if matches!(
|
||||
stage,
|
||||
|
||||
@@ -3,10 +3,10 @@ use module_puzzle::{
|
||||
PuzzleAgentMessageRole, PuzzleAgentMessageSnapshot, PuzzleAgentSessionCreateInput,
|
||||
PuzzleAgentSessionGetInput, PuzzleAgentSessionProcedureResult, PuzzleAgentSessionSnapshot,
|
||||
PuzzleAgentStage, PuzzleAnchorPack, PuzzleDraftCompileInput, PuzzleGeneratedImageCandidate,
|
||||
PuzzleGeneratedImagesSaveInput, PuzzlePublicationStatus, PuzzlePublishInput, PuzzleResultDraft,
|
||||
PuzzleLeaderboardEntry, PuzzleLeaderboardSubmitInput, PuzzleRunDragInput, PuzzleRunGetInput,
|
||||
PuzzleRunNextLevelInput, PuzzleRunProcedureResult, PuzzleRunSnapshot, PuzzleRunStartInput,
|
||||
PuzzleRunSwapInput, PuzzleRuntimeLevelStatus, PuzzleSelectCoverImageInput,
|
||||
PuzzleGeneratedImagesSaveInput, PuzzleLeaderboardEntry, PuzzleLeaderboardSubmitInput,
|
||||
PuzzlePublicationStatus, PuzzlePublishInput, PuzzleResultDraft, PuzzleRunDragInput,
|
||||
PuzzleRunGetInput, PuzzleRunNextLevelInput, PuzzleRunProcedureResult, PuzzleRunSnapshot,
|
||||
PuzzleRunStartInput, PuzzleRunSwapInput, PuzzleRuntimeLevelStatus, PuzzleSelectCoverImageInput,
|
||||
PuzzleWorkDeleteInput, PuzzleWorkGetInput, PuzzleWorkProcedureResult, PuzzleWorkProfile,
|
||||
PuzzleWorkUpsertInput, PuzzleWorksListInput, PuzzleWorksProcedureResult,
|
||||
apply_publish_overrides_to_draft, apply_selected_candidate, build_result_preview,
|
||||
@@ -1689,12 +1689,7 @@ fn upsert_puzzle_leaderboard_entry(
|
||||
) {
|
||||
let entry_id = build_puzzle_leaderboard_entry_id(user_id, profile_id, grid_size);
|
||||
let updated_at = Timestamp::from_micros_since_unix_epoch(updated_at_micros);
|
||||
if let Some(existing) = ctx
|
||||
.db
|
||||
.puzzle_leaderboard_entry()
|
||||
.entry_id()
|
||||
.find(&entry_id)
|
||||
{
|
||||
if let Some(existing) = ctx.db.puzzle_leaderboard_entry().entry_id().find(&entry_id) {
|
||||
let should_replace = elapsed_ms < existing.best_elapsed_ms
|
||||
|| (elapsed_ms == existing.best_elapsed_ms
|
||||
&& updated_at.to_micros_since_unix_epoch()
|
||||
@@ -1725,16 +1720,18 @@ fn upsert_puzzle_leaderboard_entry(
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.db.puzzle_leaderboard_entry().insert(PuzzleLeaderboardEntryRow {
|
||||
entry_id,
|
||||
profile_id: profile_id.to_string(),
|
||||
grid_size,
|
||||
user_id: user_id.to_string(),
|
||||
nickname: nickname.to_string(),
|
||||
best_elapsed_ms: elapsed_ms,
|
||||
last_run_id: run_id.to_string(),
|
||||
updated_at,
|
||||
});
|
||||
ctx.db
|
||||
.puzzle_leaderboard_entry()
|
||||
.insert(PuzzleLeaderboardEntryRow {
|
||||
entry_id,
|
||||
profile_id: profile_id.to_string(),
|
||||
grid_size,
|
||||
user_id: user_id.to_string(),
|
||||
nickname: nickname.to_string(),
|
||||
best_elapsed_ms: elapsed_ms,
|
||||
last_run_id: run_id.to_string(),
|
||||
updated_at,
|
||||
});
|
||||
}
|
||||
|
||||
fn list_puzzle_leaderboard_entries(
|
||||
@@ -1799,8 +1796,8 @@ fn deserialize_run(value: &str) -> Result<PuzzleRunSnapshot, String> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use module_puzzle::{
|
||||
build_generated_candidates, empty_anchor_pack, recommendation_score, tag_similarity_score,
|
||||
PuzzleLeaderboardEntry,
|
||||
PuzzleLeaderboardEntry, build_generated_candidates, empty_anchor_pack,
|
||||
recommendation_score, tag_similarity_score,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user