2020-11-07 18:10:19 +00:00
|
|
|
const { Model } = require('flitter-orm')
|
2020-11-08 00:05:26 +00:00
|
|
|
/**
|
|
|
|
* WeeklyPlayerStat model
|
|
|
|
* -----------------------------------------------------------------------
|
2020-11-08 18:34:50 +00:00
|
|
|
* A record containing the statistics for a single player for a single week.
|
|
|
|
*
|
|
|
|
* @extends Model
|
2020-11-08 00:05:26 +00:00
|
|
|
*/
|
2020-11-07 18:10:19 +00:00
|
|
|
class WeeklyPlayerStat extends Model {
|
|
|
|
static get services() {
|
|
|
|
return [...super.services, 'models']
|
|
|
|
}
|
|
|
|
|
2020-11-08 00:05:26 +00:00
|
|
|
/**
|
|
|
|
* defines the schema of the particular model
|
|
|
|
*/
|
2020-11-07 18:10:19 +00:00
|
|
|
static get schema() {
|
|
|
|
return {
|
|
|
|
player_id: String,
|
|
|
|
week_num: Number,
|
|
|
|
patch_player_id: String,
|
|
|
|
fantasy_points: Number,
|
2020-11-07 19:31:00 +00:00
|
|
|
|
|
|
|
passing_attempts: Number,
|
|
|
|
passing_completions: Number,
|
|
|
|
passing_yards: Number,
|
|
|
|
fumbles: Number,
|
|
|
|
kick_returns: Number,
|
|
|
|
sacks: Number,
|
2020-11-07 18:10:19 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-07 22:14:00 +00:00
|
|
|
|
2020-11-08 00:05:26 +00:00
|
|
|
/**
|
2020-11-08 18:34:50 +00:00
|
|
|
* Cast the stats to a format expected by the API.
|
|
|
|
* @return Promise<object>
|
2020-11-08 00:05:26 +00:00
|
|
|
*/
|
2020-11-07 22:14:00 +00:00
|
|
|
async to_api() {
|
|
|
|
return {
|
|
|
|
'Passing Attempts': this.passing_attempts,
|
|
|
|
'Passing Completions': this.passing_completions,
|
|
|
|
'Passing Yards': this.passing_yards,
|
|
|
|
'Fumbles': this.fumbles,
|
|
|
|
'Kick Returns': this.kick_returns,
|
|
|
|
'Sacks': this.sacks,
|
|
|
|
}
|
|
|
|
}
|
2020-11-07 18:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = WeeklyPlayerStat
|