diff options
| -rw-r--r-- | crunch_team.sql | 2 | ||||
| -rw-r--r-- | worker.js | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/crunch_team.sql b/crunch_team.sql index a11cc33..3d55e25 100644 --- a/crunch_team.sql +++ b/crunch_team.sql @@ -31,7 +31,7 @@ JOIN ( JOIN team t ON tm.team_id = t.id JOIN roster r ON p.roster_api_id = r.api_id JOIN `match` m ON r.match_api_id = m.api_id - WHERE t.id IN (:team_ids) + WHERE t.id = :team_id GROUP BY t.id, m.api_id, r.id ) AS cnt_by_m JOIN participant p ON p.match_api_id = cnt_by_m.m_api_id @@ -118,11 +118,14 @@ if (LOGGLY_TOKEN) replacements: { participant_api_ids: api_ids_global }, type: seq.QueryTypes.UPSERT }); - if (team_ids.length > 0) - await seq.query(team_script, { - replacements: { team_ids: team_ids }, - type: seq.QueryTypes.UPDATE - }); + if (team_ids.length > 0) { + await Promise.each(team_ids, async (tid) => + await seq.query(team_script, { + replacements: { team_id: tid }, + type: seq.QueryTypes.UPDATE + }) + ); + } if (api_ids_player.length > 0) await seq.query(player_script, { replacements: { participant_api_ids: api_ids_player }, |
