Add interval flag (doesn't currently do anything) and debate future
visualization.
This commit is contained in:
10
README.adoc
10
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
|
||||
|
||||
12
gamelog.ron
12
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,
|
||||
|
||||
2
gamelog/Cargo.lock
generated
2
gamelog/Cargo.lock
generated
@@ -19,7 +19,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gamelog"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"ron",
|
||||
"semver",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gamelog"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -168,8 +168,10 @@ impl Game {
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
||||
pub enum Flags {
|
||||
IgnoreActions,
|
||||
IgnoreTeam(Team),
|
||||
IgnoreScore,
|
||||
Interval(u8),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
miller/Cargo.lock
generated
2
miller/Cargo.lock
generated
@@ -64,7 +64,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "gamelog"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"ron",
|
||||
"semver",
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user