record-daemon: end-of-game stats, summoner spells
record-daemon / Build, check and test (push) Failing after 8s
record-daemon / Build, check and test (push) Failing after 8s
This commit is contained in:
@@ -388,11 +388,18 @@ impl Daemon {
|
||||
map_name,
|
||||
team,
|
||||
summoner_name,
|
||||
puuid: transition_puuid,
|
||||
runes: transition_runes,
|
||||
summoner_spells: transition_summoner_spells,
|
||||
} => {
|
||||
info!(
|
||||
"[EVENT_HANDLER] GameStarted transition - game_id: {}, champion: {:?}, queue_type: {:?}, game_mode: {:?}",
|
||||
game_id, champion, queue_type, game_mode
|
||||
);
|
||||
info!(
|
||||
"[EVENT_HANDLER] Transition provided: puuid={:?}, runes={:?}, summoner_spells={:?}",
|
||||
transition_puuid, transition_runes, transition_summoner_spells
|
||||
);
|
||||
|
||||
// If already recording, stop the current recording first
|
||||
if self.state_machine.is_recording() {
|
||||
@@ -435,6 +442,35 @@ impl Daemon {
|
||||
})
|
||||
});
|
||||
|
||||
// Fetch player game metadata (runes, summoner spells, puuid) as fallback
|
||||
let player_metadata = self.lqp_client.fetch_player_game_metadata().await.ok();
|
||||
let (fetched_puuid, fetched_runes, fetched_summoner_spells) =
|
||||
player_metadata.map_or((None, None, None), |m| {
|
||||
(m.puuid, m.runes, m.summoner_spells)
|
||||
});
|
||||
|
||||
// Use transition values first, then fall back to fetched values
|
||||
let final_puuid = transition_puuid.or(fetched_puuid);
|
||||
let final_runes = transition_runes.or(fetched_runes);
|
||||
let final_summoner_spells = transition_summoner_spells.or(fetched_summoner_spells);
|
||||
|
||||
info!(
|
||||
"[EVENT_HANDLER] Final values: puuid={:?}, runes={:?}, summoner_spells={:?}",
|
||||
final_puuid, final_runes, final_summoner_spells
|
||||
);
|
||||
|
||||
// Fetch all players identities for puuid mapping
|
||||
let all_players_identities = self.lqp_client.fetch_all_players_identities().await.ok();
|
||||
let all_players_info: Vec<record_daemon::timeline::PlayerIdentityInfo> =
|
||||
all_players_identities.unwrap_or_default().into_iter().map(|p| {
|
||||
record_daemon::timeline::PlayerIdentityInfo {
|
||||
puuid: p.puuid,
|
||||
summoner_name: p.summoner_name,
|
||||
champion_name: p.champion_name,
|
||||
team: p.team,
|
||||
}
|
||||
}).collect();
|
||||
|
||||
// Build game metadata for timeline
|
||||
let metadata_update = record_daemon::timeline::MetadataUpdate {
|
||||
queue_type: queue_type.clone(),
|
||||
@@ -443,6 +479,10 @@ impl Daemon {
|
||||
map_name: map_name.clone(),
|
||||
team,
|
||||
summoner_name: summoner_name.clone(),
|
||||
puuid: final_puuid,
|
||||
runes: final_runes,
|
||||
summoner_spells: final_summoner_spells,
|
||||
all_players: all_players_info,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -461,12 +501,15 @@ impl Daemon {
|
||||
info!("[EVENT_HANDLER] start_recording completed successfully");
|
||||
}
|
||||
}
|
||||
StateTransition::GameEnded { game_end_info } => {
|
||||
StateTransition::GameEnded { game_end_info, final_items: _ } => {
|
||||
info!(
|
||||
"[EVENT_HANDLER] GameEnded transition with info: {:?}",
|
||||
game_end_info
|
||||
);
|
||||
|
||||
// Fetch final items before stopping
|
||||
let fetched_final_items = self.lqp_client.fetch_final_items().await.ok().flatten();
|
||||
|
||||
// Convert GameEndInfo to GameEndMetadata if available
|
||||
let game_end_metadata =
|
||||
game_end_info.map(|info| record_daemon::lqp::GameEndMetadata {
|
||||
@@ -508,7 +551,7 @@ impl Daemon {
|
||||
game_end_metadata
|
||||
);
|
||||
|
||||
if let Err(e) = self.stop_recording_with_metadata(game_end_metadata).await {
|
||||
if let Err(e) = self.stop_recording_with_metadata(game_end_metadata, fetched_final_items).await {
|
||||
error!("[EVENT_HANDLER] Failed to stop recording: {}", e);
|
||||
|
||||
// Don't propagate error - keep daemon running
|
||||
@@ -598,13 +641,14 @@ impl Daemon {
|
||||
|
||||
/// Stop recording.
|
||||
async fn stop_recording(&self) -> Result<()> {
|
||||
self.stop_recording_with_metadata(None).await
|
||||
self.stop_recording_with_metadata(None, None).await
|
||||
}
|
||||
|
||||
/// Stop recording with optional game end metadata.
|
||||
async fn stop_recording_with_metadata(
|
||||
&self,
|
||||
game_end_metadata: Option<record_daemon::lqp::GameEndMetadata>,
|
||||
final_items: Option<record_daemon::lqp::ItemBuild>,
|
||||
) -> Result<()> {
|
||||
info!("Stopping recording");
|
||||
|
||||
@@ -673,6 +717,9 @@ impl Daemon {
|
||||
});
|
||||
}
|
||||
|
||||
// Add final items
|
||||
update.final_items = final_items;
|
||||
|
||||
// Apply the update
|
||||
if let Err(e) = timeline_store.write().update_metadata(recording_id, update) {
|
||||
warn!("Failed to update recording metadata: {}", e);
|
||||
|
||||
Reference in New Issue
Block a user