NAME
Sport::Analytics::NHL::Tools - Commonly used routines that are system-dependent
SYNOPSIS
Commonly used routines that are specific to the Sport::Analytics::NHL ecosystem. For the independent stuff see Sport::Analytics::NHL::Util .
use Sport::Analytics::NHL::Tools;
my $game = parse_nhl_game_id(2011020001);
my $season = get_season_from_date(20110202); # returns 2010
my $team = resolve('NY Rangers'); # returns NYR
#and so on
Provides global variable $DB that can be used to store the MongoDB handle.
FUNCTIONS
parse_nhl_game_id
-
Parses the SSSSTTNNNN nhl id Arguments: the nhl game id Returns: hashref with season, stage, season id and our SSSSTNNNN id
parse_our_game_id
-
Parses the SSSSTNNNN our id Arguments: our game id Returns: hashref with season, stage, season id and our SSSSTNNNN id
get_season_from_date
-
Figures out the NHL season (start year) the given YYYYMMDD date refers to Arguments: the YYYYMMDD date Returns: the YYYY or YYYY-1 season
get_schedule_json_file
-
Returns the path to the schedule file in the filesystem Arguments: the season and the root of the data (optional) Returns: the path to the schedule file
resolve_team
-
Attempts to resolve the name of a team to the normalized 3-letter id Arguments: the name of a team, optional no-db force flag Returns: the 3-letter normalized id
convert_new_schedule_game
-
Converts a game record obtained from the 'live' interface to a normalized form
Arguments: the game record Returns: the normalized game
arrange_new_schedule_by_date
-
Arranges the schedule obtained from the 'live' interface by dates
Arguments: the schedule Returns: hashref with keys of dates, values of lists of normalized game records
convert_old_schedule_game
-
Converts a game record obtained from the API interface to a normalized form
Arguments: the game record Returns: the normalized game
arrange_old_schedule_by_date
-
Arranges the schedule obtained from the API interface by dates
Arguments: the schedule Returns: hashref with keys of dates, values of lists of normalized game records
convert_schedule_game
-
Converts a game record obtained scraping the schedules to a normalized form
Arguments: the game record Returns: the normalized game
arrange_schedule_by_date
-
Arranges the schedule obtained by the scraper by dates
Arguments: the schedule Returns: hashref with keys of dates, values of lists of normalized game records
get_games_for_dates_from_db
-
Gets the list of the games scheduled for given dates using the file storage
Arguments: the list of dates Returns: the list of normalized game records
get_games_for_dates_from_fs
-
Gets the list of the games scheduled for given dates using the database
Arguments: the list of dates Returns: the list of normalized game records
get_games_for_dates
-
Gets the list of the games scheduled for given dates
Arguments: the list of dates Returns: the list of normalized game records
get_start_stop_date
-
Gets the earliest possible start and latest possible end for a season in format YYYY-MM-DD
Arguments: the season Returns: (YYYY-09-02,YYYY+1-09-01)
make_game_path
-
Creates and/or returns the game path for a given season, stage, season_id
Arguments: season, stage, season_id, root storage dir (optional) Returns: the storage path (created if necessary)
read_schedules
-
Reads the existing schedules for the given range of seasons
Arguments: the hashref with first and last season of the range Returns: the schedule data, hashref by season
get_game_id_from_path
-
Given the game path, produces our SSSSTNNNN game id
Arguments: the game path Returns the SSSSTNNNN id, or undef if the matching of the path failed
read_existing_game_ids
-
Find games already scraped into the filesystem and returns the game ids of them.
Arguments: the season to look for Returns: hashref of game ids as keys and 1s as values
AUTHOR
More Hockey Stats, <contact at morehockeystats.com>
BUGS
Please report any bugs or feature requests to contact at morehockeystats.com
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sport::Analytics::NHL::Tools. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Sport::Analytics::NHL::Tools
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Sport::Analytics::NHL::Tools
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN