{"size": 786, "ext": "js", "max_stars_repo_path": "server/models/seasons.js", "max_stars_repo_name": "Arshavin86/NBA_MVP_LADDER", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/models/seasons.js", "max_issues_repo_name": "Arshavin86/NBA_MVP_LADDER", "max_issues_repo_issues_event_min_datetime": "2019-10-25T20:16:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-12T00:46:34.000Z", "max_forks_repo_path": "server/models/seasons.js", "max_forks_repo_name": "Arshavin86/NBA_MVP_LADDER", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 34.1739130435, "max_line_length": 172, "alphanum_fraction": 0.6501272265}
const { db } = require('../../database/db')

module.exports = {
  getSeasons
}

async function getSeasons ({ queryArray, year }) {
  try {
    // check if we need playOffs or regular season
    if (queryArray[0][0] === 'p') {
      const qr = 'SELECT firstName, lastName, teamID, awards, pos, position FROM player INNER JOIN playOff$1 ON player.playerID = playOff$1.playerID ORDER BY position ASC;'
      const list = await db.query(qr, [year])
      return list
    } else {
      const qr = 'SELECT firstName, lastName, teamID, awards, pos, position FROM player INNER JOIN season$1 ON player.playerID = season$1.playerID ORDER BY position ASC;'
      const list = await db.query(qr, [year])
      return list
    }
  } catch (e) {
    console.error('getSeasons is failed: ', e)
  }
}
