Play the strongest Match on its own champion and report every followed game (#89)
CI / core (pull_request) Successful in 1m40s

From the review of PR #99:
- Of several followed Matches waiting, the strongest plays on its own
  champion (tick, card and splash), the most recent among equals. The
  comet no longer flies to one champion's tick with another's splash.
- A game the client gave no id for, or seen before any Match gave the
  platform, is reported when the sync stores it: the client's id when
  it has one, else the newest Match newer than every one stored. A
  first import without that id stays history.
- What a Match brought comes from the Challenge's own Marks, with and
  without it, instead of a second set of rules in SQL; `fetch_and_store`
  is back to fetching and storing. `MatchEnd::Completed` takes the
  glossary's word, and its variants are documented again.
- Only the count of the banner's title rolls in, from 10 px below, as
  in the prototype; the « Dernière Partie » line still fades in.
- The Windows setting is checked where a Match is queued, and the tests
  now go through the follower round and the statistics; a test checks
  that the end state is what a reload shows.
- The Match's state is one `MatchPlayback`, ended in one place; the
  durations are named; `MarkFill`, `Changing` and `RevealFrame` replace
  bare tuples; a splash that cannot be read ends its reveal.
- `follow_client_with` takes the report itself, without a forwarding
  function. docs/performance.md describes the Match animation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 authored and nessar committed 2026-11-22 15:16:04 +01:00
1 parent 126912fd09
commit 44c2d10b3b
14 files changed
+711 -325

No files matched your search

+83 -15
View File
@@ -7,9 +7,9 @@ use std::thread;
use std::time::{Duration, Instant};
use arena_tracker_core::{
Account, ChampSelect, ChampionRow, ChampionState, ClientError, ClientEvent, Format,
MATCH_RETRIES, ProgressCheck, RETRY_EVERY_MS, Scope, SeasonScope, SourceError, Tracker,
Unpickable, UpdateProblem,
Account, ChampSelect, ChampionRow, ChampionState, ClientError, ClientEvent, FollowedMatch,
Format, MATCH_RETRIES, MatchEnd, ProgressCheck, RETRY_EVERY_MS, Scope, SeasonScope,
SourceError, Tracker, Unpickable, UpdateProblem,
};
use common::{
FakeClient, FakeHistory, PlayedMatch, RawChampSelect, S2, S2_TRACK, SELF_PUUID, at, date,
@@ -674,23 +674,13 @@ fn only_a_live_insert_reports_what_the_match_brought_to_the_challenge() {
use arena_tracker_core::MatchEnd::*;
let world = World::new(&s2_matches());
let tracker = world.tracker();
let follow = || {
let mut events = Vec::new();
tracker.follow_client_reporting(
now(),
None,
&tracker.client_snapshot(),
&mut |_| {},
&mut |e| events.push(e),
);
events
};
let follow = || reported_round(&tracker);
assert!(follow().is_empty(), "history import");
for (i, (placement, expected)) in [
(6, Mark),
(2, Mark),
(3, Nothing),
(1, Completion),
(1, Completed),
(1, Nothing),
]
.into_iter()
@@ -719,6 +709,84 @@ fn only_a_live_insert_reports_what_the_match_brought_to_the_challenge() {
}
}
/// A round one retry interval after the previous one, and the followed Matches it reports.
fn reported_round(tracker: &Tracker) -> Vec<FollowedMatch> {
let now_ms = CLOCK.with(|clock| clock.replace(clock.get() + RETRY_EVERY_MS) + RETRY_EVERY_MS);
let mut events = Vec::new();
tracker.follow_client_with(
now_ms,
None,
&tracker.client_snapshot(),
&mut |_| {},
&mut |e| events.push(e),
);
events
}
#[test]
fn a_game_the_client_gave_no_id_for_is_reported_when_a_sync_stores_it() {
let world = World::new(&s2_matches());
let tracker = world.tracker();
assert!(reported_round(&tracker).is_empty(), "history import");
world.client.set_game_id(None);
world.client.set_phase("InProgress", true);
assert!(reported_round(&tracker).is_empty());
world.history.add(payload(
"EUW1_900",
1750,
222,
"Jinx",
6,
false,
at(date(2026, 4, 5), 1),
));
world.client.set_phase("EndOfGame", true);
let events = reported_round(&tracker);
assert_eq!(
events
.iter()
.map(|e| (e.champion_id, e.end))
.collect::<Vec<_>>(),
[(222, MatchEnd::Mark)]
);
assert!(reported_round(&tracker).is_empty());
}
#[test]
fn without_a_platform_the_first_import_reports_only_the_game_the_client_named() {
let world = World::new(&[]);
let tracker = world.tracker();
assert!(reported_round(&tracker).is_empty());
world.client.set_game_id(Some(common::recorded_game_id()));
world.client.set_phase("InProgress", true);
assert!(reported_round(&tracker).is_empty());
world.history.add(payload(
"EUW1_1",
1750,
11,
"Ahri",
3,
true,
at(date(2026, 4, 4), 1),
));
world.history.add(finished_match(1750));
world.client.set_phase("EndOfGame", true);
let events = reported_round(&tracker);
assert_eq!(tracker.match_count(SELF_PUUID).unwrap(), 2);
assert_eq!(
events
.iter()
.map(|e| (e.champion_id, e.end))
.collect::<Vec<_>>(),
[(222, MatchEnd::Completed)]
);
assert!(reported_round(&tracker).is_empty(), "already stored");
}
#[test]
fn a_finished_game_is_fetched_by_its_id_even_in_a_queue_nobody_lists() {
let world = World::new(&s2_matches());