clean up the game detail page.
This commit is contained in:
@@ -91,9 +91,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => {
|
||||
picks.forEach((character, characterNum) => {
|
||||
const role = character.dataValues.role
|
||||
// Count role application
|
||||
pickedCharacterCount.set(
|
||||
role, (pickedCharacterCount.get(role) || 0) + 1
|
||||
)
|
||||
pickedCharacterCount.set(role, (pickedCharacterCount.get(role) || 0) + 1)
|
||||
})
|
||||
|
||||
appls.forEach((character, characterNum) => {
|
||||
@@ -105,9 +103,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => {
|
||||
}
|
||||
activeCharacters.get(role).add(charId)
|
||||
// Count role application
|
||||
appedCharacterCount.set(
|
||||
role, (appedCharacterCount.get(role) || 0) + 1
|
||||
)
|
||||
appedCharacterCount.set(role, (appedCharacterCount.get(role) || 0) + 1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -130,7 +126,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => {
|
||||
result[roleName] = {
|
||||
apps: appedCharacterCount.get(roleName) || 0,
|
||||
picks: pickedCharacterCount.get(roleName) || 0,
|
||||
active: activeCharacters.has(roleName) ?activeCharacters.get(roleName).size : 0
|
||||
active: activeCharacters.has(roleName) ? activeCharacters.get(roleName).size : 0
|
||||
}
|
||||
})
|
||||
|
||||
@@ -195,7 +191,10 @@ app.get('/api/game/:gameId', async (req, res) => {
|
||||
})
|
||||
|
||||
app.post('/api/game/:gameId/apps', async (req, res) => {
|
||||
const apps = await App.findAll({ where: { gameId: req.params['gameId'] } })
|
||||
const apps = await App.findAll({
|
||||
include: [{ model: Character, as: 'appliedCharacter' }],
|
||||
where: { gameId: req.params['gameId'] }
|
||||
})
|
||||
res.send(apps)
|
||||
})
|
||||
|
||||
@@ -205,7 +204,10 @@ app.post('/api/character/:characterId/apps', async (req, res) => {
|
||||
})
|
||||
|
||||
app.post('/api/game/:gameId/picks', async (req, res) => {
|
||||
const picks = await Pick.findAll({ where: { gameId: req.params['gameId'] } })
|
||||
const picks = await Pick.findAll({
|
||||
include: [{ model: Character, as: 'pickedCharacter' }],
|
||||
where: { gameId: req.params['gameId'] }
|
||||
})
|
||||
res.send(picks)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user