save steamUUID for player
parent
46642aea4d
commit
fc0bf18b03
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue