Update loader, add event and fix count to api
This commit is contained in:
@@ -36,6 +36,8 @@ app.post('/api/serverstats/gamestats', jsonParser, async (req, res) => {
|
|||||||
'SUM(CASE WHEN status = "Complete" THEN 1 ELSE 0 END) as Complete, ' +
|
'SUM(CASE WHEN status = "Complete" THEN 1 ELSE 0 END) as Complete, ' +
|
||||||
'SUM(CASE WHEN status = "Postponed" THEN 1 ELSE 0 END) as Postponed, ' +
|
'SUM(CASE WHEN status = "Postponed" THEN 1 ELSE 0 END) as Postponed, ' +
|
||||||
'SUM(CASE WHEN status = "Pending" THEN 1 ELSE 0 END) as Pending, ' +
|
'SUM(CASE WHEN status = "Pending" THEN 1 ELSE 0 END) as Pending, ' +
|
||||||
|
'SUM(event) as Events, ' +
|
||||||
|
'SUM(fix) as Fixes, ' +
|
||||||
'SUM(payoutEB) as TotalEB, ' +
|
'SUM(payoutEB) as TotalEB, ' +
|
||||||
'SUM(payoutIP) as TotalIP, ' +
|
'SUM(payoutIP) as TotalIP, ' +
|
||||||
'SUM(payoutEB) / SUM(CASE WHEN status = "Complete" THEN 1 ELSE 0 END) as AverageEB, ' +
|
'SUM(payoutEB) / SUM(CASE WHEN status = "Complete" THEN 1 ELSE 0 END) as AverageEB, ' +
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const Game = database.define(
|
|||||||
gamemaster: { type: DataTypes.TEXT },
|
gamemaster: { type: DataTypes.TEXT },
|
||||||
payoutEB: { type: DataTypes.INTEGER },
|
payoutEB: { type: DataTypes.INTEGER },
|
||||||
payoutIP: { type: DataTypes.INTEGER },
|
payoutIP: { type: DataTypes.INTEGER },
|
||||||
payputLoot: { type: DataTypes.INTEGER }
|
payoutLoot: { type: DataTypes.INTEGER }
|
||||||
},
|
},
|
||||||
{ timestamps: false }
|
{ timestamps: false }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def extractGameFromRow(counter, row):
|
|||||||
row['Game Title'],
|
row['Game Title'],
|
||||||
row['Game Status'],
|
row['Game Status'],
|
||||||
row['Fix'],
|
row['Fix'],
|
||||||
0,
|
row['Event'],
|
||||||
int(datetime.strptime(row['Game Date'],'%d-%b-%Y').timestamp()) if row['Game Date'] else 0,
|
int(datetime.strptime(row['Game Date'],'%d-%b-%Y').timestamp()) if row['Game Date'] else 0,
|
||||||
row['GM'],
|
row['GM'],
|
||||||
row['Payout (EB)'],
|
row['Payout (EB)'],
|
||||||
@@ -88,7 +88,7 @@ def loadAppsAndPicks(characterNameToId, gameTitleToId, gameFileName):
|
|||||||
picks.append(Link(gameId, gameTitle, characterId, characterName))
|
picks.append(Link(gameId, gameTitle, characterId, characterName))
|
||||||
for i in range(1,51):
|
for i in range(1,51):
|
||||||
characterName = row['Applicant {}'.format(i)]
|
characterName = row['Applicant {}'.format(i)]
|
||||||
if characterName:
|
if characterName and characterName in characterNameToId:
|
||||||
characterId = characterNameToId[characterName]
|
characterId = characterNameToId[characterName]
|
||||||
apps.append(Link(gameId, gameTitle, characterId, characterName))
|
apps.append(Link(gameId, gameTitle, characterId, characterName))
|
||||||
|
|
||||||
@@ -103,11 +103,25 @@ def main():
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
for character in characters:
|
for character in characters:
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
REPLACE INTO Characters (characterName, id, playerName, role, creationDate, status)
|
REPLACE INTO Characters (characterName, id, playerName, role, creationDate, status)
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
""", [character.characterName, character.id, character.playerName, character.role, character.creationDate, character.status])
|
""", [character.characterName, character.id, character.playerName, character.role, character.creationDate, character.status])
|
||||||
|
for game in games:
|
||||||
|
cursor.execute("""
|
||||||
|
REPLACE INTO Games (id, title, status, fix, event, postdate, gamemaster, payoutEB, payoutIP, payoutLoot)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
""", [game.id, game.title, game.status, game.fix, game.event, game.postdate, game.gamemaster, game.payouteb, game.payoutip, game.payoutloot])
|
||||||
|
for app in apps:
|
||||||
|
cursor.execute("""
|
||||||
|
REPLACE INTO Apps (gameId, gameTitle, characterId, characterName)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
""", [app.gameId, app.gameTitle, app.characterId, app.characterName])
|
||||||
|
for pick in picks:
|
||||||
|
cursor.execute("""
|
||||||
|
REPLACE INTO Picks (gameId, gameTitle, characterId, characterName)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
""", [pick.gameId, pick.gameTitle, pick.characterId, pick.characterName])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user