From 37c16ecf9fd64fc7644e82d8619584d0f64d694e Mon Sep 17 00:00:00 2001 From: Kapil Viren Ahuja Date: Thu, 30 Mar 2017 21:34:58 +0530 Subject: Pushed shard_id to all the tables as shard + api_id is the unique combination --- models/participant.js | 4 ++++ models/player.js | 2 +- models/roster.js | 4 ++++ worker.js | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/models/participant.js b/models/participant.js index efcb7dd..d48874b 100644 --- a/models/participant.js +++ b/models/participant.js @@ -13,6 +13,10 @@ module.exports = function(sequelize, DataTypes) { allowNull: false, unique: true }, + shard_id: { + type: DataTypes.STRING(191), + allowNull: false + }, player_api_id: { type: DataTypes.STRING(191), allowNull: false diff --git a/models/player.js b/models/player.js index 4f24f56..af56432 100644 --- a/models/player.js +++ b/models/player.js @@ -23,7 +23,7 @@ module.exports = function(sequelize, DataTypes) { }, shard_id: { type: DataTypes.STRING(191), - allowNull: true + allowNull: false }, last_match_created_date: { type: DataTypes.TIME, diff --git a/models/roster.js b/models/roster.js index 5966e3a..f196f0f 100644 --- a/models/roster.js +++ b/models/roster.js @@ -17,6 +17,10 @@ module.exports = function(sequelize, DataTypes) { allowNull: false, unique: true }, + shard_id: { + type: DataTypes.STRING(191), + allowNull: false + }, aces_earned: { type: DataTypes.INTEGER(11), allowNull: false diff --git a/worker.js b/worker.js index a563562..3c51624 100644 --- a/worker.js +++ b/worker.js @@ -60,13 +60,18 @@ var RABBITMQ_URI = process.env.RABBITMQ_URI || "amqp://localhost", await match.rosters.forEach(async (roster) => { roster.match_api_id = match.api_id; + roster.shard_id = match.shard_id; await model.Roster.upsert(roster, { include: [ model.Participant/*, model.Team*/ ] }); await roster.participants.forEach(async (participant) => { + participant.shard_id = roster.shard_id; + participant.player.shard_id = participant.shard_id; + await model.Player.upsert(participant.player); + participant.roster_api_id = roster.api_id; participant.player_api_id = participant.player.api_id; await model.Participant.upsert(participant, { -- cgit v1.3.1