save steamUUID for player

pull/29/head
HardiReady 2018-02-26 09:33:28 +01:00
parent 46642aea4d
commit fc0bf18b03
3 changed files with 11 additions and 4 deletions

View File

@ -36,6 +36,6 @@ const LogTransportSchema = new Schema({
collection: 'logTransport' collection: 'logTransport'
}); });
// optional more indices // optional more indices
LogTransportSchema.index({war: 1}); LogTransportSchema.index({war: 1, driver: 1});
module.exports = mongoose.model('LogTransport', LogTransportSchema); module.exports = mongoose.model('LogTransport', LogTransportSchema);

View File

@ -58,12 +58,17 @@ const PlayerSchema = new Schema({
type: Number, type: Number,
get: v => Math.round(v), get: v => Math.round(v),
set: v => Math.round(v) set: v => Math.round(v)
},
steamUUID: {
type: Number,
get: v => Math.round(v),
set: v => Math.round(v)
} }
}, { }, {
collection: 'player', collection: 'player',
timestamps: {createdAt: 'timestamp'} timestamps: {createdAt: 'timestamp'}
}); });
// optional more indices // optional more indices
PlayerSchema.index({timestamp: 1}); PlayerSchema.index({warId: 1});
module.exports = mongoose.model('Player', PlayerSchema); module.exports = mongoose.model('Player', PlayerSchema);

View File

@ -20,10 +20,11 @@ const parseWarLog = (lineArray, war) => {
players: [] players: []
}; };
const addPlayerIfNotExists = (inputPlayer) => { const addPlayerIfNotExists = (inputPlayer, steamUUID) => {
const player = getPlayerAndFractionFromString(inputPlayer); const player = getPlayerAndFractionFromString(inputPlayer);
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) { if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) {
player['warId'] = war._id; player['warId'] = war._id;
player['steamUUID'] = steamUUID;
stats.players.push(player); stats.players.push(player);
} }
}; };
@ -171,7 +172,8 @@ const parseWarLog = (lineArray, war) => {
*/ */
else if (line.includes('(Fraktionsuebersicht)')) { else if (line.includes('(Fraktionsuebersicht)')) {
const playerString = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(', PUID')); const playerString = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(', PUID'));
addPlayerIfNotExists(playerString) const playerUUID = line.substring(line.lastIndexOf('PUID ') + 5, line.lastIndexOf('"'));
addPlayerIfNotExists(playerString, playerUUID)
} }
}); });