Name things as the glossary does, reuse the core's Season periods
CI / core (pull_request) Successful in 1m46s
CI / core (pull_request) Successful in 1m46s
« En attente » is AWAITED, the block's PUUID is the client's; the filters of « Parties » use the core's period of a Season instead of a copy; the list view joins the cached views in docs/performance.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d4cdfd9670
commit
1192c13830
14 files changed
+41
-52
No files matched your search
@@ -25,9 +25,9 @@ pub(in crate::page) use list::MatchList;
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use list::MatchRow as Row;
|
||||
pub use list::init;
|
||||
use shown::{Champions, ShownRecap};
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use shown::{PENDING, ShownAugment, ShownPlayer, Slot, UNAVAILABLE};
|
||||
pub(in crate::page) use shown::{AWAITED, ShownAugment, ShownPlayer, Slot, UNAVAILABLE};
|
||||
use shown::{Champions, ShownRecap};
|
||||
|
||||
use super::{Page, Tab};
|
||||
use crate::card_images::CardImages;
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::path::PathBuf;
|
||||
use arena_tracker_core::{DamageSums, DeathRecapState, Effect, GameCatalog, RecapPlayer};
|
||||
use gpui_kit::SharedString;
|
||||
|
||||
use super::shown::{PENDING, UNAVAILABLE};
|
||||
use super::shown::{AWAITED, UNAVAILABLE};
|
||||
use crate::text::thousands;
|
||||
|
||||
pub(in crate::page) const LOADING: &str = "Chargement…";
|
||||
@@ -60,7 +60,7 @@ impl ShownDamage {
|
||||
catalog: &GameCatalog,
|
||||
) -> ShownDamage {
|
||||
if provisional {
|
||||
return ShownDamage::Note(PENDING);
|
||||
return ShownDamage::Note(AWAITED);
|
||||
}
|
||||
let stored = match death {
|
||||
Death::Failed => return ShownDamage::Retry,
|
||||
@@ -139,10 +139,10 @@ mod tests {
|
||||
let known = |state| Death::Known(state);
|
||||
let note = |word| ShownDamage::Note(word);
|
||||
// A Provisional Match waits, whatever is known.
|
||||
assert_eq!(damage(true, &Death::Loading), note(PENDING));
|
||||
assert_eq!(damage(true, &Death::Loading), note(AWAITED));
|
||||
assert_eq!(
|
||||
damage(true, &known(DeathRecapState::NotFetched)),
|
||||
note(PENDING)
|
||||
note(AWAITED)
|
||||
);
|
||||
assert_eq!(damage(false, &Death::Loading), note(LOADING));
|
||||
assert_eq!(damage(false, &Death::Failed), ShownDamage::Retry);
|
||||
|
||||
@@ -98,7 +98,7 @@ fn measure(caption: &'static str, value: Value) -> Measure {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::page::matches::shown::{PENDING, UNAVAILABLE};
|
||||
use crate::page::matches::shown::{AWAITED, UNAVAILABLE};
|
||||
|
||||
fn text(details: &Details, title: &str, caption: &str) -> (String, bool) {
|
||||
let value = details.get(title, caption).unwrap();
|
||||
@@ -159,13 +159,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn a_provisional_match_waits_for_its_details() {
|
||||
let details = Details::of(&RecapPlayer::default(), PENDING);
|
||||
let details = Details::of(&RecapPlayer::default(), AWAITED);
|
||||
assert!(
|
||||
details
|
||||
.0
|
||||
.iter()
|
||||
.flat_map(|g| &g.measures)
|
||||
.all(|m| { m.value.missing && m.value.text == PENDING })
|
||||
.all(|m| { m.value.missing && m.value.text == AWAITED })
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -56,9 +56,8 @@ pub(super) struct Filters {
|
||||
/// The search has a query: the champions are only looked up then.
|
||||
searching: bool,
|
||||
pub(super) input: Entity<InputState>,
|
||||
/// Each Season's period in epoch ms, as the statistics cut them: from its start to the next
|
||||
/// one's, the last open-ended.
|
||||
periods: Vec<(String, Range<i64>)>,
|
||||
/// The Season table, oldest first: the periods of the Seasons come from it.
|
||||
seasons: Vec<Season>,
|
||||
}
|
||||
|
||||
impl Filters {
|
||||
@@ -69,7 +68,7 @@ impl Filters {
|
||||
search: ChampionSearch::new(""),
|
||||
searching: false,
|
||||
input: cx.new(|cx| InputState::new(window, cx).placeholder("Rechercher")),
|
||||
periods: periods(seasons),
|
||||
seasons: seasons.to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,25 +85,10 @@ impl Filters {
|
||||
|
||||
/// The period of `season`; none for a Season the table does not know.
|
||||
fn period(&self, season: &str) -> Range<i64> {
|
||||
(self.periods.iter())
|
||||
.find(|(name, _)| name == season)
|
||||
.map_or(0..0, |(_, period)| period.clone())
|
||||
arena_tracker_core::period(&self.seasons, season).unwrap_or(0..0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Each Season's period in epoch ms: from its start to the next one's, the last open-ended.
|
||||
/// `seasons` is sorted by start.
|
||||
fn periods(seasons: &[Season]) -> Vec<(String, Range<i64>)> {
|
||||
(seasons.iter().enumerate())
|
||||
.map(|(ix, season)| {
|
||||
let end = seasons
|
||||
.get(ix + 1)
|
||||
.map_or(i64::MAX, |next| next.start.start_ms());
|
||||
(season.name.clone(), season.start.start_ms()..end)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl Page {
|
||||
/// The positions, in the entries, of the Matches the filters keep.
|
||||
fn visible_matches(&self, champions: &Champions) -> Vec<usize> {
|
||||
@@ -312,7 +296,7 @@ pub(super) fn no_result(muted: Hsla) -> impl IntoElement {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{MatchEntry, PlacementFilter, Season, periods};
|
||||
use super::{MatchEntry, PlacementFilter, Season};
|
||||
use arena_tracker_core::{Date, Format};
|
||||
|
||||
fn entry(placement: u8, win: bool) -> MatchEntry {
|
||||
@@ -355,8 +339,12 @@ mod tests {
|
||||
#[test]
|
||||
fn a_season_runs_to_the_next_ones_start_and_the_last_is_open() {
|
||||
let (a, b) = (season("A", 1), season("B", 6));
|
||||
let periods = periods(&[a.clone(), b.clone()]);
|
||||
assert_eq!(periods[0].1, a.start.start_ms()..b.start.start_ms());
|
||||
assert_eq!(periods[1].1.end, i64::MAX);
|
||||
let seasons = [a.clone(), b.clone()];
|
||||
let first = arena_tracker_core::period(&seasons, "A").unwrap();
|
||||
assert_eq!(first, a.start.start_ms()..b.start.start_ms());
|
||||
assert_eq!(
|
||||
arena_tracker_core::period(&seasons, "B").unwrap().end,
|
||||
i64::MAX
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ use crate::text::{duration, match_time, ordinal, thousands};
|
||||
/// A value absent from the source: never shown as 0.
|
||||
pub(in crate::page) const UNAVAILABLE: &str = "Indisponible";
|
||||
/// The same in a Provisional Match, whose source gives less until Riot publishes it.
|
||||
pub(in crate::page) const PENDING: &str = "En attente";
|
||||
pub(in crate::page) const AWAITED: &str = "En attente";
|
||||
|
||||
/// A champion of the catalog, as « Parties » needs it.
|
||||
struct Known {
|
||||
@@ -175,7 +175,7 @@ impl ShownRecap {
|
||||
death: &Death,
|
||||
) -> ShownRecap {
|
||||
let missing = if recap.provisional {
|
||||
PENDING
|
||||
AWAITED
|
||||
} else {
|
||||
UNAVAILABLE
|
||||
};
|
||||
@@ -216,7 +216,7 @@ fn player(
|
||||
champions: &Champions,
|
||||
catalog: &GameCatalog,
|
||||
) -> ShownPlayer {
|
||||
let missing = if provisional { PENDING } else { UNAVAILABLE };
|
||||
let missing = if provisional { AWAITED } else { UNAVAILABLE };
|
||||
let count = |value: Option<u32>| value.map_or_else(|| missing.to_string(), |v| v.to_string());
|
||||
let kda = [p.kills, p.deaths, p.assists];
|
||||
let absent = || Value::of(None::<()>, missing, |_| String::new());
|
||||
@@ -362,7 +362,7 @@ mod tests {
|
||||
&Death::Loading,
|
||||
);
|
||||
assert!(shown.provisional);
|
||||
assert_eq!(shown.teams[0].players[0].level.text, PENDING);
|
||||
assert_eq!(shown.teams[0].placement.text, PENDING);
|
||||
assert_eq!(shown.teams[0].players[0].level.text, AWAITED);
|
||||
assert_eq!(shown.teams[0].placement.text, AWAITED);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::matches_fixtures::{TwoAccounts, recap_ready};
|
||||
use super::page_fixtures::{center, draw, open_page_with_tracker, switch_tab};
|
||||
use crate::page::matches::{PENDING, Recap, ShownDamage};
|
||||
use crate::page::matches::{AWAITED, Recap, ShownDamage};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{
|
||||
@@ -119,7 +119,7 @@ pub(super) fn block() -> EndOfGameBlock {
|
||||
});
|
||||
EndOfGameBlock {
|
||||
content: content.to_string(),
|
||||
summoner_puuid: Some("client-alice".into()),
|
||||
client_puuid: Some("client-alice".into()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ async fn a_provisional_match_has_its_badge_and_waits_for_its_values(cx: &mut Tes
|
||||
for player in &team.players {
|
||||
missing.extend([&player.riot_id, &player.level, &player.damage]);
|
||||
// No timeline yet: waited for too, and not asked for.
|
||||
assert_eq!(player.damage_seen, ShownDamage::Note(PENDING));
|
||||
assert_eq!(player.damage_seen, ShownDamage::Note(AWAITED));
|
||||
for group in &player.details.0 {
|
||||
missing.extend(group.measures.iter().map(|m| &m.value));
|
||||
}
|
||||
@@ -199,7 +199,7 @@ async fn a_provisional_match_has_its_badge_and_waits_for_its_values(cx: &mut Tes
|
||||
}
|
||||
let missing: Vec<_> = missing.into_iter().filter(|v| v.missing).collect();
|
||||
assert!(!missing.is_empty());
|
||||
assert!(missing.iter().all(|v| v.text == PENDING), "{missing:?}");
|
||||
assert!(missing.iter().all(|v| v.text == AWAITED), "{missing:?}");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ async fn publication_replaces_the_provisional_match_keeping_the_selection_and_th
|
||||
assert!(!shown.provisional);
|
||||
let account = shown.teams.iter().find(|t| t.account).unwrap();
|
||||
assert_eq!(account.placement.text, "2ᵉ");
|
||||
assert!(shown.teams.iter().all(|t| t.placement.text != PENDING));
|
||||
assert!(shown.teams.iter().all(|t| t.placement.text != AWAITED));
|
||||
});
|
||||
assert!(window.debug_bounds("recap-provisional").is_none());
|
||||
assert_eq!(open(&page, &mut window), Some(1));
|
||||
|
||||
@@ -42,7 +42,7 @@ pub trait GameClientSource: Send + Sync {
|
||||
pub struct EndOfGameBlock {
|
||||
/// The JSON content, as the client gave it.
|
||||
pub content: String,
|
||||
pub summoner_puuid: Option<String>,
|
||||
pub client_puuid: Option<String>,
|
||||
}
|
||||
|
||||
/// What a wait saw: a champ select change, or anything else (gameflow, summoner, a timeout).
|
||||
|
||||
@@ -70,7 +70,7 @@ impl Tracker {
|
||||
let row = StoredBlock {
|
||||
id: None,
|
||||
received_at_ms: now_ms,
|
||||
client_puuid: block.summoner_puuid.clone(),
|
||||
client_puuid: block.client_puuid.clone(),
|
||||
signed_in_riot_id: signed_in.map(Into::into),
|
||||
raw: block.content.clone(),
|
||||
};
|
||||
|
||||
@@ -241,7 +241,7 @@ impl GameClientSource for LeagueClient {
|
||||
let content = self.get_ok(END_OF_GAME_BLOCK).ok()?;
|
||||
Some(EndOfGameBlock {
|
||||
content,
|
||||
summoner_puuid: lock(&self.summoner_puuid).clone(),
|
||||
client_puuid: lock(&self.summoner_puuid).clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ impl LeagueClient {
|
||||
}
|
||||
*lock(&self.end_of_game_block) = Some(EndOfGameBlock {
|
||||
content: data.to_string(),
|
||||
summoner_puuid: lock(&self.summoner_puuid).clone(),
|
||||
client_puuid: lock(&self.summoner_puuid).clone(),
|
||||
});
|
||||
Some(ClientEvent::Other)
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ fn the_end_of_game_block_is_kept_from_its_event_until_a_round_takes_it() {
|
||||
serde_json::from_str::<Value>(&taken.content).unwrap(),
|
||||
block
|
||||
);
|
||||
assert_eq!(taken.summoner_puuid.as_deref(), Some("client-puuid"));
|
||||
assert_eq!(taken.client_puuid.as_deref(), Some("client-puuid"));
|
||||
assert_eq!(client.take_end_of_game_block(), None, "handed over once");
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ pub use league_client::{LeagueClient, decode_gameflow};
|
||||
pub use model::{Account, FollowedMatch, Format, Match, MatchEnd, SyncProgress, SyncReport};
|
||||
pub use recap::{DamageByType, MatchRecap, RecapPlayer, RecapTeam};
|
||||
pub use riot::RiotApi;
|
||||
pub use seasons::{Season, default_seasons, load_seasons};
|
||||
pub use seasons::{Season, default_seasons, load_seasons, period};
|
||||
pub use splash::{BannerFrame, Splash, SplashFocus};
|
||||
pub use statistics::{
|
||||
ChallengeSummary, ChampionChallenge, ChampionRow, ChampionState, Charts, Column, LastMatch,
|
||||
|
||||
@@ -80,7 +80,7 @@ fn parse(text: &str) -> Result<Vec<Season>, String> {
|
||||
|
||||
/// The period of a Season in epoch ms: from its start up to the next Season's start
|
||||
/// (exclusive); the last one is open-ended. `seasons` must be sorted by start.
|
||||
pub(crate) fn period(seasons: &[Season], name: &str) -> Option<Range<i64>> {
|
||||
pub fn period(seasons: &[Season], name: &str) -> Option<Range<i64>> {
|
||||
let i = seasons.iter().position(|s| s.name == name)?;
|
||||
let end = seasons
|
||||
.get(i + 1)
|
||||
|
||||
@@ -292,7 +292,7 @@ impl GameClientSource for FakeClient {
|
||||
let content = state.end_of_game_event.take()?;
|
||||
Some(EndOfGameBlock {
|
||||
content,
|
||||
summoner_puuid: state.summoner_puuid.clone(),
|
||||
client_puuid: state.summoner_puuid.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ impl GameClientSource for FakeClient {
|
||||
state.end_of_game_reads += 1;
|
||||
Some(EndOfGameBlock {
|
||||
content: state.end_of_game_route.clone()?,
|
||||
summoner_puuid: state.summoner_puuid.clone(),
|
||||
client_puuid: state.summoner_puuid.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -75,3 +75,4 @@ The identity (ring, banner, animations; `docs/interface.md`) follows the same ru
|
||||
- **Two splashes decoded at most**: the one shown and the one replacing it. All splashes are downloaded in the background, at low priority, after the card portraits, and kept on disk.
|
||||
- During champ select, the Anvil grid is cached at the height of its card rows. The capture replay checks that a splash fade builds no cards and that traversing the hand and « Autres champions » keeps at most two decoded splashes. The latest hovered card takes over when the current fade finishes.
|
||||
- **The ring is a cached view**, laid out from its style alone. A structural test guards it: hovering a card, scrolling the grid or an animation on another part does not render the ring; only a change of what it shows (the champions' state, their order, the selection) or its own animation does. Its gain is checked at the next release benchmark.
|
||||
- **The « Parties » list is a cached view** (`MatchList`, `crates/app/src/page/matches/list.rs`), which owns its selection, scroll and hover. The page drawn again (the recap arriving, the veil) does not draw it: a structural test in `crates/app/src/page/tests/matches.rs` checks that its render count does not move. Its gain is checked at the next release benchmark.
|
||||
Reference in new issue
Block a user