Files
arena-tracker/crates/core/tests/statistics.rs
T

64 lines
1.7 KiB
Rust

mod common;
use arena_tracker_core::{
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, 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;
fn stats(tracker: &Tracker, season: &str, format: Option<Format>) -> Statistics {
let scope = Scope {
season: SeasonScope::Season(season.into()),
format,
};
tracker.statistics(SELF_PUUID, &scope).unwrap()
}
fn all_seasons(tracker: &Tracker) -> Statistics {
let scope = Scope {
season: SeasonScope::AllSeasons,
format: None,
};
tracker.statistics(SELF_PUUID, &scope).unwrap()
}
fn row(stats: &Statistics, champion_id: u32) -> &ChampionRow {
stats
.rows
.iter()
.find(|r| r.champion.id == champion_id)
.unwrap()
}
const NO_MARKS: Marks = Marks {
played: false,
won: false,
completed: false,
};
fn challenge(stats: &Statistics, champion_id: u32) -> ChampionChallenge {
row(stats, champion_id).challenge.unwrap()
}
/// A day of April 2026, in the second Season.
fn april(day: u8) -> i64 {
at(date(2026, 4, day), 0)
}
#[path = "statistics/champion_challenge.rs"]
mod champion_challenge;
#[path = "statistics/completions.rs"]
mod completions;
#[path = "statistics/rows_and_charts.rs"]
mod rows_and_charts;
#[path = "statistics/seasons_and_challenge.rs"]
mod seasons_and_challenge;
#[path = "statistics/sorting_and_filters.rs"]
mod sorting_and_filters;