record-daemon: remove data in state machine
record-daemon / Build, check and test (push) Successful in 2m11s
record-daemon / Build, check and test (push) Successful in 2m11s
This commit is contained in:
+75
-77
@@ -353,33 +353,32 @@ impl Daemon {
|
||||
if let Some(_new_state) = self.state_machine.transition(transition.clone()) {
|
||||
// Handle recording start/stop
|
||||
match transition {
|
||||
StateTransition::GameStarted {
|
||||
game_id,
|
||||
champion,
|
||||
queue_type,
|
||||
queue_id,
|
||||
game_mode,
|
||||
map_name,
|
||||
team,
|
||||
summoner_name,
|
||||
puuid: transition_puuid,
|
||||
runes: transition_runes,
|
||||
summoner_spells: transition_summoner_spells,
|
||||
} => {
|
||||
StateTransition::GameStarted => {
|
||||
// Extract data from the GameStart event that was stored in the timeline
|
||||
let (game_id, queue_type, queue_id, game_mode, map_name, session) =
|
||||
if let GameEvent::GameStart(ref info) = event {
|
||||
(
|
||||
info.game_id,
|
||||
info.queue_type.clone(),
|
||||
info.queue_id,
|
||||
info.game_mode.clone(),
|
||||
info.map_name.clone(),
|
||||
info.session.clone(),
|
||||
)
|
||||
} else {
|
||||
(0, None, None, None, None, None)
|
||||
};
|
||||
|
||||
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
|
||||
);
|
||||
"[EVENT_HANDLER] GameStarted transition - game_id: {}, queue_type: {:?}, game_mode: {:?}",
|
||||
game_id, queue_type, game_mode
|
||||
);
|
||||
|
||||
// If already recording, stop the current recording first
|
||||
if self.state_machine.is_recording() {
|
||||
info!(
|
||||
"[EVENT_HANDLER] Stopping previous recording before starting new one"
|
||||
);
|
||||
"[EVENT_HANDLER] Stopping previous recording before starting new one"
|
||||
);
|
||||
|
||||
if let Err(e) = self.stop_recording().await {
|
||||
warn!("[EVENT_HANDLER] Failed to stop previous recording: {}", e);
|
||||
@@ -388,51 +387,56 @@ impl Daemon {
|
||||
|
||||
info!("[EVENT_HANDLER] Calling start_recording...");
|
||||
|
||||
// Wrap the start_recording call to catch any panics
|
||||
let start_result =
|
||||
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
// We need to use a blocking approach here since we're in catch_unwind
|
||||
// The actual async call happens outside
|
||||
}));
|
||||
|
||||
if let Err(panic_info) = start_result {
|
||||
error!(
|
||||
"[EVENT_HANDLER] PANIC before start_recording: {:?}",
|
||||
panic_info
|
||||
);
|
||||
|
||||
eprintln!(
|
||||
"[EVENT_HANDLER] PANIC before start_recording: {:?}",
|
||||
panic_info
|
||||
);
|
||||
}
|
||||
|
||||
// Get pre-game metadata to pass to recording
|
||||
let pregame = self.pregame_data.read().clone();
|
||||
let champion_name = champion.or_else(|| {
|
||||
pregame.as_ref().and({
|
||||
// Try to get champion name from metadata if not provided
|
||||
None // We only have champion_id, not name
|
||||
})
|
||||
});
|
||||
|
||||
// Fetch player game metadata (runes, summoner spells, puuid) as fallback
|
||||
// Fetch player game metadata (puuid, runes, summoner spells)
|
||||
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)
|
||||
let (puuid, runes, summoner_spells, champion_id, team, summoner_name) =
|
||||
player_metadata.map_or((None, None, None, None, None, None), |m| {
|
||||
(
|
||||
m.puuid,
|
||||
m.runes,
|
||||
m.summoner_spells,
|
||||
m.champion_id,
|
||||
m.team,
|
||||
m.summoner_name,
|
||||
)
|
||||
});
|
||||
|
||||
// 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);
|
||||
// If we have puuid and session, extract player-specific data from session
|
||||
let (champion, final_team, final_summoner_name) = if let Some(ref p) = puuid
|
||||
{
|
||||
if let Some(ref sess) = session {
|
||||
let champ_id = sess.get_champion_id(p);
|
||||
let champ_name =
|
||||
champ_id.and_then(record_daemon::lqp::champion_id_to_name);
|
||||
let team_id = sess.get_team(p);
|
||||
let summoner = sess.get_summoner_name(p).map(|s| s.to_string());
|
||||
(
|
||||
champ_name.or_else(|| {
|
||||
champion_id
|
||||
.and_then(record_daemon::lqp::champion_id_to_name)
|
||||
}),
|
||||
team_id.or(team),
|
||||
summoner.or(summoner_name),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
champion_id.and_then(record_daemon::lqp::champion_id_to_name),
|
||||
team,
|
||||
summoner_name,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
(
|
||||
champion_id.and_then(record_daemon::lqp::champion_id_to_name),
|
||||
team,
|
||||
summoner_name,
|
||||
)
|
||||
};
|
||||
|
||||
info!(
|
||||
"[EVENT_HANDLER] Final values: puuid={:?}, runes={:?}, summoner_spells={:?}",
|
||||
final_puuid, final_runes, final_summoner_spells
|
||||
puuid, runes, summoner_spells
|
||||
);
|
||||
|
||||
// Fetch all players identities for puuid mapping
|
||||
@@ -452,15 +456,15 @@ impl Daemon {
|
||||
|
||||
// Build game metadata for timeline
|
||||
let metadata_update = record_daemon::timeline::MetadataUpdate {
|
||||
queue_type: queue_type.clone(),
|
||||
queue_type,
|
||||
queue_id,
|
||||
game_mode: game_mode.clone(),
|
||||
map_name: map_name.clone(),
|
||||
team,
|
||||
summoner_name: summoner_name.clone(),
|
||||
puuid: final_puuid,
|
||||
runes: final_runes,
|
||||
summoner_spells: final_summoner_spells,
|
||||
game_mode,
|
||||
map_name,
|
||||
team: final_team,
|
||||
summoner_name: final_summoner_name,
|
||||
puuid,
|
||||
runes,
|
||||
summoner_spells,
|
||||
all_players: all_players_info,
|
||||
..Default::default()
|
||||
};
|
||||
@@ -468,7 +472,7 @@ impl Daemon {
|
||||
if let Err(e) = self
|
||||
.start_recording_with_metadata(
|
||||
game_id,
|
||||
champion_name.as_deref(),
|
||||
champion.as_deref(),
|
||||
metadata_update,
|
||||
)
|
||||
.await
|
||||
@@ -480,14 +484,8 @@ impl Daemon {
|
||||
info!("[EVENT_HANDLER] start_recording completed successfully");
|
||||
}
|
||||
}
|
||||
StateTransition::GameEnded {
|
||||
game_end_info,
|
||||
final_items: _,
|
||||
} => {
|
||||
info!(
|
||||
"[EVENT_HANDLER] GameEnded transition with info: {:?}",
|
||||
game_end_info
|
||||
);
|
||||
StateTransition::GameEnded => {
|
||||
info!("[EVENT_HANDLER] GameEnded transition");
|
||||
|
||||
// Fetch final items before stopping
|
||||
let fetched_final_items =
|
||||
|
||||
Reference in New Issue
Block a user