Expose the order of the completions and the Season's last Match (#84)
The Challenge's chronological pass that counts the Attempts now also records the Completed champions in the order of their first top 1, and what the Season's latest Match, all Formats, did to its champion: an Attempt, the completing Match, or one played after completion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYQB8paBcLk67XoAUYARBK
This commit is contained in:
1 parent
cee9ff2989
commit
e28aefc3bc
3 files changed
+152
-17
No files matched your search
@@ -1,13 +1,14 @@
|
||||
mod common;
|
||||
|
||||
use arena_tracker_core::{
|
||||
Account, Champion, ChampionChallenge, ChampionRow, ChampionState, Column, Error, Format, Marks,
|
||||
Scope, Season, SeasonScope, StateFilter, Statistics, Tracker, sort_rows,
|
||||
Account, Champion, ChampionChallenge, ChampionRow, ChampionState, Column, Error, Format,
|
||||
LastMatch, Marks, MatchOutcome, Scope, Season, SeasonScope, StateFilter, Statistics, Tracker,
|
||||
sort_rows,
|
||||
};
|
||||
use common::jan_2026 as jan;
|
||||
use common::{
|
||||
CATALOG, FakeChampions, FakeHistory, RIOT_ID, S1, S2, SELF_PUUID, at, date, imported_tracker,
|
||||
payload, payloads, played_by, played_match, recorded_account, run, seasons,
|
||||
CATALOG, FakeChampions, FakeHistory, PlayedMatch, RIOT_ID, S1, S2, SELF_PUUID, at, date,
|
||||
imported_tracker, payload, payloads, played_by, played_match, recorded_account, run, seasons,
|
||||
};
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -862,3 +863,92 @@ fn the_first_top_1_day_matches_the_progress_curve() {
|
||||
assert_eq!(days, curve);
|
||||
assert_eq!(challenge(&stats, 11).completed_on, Some(date(2026, 1, 6)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_completions_keep_the_order_of_their_first_top_1() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let matches = [
|
||||
run(222, &[3, 1], jan(2, 0)), // Completed second, on its 2nd Attempt
|
||||
run(11, &[1, 1], jan(2, 0)), // Completed first: the later top 1 changes nothing
|
||||
run(103, &[1], jan(4, 0)),
|
||||
run(1, &[4], jan(5, 0)), // played, never Completed
|
||||
]
|
||||
.concat();
|
||||
let tracker = imported_tracker(dir.path(), &matches);
|
||||
|
||||
let challenge = stats(&tracker, S1, None).challenge.unwrap();
|
||||
|
||||
assert_eq!(challenge.completion_order, [11, 222, 103]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_last_match_says_what_it_did_to_its_champion() {
|
||||
let last = |matches: &[PlayedMatch], format: Option<Format>| {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let tracker = imported_tracker(dir.path(), matches);
|
||||
stats(&tracker, S1, format).challenge.unwrap().last_match
|
||||
};
|
||||
let outcome = |champion_id, placement, outcome| {
|
||||
Some(LastMatch {
|
||||
champion_id,
|
||||
placement,
|
||||
outcome,
|
||||
})
|
||||
};
|
||||
// Not yet Completed: its 3rd Attempt.
|
||||
assert_eq!(
|
||||
last(&run(11, &[5, 4, 4], jan(2, 0)), None),
|
||||
outcome(11, 4, MatchOutcome::Attempt(3))
|
||||
);
|
||||
// The Match that completes it, here on the 3rd Attempt, or on the first.
|
||||
assert_eq!(
|
||||
last(&run(11, &[5, 4, 1], jan(2, 0)), None),
|
||||
outcome(11, 1, MatchOutcome::Completed(3))
|
||||
);
|
||||
assert_eq!(
|
||||
last(&run(222, &[1], jan(2, 0)), None),
|
||||
outcome(222, 1, MatchOutcome::Completed(1))
|
||||
);
|
||||
// Already Completed: not an Attempt.
|
||||
assert_eq!(
|
||||
last(&run(11, &[1, 4], jan(2, 0)), None),
|
||||
outcome(11, 4, MatchOutcome::AfterCompletion)
|
||||
);
|
||||
// The latest by start time, whatever the champion, and all Formats whatever the filter.
|
||||
let matches = [
|
||||
played_match(103, 2, jan(3, 0)),
|
||||
played_match(11, 6, jan(4, 0)).in_format(1740),
|
||||
played_match(222, 3, jan(2, 0)),
|
||||
];
|
||||
assert_eq!(
|
||||
last(&matches, Some(Format::Arena3x6)),
|
||||
outcome(11, 6, MatchOutcome::Attempt(1))
|
||||
);
|
||||
// Only the Season's Matches: one of the next Season is not the last of this one.
|
||||
assert_eq!(
|
||||
last(
|
||||
&[
|
||||
played_match(103, 2, jan(3, 0)),
|
||||
played_match(11, 1, april(2))
|
||||
],
|
||||
None
|
||||
),
|
||||
outcome(103, 2, MatchOutcome::Attempt(1))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_season_without_any_match_has_no_last_match_nor_completion() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let tracker = imported_tracker(dir.path(), &run(11, &[1], jan(2, 0)));
|
||||
|
||||
let challenge = stats(&tracker, S2, None).challenge.unwrap();
|
||||
|
||||
assert_eq!(challenge.last_match, None);
|
||||
assert!(challenge.completion_order.is_empty());
|
||||
}
|
||||
|
||||
/// A day of April 2026, in the second Season.
|
||||
fn april(day: u8) -> i64 {
|
||||
at(date(2026, 4, day), 0)
|
||||
}
|
||||
Reference in new issue
Block a user