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'
});
// optional more indices
LogTransportSchema.index({war: 1});
LogTransportSchema.index({war: 1, driver: 1});
module.exports = mongoose.model('LogTransport', LogTransportSchema);

View File

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

View File

@ -20,10 +20,11 @@ const parseWarLog = (lineArray, war) => {
players: []
};
const addPlayerIfNotExists = (inputPlayer) => {
const addPlayerIfNotExists = (inputPlayer, steamUUID) => {
const player = getPlayerAndFractionFromString(inputPlayer);
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) {
player['warId'] = war._id;
player['steamUUID'] = steamUUID;
stats.players.push(player);
}
};
@ -171,7 +172,8 @@ const parseWarLog = (lineArray, war) => {
*/
else if (line.includes('(Fraktionsuebersicht)')) {
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)
}
});