pub struct FanduelData { /* private fields */ }Expand description
A handle for parsing and storing FanDuel salary data in SQLite.
Clone values share the same underlying database connection pool.
Implementations§
Source§impl FanduelData
impl FanduelData
Sourcepub async fn connect(database_url: &str) -> Result<Self, FanduelDataError>
pub async fn connect(database_url: &str) -> Result<Self, FanduelDataError>
Connect, creating the database and applying this crate’s migrations if needed. Migration applies are idempotent.
Sourcepub async fn in_memory() -> Result<Self, FanduelDataError>
pub async fn in_memory() -> Result<Self, FanduelDataError>
Create an empty in-memory database and apply all migrations.
This constructor is primarily intended for tests.
Sourcepub fn parse_fanduel_csv(
&self,
season_week: SeasonWeek,
csv_data: &[u8],
) -> Result<Vec<SalariedPlayer>, FanduelDataError>
pub fn parse_fanduel_csv( &self, season_week: SeasonWeek, csv_data: &[u8], ) -> Result<Vec<SalariedPlayer>, FanduelDataError>
Parse a FanDuel salary CSV into typed records without saving them.
The season week must be provided because the CSV does not identify the NFL week it
represents. Review or modify the returned records before passing them to
save_salaried_players.
Sourcepub async fn save_salaried_players(
&self,
salaries: &[SalariedPlayer],
) -> Result<(), FanduelDataError>
pub async fn save_salaried_players( &self, salaries: &[SalariedPlayer], ) -> Result<(), FanduelDataError>
Save salary records to the database, typically after parsing them with
parse_fanduel_csv.
Existing records for the same player and game (or defense team and game) are updated, making repeated imports safe. The entire slice is saved as one transaction.
Sourcepub async fn weekly_salary_counts(
&self,
) -> Result<BTreeMap<SeasonWeek, usize>, FanduelDataError>
pub async fn weekly_salary_counts( &self, ) -> Result<BTreeMap<SeasonWeek, usize>, FanduelDataError>
Count all salary entries for each season week present in the database.
Weeks with no entries are omitted.
Sourcepub async fn weekly_unmatched_counts(
&self,
matched_ids: &[u32],
) -> Result<BTreeMap<SeasonWeek, usize>, FanduelDataError>
pub async fn weekly_unmatched_counts( &self, matched_ids: &[u32], ) -> Result<BTreeMap<SeasonWeek, usize>, FanduelDataError>
Count unmatched player salary entries by season week.
matched_ids lists player IDs that have been matched elsewhere. Defense (DST) entries
are excluded, and weeks with no unmatched players are omitted.
Sourcepub async fn salaried_players_for(
&self,
season_week: SeasonWeek,
) -> Result<Vec<SalariedPlayer>, FanduelDataError>
pub async fn salaried_players_for( &self, season_week: SeasonWeek, ) -> Result<Vec<SalariedPlayer>, FanduelDataError>
Return all player and defense salary entries for a season week.
Returns an empty vector when the database has no entries for that week.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FanduelData
impl !UnwindSafe for FanduelData
impl Freeze for FanduelData
impl Send for FanduelData
impl Sync for FanduelData
impl Unpin for FanduelData
impl UnsafeUnpin for FanduelData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more