diff --git a/README.adoc b/README.adoc index 70872db..660f24a 100644 --- a/README.adoc +++ b/README.adoc @@ -5,8 +5,6 @@ == Prelude -VERY EARLY ALPHA -- NOT YET FUNCTIONAL - For my stats course (4U Data Management) I have to interpret a bunch of data generated in class. In an effort to not spend ages mindlessly using a calculator every summative check-in, I have started this project. @@ -14,6 +12,14 @@ I figured, that since I already had to digitize every note, that I was required == Goals +* [ ] Data Visualizer? +* [ ] Dynamic Web Page? +** Server Side Events? +** IDK frontend web at all. +** plotly.rs? +** charming.rs? +** WASM? + === Gamelog * [*] Data Format ** [*] Support recording multiple games diff --git a/gamelog.ron b/gamelog.ron index 517a1dd..a901153 100644 --- a/gamelog.ron +++ b/gamelog.ron @@ -5,7 +5,7 @@ [ Game( version: "0.5.0", - flags: [IgnoreScore], + flags: [Interval(2), IgnoreScore], periods: [ Period( start: First, @@ -190,7 +190,7 @@ ), Game( version: "0.5.0", - flags: [IgnoreScore], + flags: [Interval(2), IgnoreScore], periods: [ Period( start: First, @@ -344,7 +344,7 @@ ), Game( version: "0.5.0", - flags: [], + flags: [Interval(2)], periods: [ Period( start: First, @@ -557,7 +557,7 @@ ), Game( version: "0.5.0", - flags: [], + flags: [Interval(2)], periods: [ Period( start: First, @@ -767,7 +767,7 @@ ), Game( version: "0.5.0", - flags: [], + flags: [Interval(2)], periods: [ Period( start: First, @@ -994,7 +994,7 @@ // TexasAnM were opponents, but not recorded as // they were not present; Miller played in place. version: "0.5.0", - flags: [IgnoreTeam(TexasAnM)], + flags: [Interval(2), IgnoreTeam(TexasAnM)], periods: [ Period( start: First, diff --git a/gamelog/Cargo.lock b/gamelog/Cargo.lock index b1bfb5c..362722b 100644 --- a/gamelog/Cargo.lock +++ b/gamelog/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "gamelog" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ron", "semver", diff --git a/gamelog/Cargo.toml b/gamelog/Cargo.toml index 9bc0a05..f0ecc0c 100644 --- a/gamelog/Cargo.toml +++ b/gamelog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gamelog" -version = "0.5.0" +version = "0.5.1" edition = "2024" [dependencies] diff --git a/gamelog/src/game.rs b/gamelog/src/game.rs index efea30a..1c085c3 100644 --- a/gamelog/src/game.rs +++ b/gamelog/src/game.rs @@ -168,8 +168,10 @@ impl Game { #[derive(Debug, Deserialize, Clone, PartialEq)] pub enum Flags { + IgnoreActions, IgnoreTeam(Team), IgnoreScore, + Interval(u8), } #[cfg(test)] diff --git a/gamelog/src/period.rs b/gamelog/src/period.rs index 654d878..3932d23 100644 --- a/gamelog/src/period.rs +++ b/gamelog/src/period.rs @@ -19,7 +19,7 @@ impl Period { let mut record: bool = true; let assume_team_known = assume_team_known.unwrap_or(false); - for event in self.events.iter() { + self.events.iter().for_each(|event| { if let Event::Kickoff(_) | Event::Turnover(_) = event { record = { if team == event.team().unwrap() { @@ -42,7 +42,7 @@ impl Period { if record { events.push(event.to_owned()); } - } + }); // If already handled or assumption override applicable if !first || (first && assume_team_known) { @@ -115,11 +115,7 @@ impl Period { } pub fn is_overtime(&self) -> bool { - if self.start.is_overtime() || self.end.as_ref().is_some_and(|some| some.is_overtime()) { - true - } else { - false - } + self.start.is_overtime() || self.end.as_ref().is_some_and(|some| some.is_overtime()) } } diff --git a/miller/Cargo.lock b/miller/Cargo.lock index 3d598a4..2fb65ea 100644 --- a/miller/Cargo.lock +++ b/miller/Cargo.lock @@ -64,7 +64,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "gamelog" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ron", "semver", diff --git a/miller/src/main.rs b/miller/src/main.rs index 58667aa..461bd4c 100644 --- a/miller/src/main.rs +++ b/miller/src/main.rs @@ -48,50 +48,49 @@ fn main() { // Work on knocking down the nesting here? for game in log.0.iter() { - if let Ok(teams) = game.teams() { - for team in teams { - if !game.flags.contains(&Flags::IgnoreTeam(team.to_owned())) { - // Team is to have their stats recorded this game of file. - let team_idx = stats - .iter() - .position(|stat| { - if stat.team == team.to_owned() { - true - } else { - false - } - }) - .unwrap(); + let teams = match game.teams() { + Ok(teams) => teams, + Err(_) => continue, + }; - stats[team_idx] - .avg_terrain_gain - .push(game.avg_gain(team.to_owned())); - - stats[team_idx] - .avg_terrain_loss - .push(game.avg_loss(team.to_owned())); - - stats[team_idx] - .avg_terrain_delta - .push(game.avg_delta(team.to_owned())); - - stats[team_idx] - .plays_per_quarter - .push(game.avg_plays_per_quarter(team.to_owned())); - - stats[team_idx] - .plays_per_game - .push(game.team_plays(team.to_owned())); - - stats[team_idx] - .penalties_per_game - .push(game.penalties(team.to_owned())); - } + for team in teams { + // Skip team if they are to be ignored this game. + if game.flags.contains(&Flags::IgnoreTeam(team.to_owned())) { + continue; } + + let team_idx = stats + .iter() + .position(|stat| stat.team == team.to_owned()) + .unwrap(); + + stats[team_idx] + .avg_terrain_gain + .push(game.avg_gain(team.to_owned())); + + stats[team_idx] + .avg_terrain_loss + .push(game.avg_loss(team.to_owned())); + + stats[team_idx] + .avg_terrain_delta + .push(game.avg_delta(team.to_owned())); + + stats[team_idx] + .plays_per_quarter + .push(game.avg_plays_per_quarter(team.to_owned())); + + stats[team_idx] + .plays_per_game + .push(game.team_plays(team.to_owned())); + + stats[team_idx] + .penalties_per_game + .push(game.penalties(team.to_owned())); } } - if dbg!(config.display_results) { + if config.display_results { // :#? for pretty-printing. stats.iter().for_each(|team| println!("{:#?}", team)); }