From bdd943d422fefbec529b5309cb587e63b41d7f46 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sun, 21 Nov 2021 16:30:36 -0700 Subject: [PATCH] Move gender constants into genders.js file in database directory --- constants/genders.js | 8 -------- database/scores/divisions.js | 4 ++-- database/scores/genders.js | 22 ++++++++++++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 constants/genders.js diff --git a/constants/genders.js b/constants/genders.js deleted file mode 100644 index 402d58f..0000000 --- a/constants/genders.js +++ /dev/null @@ -1,8 +0,0 @@ -class Gender { - constructor(name) { - this.name = name; - } -} - -exports.male = new Gender("male"); -exports.female = new Gender("female"); \ No newline at end of file diff --git a/database/scores/divisions.js b/database/scores/divisions.js index b04d6a5..38fa8be 100644 --- a/database/scores/divisions.js +++ b/database/scores/divisions.js @@ -1,5 +1,5 @@ const database = require('./../database'); -const genders = require('../../constants/genders'); +const genders = require('./genders'); @@ -15,7 +15,7 @@ class Division { function getGenderID(gender) { - return (gender == genders.male) ? "M" : "F"; + return (gender == genders.MALE) ? "M" : "F"; } diff --git a/database/scores/genders.js b/database/scores/genders.js index 27e811e..126e57b 100644 --- a/database/scores/genders.js +++ b/database/scores/genders.js @@ -1,10 +1,19 @@ const database = require('./../database'); -const genders = require('../../constants/genders'); +class Gender { + constructor(name) { + this.name = name; + } +} +const MALE = new Gender("male"); +const FEMALE = new Gender("female"); + + + async function retrieveBySport(sportID) { const query = `SELECT gender from scores.divisions @@ -17,16 +26,16 @@ async function retrieveBySport(sportID) { return gendersList; } if(table.length == 2) { - gendersList.push(genders.female); - gendersList.push(genders.male); + gendersList.push(genders.FEMALE); + gendersList.push(genders.MALE); return gendersList; } else if(table[0][0] = "F") { - gendersList.push(genders.female); + gendersList.push(genders.FEMALE); return gendersList; } else if(table[0][0] = "M") { - gendersList.push(genders.male); + gendersList.push(genders.MALE); return gendersList; } } @@ -34,5 +43,6 @@ async function retrieveBySport(sportID) { - +exports.MALE = MALE; +exports.FEMALE = FEMALE; exports.retrieveBySport = retrieveBySport; \ No newline at end of file