commenting
added JSDoc style comments to the backend
This commit is contained in:
parent
cd2f9ed3ef
commit
12ff8c680f
@ -1,10 +1,21 @@
|
|||||||
const { Controller } = require('libflitter')
|
const { Controller } = require('libflitter')
|
||||||
|
/**
|
||||||
|
* DraftBoard controller
|
||||||
|
* @extends Controller
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
class DraftBoard extends Controller {
|
class DraftBoard extends Controller {
|
||||||
static get services() {
|
static get services() {
|
||||||
return [...super.services, 'models']
|
return [...super.services, 'models']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the API data containing the players available to draft
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param next
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async get_available_players(req, res, next) {
|
async get_available_players(req, res, next) {
|
||||||
const Player = this.models.get('Player')
|
const Player = this.models.get('Player')
|
||||||
const players = await Player.get_unobligated_players()
|
const players = await Player.get_unobligated_players()
|
||||||
@ -17,6 +28,13 @@ class DraftBoard extends Controller {
|
|||||||
return res.api(api_data)
|
return res.api(api_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds the selected player to the team
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param next
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async draft_player_to_team(req, res, next) {
|
async draft_player_to_team(req, res, next) {
|
||||||
if ( !req.body.player_id ) {
|
if ( !req.body.player_id ) {
|
||||||
return res.status(400)
|
return res.status(400)
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
const { Controller } = require('libflitter')
|
const { Controller } = require('libflitter')
|
||||||
|
/**
|
||||||
|
* ScoresController
|
||||||
|
* @extends Controller
|
||||||
|
* ----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
class ScoresController extends Controller {
|
class ScoresController extends Controller {
|
||||||
static get services() {
|
static get services() {
|
||||||
return [...super.services, 'models', 'sports_data']
|
return [...super.services, 'models', 'sports_data']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the weekly scores
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param next
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
async get_weekly_scores(req, res, next) {
|
async get_weekly_scores(req, res, next) {
|
||||||
const Matchup = this.models.get('Matchup')
|
const Matchup = this.models.get('Matchup')
|
||||||
|
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
const { Model } = require('flitter-orm')
|
const { Model } = require('flitter-orm')
|
||||||
|
/**
|
||||||
|
* Matchup
|
||||||
|
* @extends Model
|
||||||
|
* ---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
class Matchup extends Model {
|
class Matchup extends Model {
|
||||||
static get services() {
|
static get services() {
|
||||||
return [...super.services, 'models']
|
return [...super.services, 'models']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* define the schema of the model
|
||||||
|
*/
|
||||||
static get schema() {
|
static get schema() {
|
||||||
return {
|
return {
|
||||||
home_team_id: String,
|
home_team_id: String,
|
||||||
@ -16,16 +23,25 @@ class Matchup extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the data of the home team
|
||||||
|
*/
|
||||||
async home_team() {
|
async home_team() {
|
||||||
const Team = this.models.get('Team')
|
const Team = this.models.get('Team')
|
||||||
return Team.findById(this.home_team_id)
|
return Team.findById(this.home_team_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the data of the visitor team
|
||||||
|
*/
|
||||||
async visitor_team() {
|
async visitor_team() {
|
||||||
const Team = this.models.get('Team')
|
const Team = this.models.get('Team')
|
||||||
return Team.findById(this.visitor_team_id)
|
return Team.findById(this.visitor_team_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the API's data
|
||||||
|
*/
|
||||||
async to_api() {
|
async to_api() {
|
||||||
const home_team = await this.home_team()
|
const home_team = await this.home_team()
|
||||||
const visitor_team = await this.visitor_team()
|
const visitor_team = await this.visitor_team()
|
||||||
|
@ -67,6 +67,9 @@ class Player extends Model {
|
|||||||
return new this(model_data)
|
return new this(model_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the id's of the unobligated players
|
||||||
|
*/
|
||||||
static async get_unobligated_players() {
|
static async get_unobligated_players() {
|
||||||
const Team = this.prototype.models.get('Team')
|
const Team = this.prototype.models.get('Team')
|
||||||
let obligated_player_ids = []
|
let obligated_player_ids = []
|
||||||
@ -83,11 +86,20 @@ class Player extends Model {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param week_num
|
||||||
|
* @returns the points scored of that week
|
||||||
|
*/
|
||||||
async points_for_week(week_num) {
|
async points_for_week(week_num) {
|
||||||
const WeeklyPlayerStat = this.models.get('WeeklyPlayerStat')
|
const WeeklyPlayerStat = this.models.get('WeeklyPlayerStat')
|
||||||
return WeeklyPlayerStat.findOne({ week_num, player_id: this.id })
|
return WeeklyPlayerStat.findOne({ week_num, player_id: this.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns true if the player is obligated
|
||||||
|
* @returns false if the player is not obligates
|
||||||
|
*/
|
||||||
async is_obligated() {
|
async is_obligated() {
|
||||||
const Team = this.models.get('Team')
|
const Team = this.models.get('Team')
|
||||||
const teams = await Team.find()
|
const teams = await Team.find()
|
||||||
@ -98,6 +110,11 @@ class Player extends Model {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param with_stats
|
||||||
|
* @returns updates the API's data
|
||||||
|
*/
|
||||||
async to_api(with_stats = false) {
|
async to_api(with_stats = false) {
|
||||||
const stat = with_stats ? await this.points_for_week() : undefined
|
const stat = with_stats ? await this.points_for_week() : undefined
|
||||||
|
|
||||||
|
@ -50,11 +50,17 @@ class Team extends Model {
|
|||||||
return new_team
|
return new_team
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the lineup
|
||||||
|
*/
|
||||||
async lineup() {
|
async lineup() {
|
||||||
const Lineup = this.models.get('Lineup')
|
const Lineup = this.models.get('Lineup')
|
||||||
return Lineup.get_and_update_for_team(this)
|
return Lineup.get_and_update_for_team(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
async players() {
|
async players() {
|
||||||
const Player = this.models.get('Player')
|
const Player = this.models.get('Player')
|
||||||
return Player.find({
|
return Player.find({
|
||||||
@ -64,6 +70,9 @@ class Team extends Model {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the API's data
|
||||||
|
*/
|
||||||
async to_api() {
|
async to_api() {
|
||||||
const User = this.models.get('auth:User')
|
const User = this.models.get('auth:User')
|
||||||
|
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
const { Model } = require('flitter-orm')
|
const { Model } = require('flitter-orm')
|
||||||
|
/**
|
||||||
|
* WeeklyPlayerStat model
|
||||||
|
* @extends Model
|
||||||
|
* -----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
class WeeklyPlayerStat extends Model {
|
class WeeklyPlayerStat extends Model {
|
||||||
static get services() {
|
static get services() {
|
||||||
return [...super.services, 'models']
|
return [...super.services, 'models']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defines the schema of the particular model
|
||||||
|
*/
|
||||||
static get schema() {
|
static get schema() {
|
||||||
return {
|
return {
|
||||||
player_id: String,
|
player_id: String,
|
||||||
@ -21,6 +28,9 @@ class WeeklyPlayerStat extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the API's data
|
||||||
|
*/
|
||||||
async to_api() {
|
async to_api() {
|
||||||
return {
|
return {
|
||||||
'Passing Attempts': this.passing_attempts,
|
'Passing Attempts': this.passing_attempts,
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
const { Model } = require('flitter-orm')
|
const { Model } = require('flitter-orm')
|
||||||
|
/**
|
||||||
|
* Weekly Team Stat model
|
||||||
|
* @extends Model
|
||||||
|
* ---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
class WeeklyTeamStat extends Model {
|
class WeeklyTeamStat extends Model {
|
||||||
static get services() {
|
static get services() {
|
||||||
return [...super.services, 'models']
|
return [...super.services, 'models']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defines the schema of the particular model
|
||||||
|
*/
|
||||||
static get schema() {
|
static get schema() {
|
||||||
return {
|
return {
|
||||||
team_id: String,
|
team_id: String,
|
||||||
|
Loading…
Reference in New Issue
Block a user