Add player count for log parsing
parent
712071865f
commit
2538f1838a
|
@ -0,0 +1,34 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogPlayerCountSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
countBlufor: {
|
||||||
|
type: Number,
|
||||||
|
get: (v) => Math.round(v),
|
||||||
|
set: (v) => Math.round(v),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
countOpfor: {
|
||||||
|
type: Number,
|
||||||
|
get: (v) => Math.round(v),
|
||||||
|
set: (v) => Math.round(v),
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
collection: 'logPlayerCount',
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogPlayerCountSchema.index({war: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogPlayerCount', LogPlayerCountSchema);
|
|
@ -15,6 +15,7 @@ const LogVehicleModel = require('../models/logs/vehicle');
|
||||||
const LogTransportModel = require('../models/logs/transport');
|
const LogTransportModel = require('../models/logs/transport');
|
||||||
const LogFlagModel = require('../models/logs/flag');
|
const LogFlagModel = require('../models/logs/flag');
|
||||||
const LogPointsModel = require('../models/logs/points');
|
const LogPointsModel = require('../models/logs/points');
|
||||||
|
const LogPlayerCountModel = require('../models/logs/player-count');
|
||||||
|
|
||||||
const logsRouter = new express.Router();
|
const logsRouter = new express.Router();
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ logsRouter.route('/:warId')
|
||||||
const vehicleObjects = LogVehicleModel.find(filter, {}, sort);
|
const vehicleObjects = LogVehicleModel.find(filter, {}, sort);
|
||||||
const transportObjects = LogTransportModel.find(filter, {}, sort);
|
const transportObjects = LogTransportModel.find(filter, {}, sort);
|
||||||
const flagObjects = LogFlagModel.find(filter, {}, sort);
|
const flagObjects = LogFlagModel.find(filter, {}, sort);
|
||||||
|
const playerCountObjects = LogPlayerCountModel.find(filter, {}, sort);
|
||||||
const resources = {
|
const resources = {
|
||||||
points: pointsObjects.exec.bind(pointsObjects),
|
points: pointsObjects.exec.bind(pointsObjects),
|
||||||
budget: budgetObjects.exec.bind(budgetObjects),
|
budget: budgetObjects.exec.bind(budgetObjects),
|
||||||
|
@ -54,6 +56,7 @@ logsRouter.route('/:warId')
|
||||||
vehicle: killObjects.exec.bind(vehicleObjects),
|
vehicle: killObjects.exec.bind(vehicleObjects),
|
||||||
transport: transportObjects.exec.bind(transportObjects),
|
transport: transportObjects.exec.bind(transportObjects),
|
||||||
flag: flagObjects.exec.bind(flagObjects),
|
flag: flagObjects.exec.bind(flagObjects),
|
||||||
|
playerCount: playerCountObjects.exec.bind(playerCountObjects),
|
||||||
};
|
};
|
||||||
|
|
||||||
async.parallel(resources, (error, results) => {
|
async.parallel(resources, (error, results) => {
|
||||||
|
|
|
@ -33,6 +33,7 @@ const LogTransportModel = require('../models/logs/transport');
|
||||||
const LogFlagModel = require('../models/logs/flag');
|
const LogFlagModel = require('../models/logs/flag');
|
||||||
const LogBudgetModel = require('../models/logs/budget');
|
const LogBudgetModel = require('../models/logs/budget');
|
||||||
const LogPointsModel = require('../models/logs/points');
|
const LogPointsModel = require('../models/logs/points');
|
||||||
|
const LogPlayerCountModel = require('../models/logs/player-count');
|
||||||
|
|
||||||
// util
|
// util
|
||||||
const genericPatch = require('./_generic').genericPatch;
|
const genericPatch = require('./_generic').genericPatch;
|
||||||
|
@ -76,6 +77,8 @@ wars.route('/')
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(statsResult.playerCount)
|
||||||
LogKillModel.create(statsResult.kills, () => {
|
LogKillModel.create(statsResult.kills, () => {
|
||||||
LogVehicleKillModel.create(statsResult.vehicles, () => {
|
LogVehicleKillModel.create(statsResult.vehicles, () => {
|
||||||
LogRespawnModel.create(statsResult.respawn, () => {
|
LogRespawnModel.create(statsResult.respawn, () => {
|
||||||
|
@ -83,6 +86,7 @@ wars.route('/')
|
||||||
LogFlagModel.create(statsResult.flag, () => {
|
LogFlagModel.create(statsResult.flag, () => {
|
||||||
LogBudgetModel.create(statsResult.budget, () => {
|
LogBudgetModel.create(statsResult.budget, () => {
|
||||||
LogTransportModel.create(statsResult.transport, () => {
|
LogTransportModel.create(statsResult.transport, () => {
|
||||||
|
LogPlayerCountModel.create(statsResult.playerCount, () => {
|
||||||
LogPointsModel.create(statsResult.points, () => {
|
LogPointsModel.create(statsResult.points, () => {
|
||||||
const folderName = resourceLocation.concat(war._id);
|
const folderName = resourceLocation.concat(war._id);
|
||||||
mkdirp(folderName, (err) => {
|
mkdirp(folderName, (err) => {
|
||||||
|
@ -117,6 +121,7 @@ wars.route('/')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const err = new Error('no Logfile provided');
|
const err = new Error('no Logfile provided');
|
||||||
err.status = codes.wrongmediasend;
|
err.status = codes.wrongmediasend;
|
||||||
|
|
|
@ -23,6 +23,12 @@ const vehicleRegex = /(vehicle:\s(.*?)\))/;
|
||||||
|
|
||||||
const categoryRegex = /(category:\s(.*?)\))/;
|
const categoryRegex = /(category:\s(.*?)\))/;
|
||||||
|
|
||||||
|
const bluforPlayerCountRegex = /NATO\s(\d*)/;
|
||||||
|
|
||||||
|
const opforPlayerCountRegex = /CSAT\s(\d*)/;
|
||||||
|
|
||||||
|
const timestampRegex= /LOG:\s(\d*:\d*:\d*)\s---/;
|
||||||
|
|
||||||
const parseWarLog = (lineArray, war) => {
|
const parseWarLog = (lineArray, war) => {
|
||||||
let flagBlufor = true;
|
let flagBlufor = true;
|
||||||
let flagOpfor = true;
|
let flagOpfor = true;
|
||||||
|
@ -41,6 +47,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
flag: [],
|
flag: [],
|
||||||
transport: [],
|
transport: [],
|
||||||
players: [],
|
players: [],
|
||||||
|
playerCount: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const VEHICLE_BLACKLIST = [
|
const VEHICLE_BLACKLIST = [
|
||||||
|
@ -245,6 +252,19 @@ const parseWarLog = (lineArray, war) => {
|
||||||
fraction: driver ? driver.fraction : 'NONE',
|
fraction: driver ? driver.fraction : 'NONE',
|
||||||
distance: distance,
|
distance: distance,
|
||||||
});
|
});
|
||||||
|
} else if (line.includes('(Spieleranzahl)')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
|
||||||
|
const timestamp = (timestampRegex.exec(line))[1];
|
||||||
|
const countBlufor = (bluforPlayerCountRegex.exec(line))[1];
|
||||||
|
const countOpfor = (opforPlayerCountRegex.exec(line))[1];
|
||||||
|
|
||||||
|
stats.playerCount.push({
|
||||||
|
war: war.id,
|
||||||
|
time: getFullTimeDate(war.date, timestamp),
|
||||||
|
countBlufor: countBlufor,
|
||||||
|
countOpfor: countOpfor,
|
||||||
|
});
|
||||||
} else if (line.includes('(Fraktionsuebersicht)') || line.includes('Fraktionsübersicht')) {
|
} else if (line.includes('(Fraktionsuebersicht)') || line.includes('Fraktionsübersicht')) {
|
||||||
/**
|
/**
|
||||||
* PLAYERS
|
* PLAYERS
|
||||||
|
|
Loading…
Reference in New Issue