Add log time save with decimal
parent
b266d6f972
commit
3ccdbe4da3
|
@ -10,7 +10,7 @@ const LogBudgetSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
fraction: {
|
fraction: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogFlagSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogKillSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
shooter: {
|
shooter: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogKillSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
ptBlufor: {
|
ptBlufor: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogRespawnSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogReviveSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
medic: {
|
medic: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const LogTransportSchema = new Schema({
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
time: {
|
time: {
|
||||||
type: Date,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
driver: {
|
driver: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const timeStringToDecimal = require('../tools/util').timeStringToDecimal;
|
||||||
const arrayContains = require('./util').arrayContains;
|
const arrayContains = require('./util').arrayContains;
|
||||||
|
|
||||||
const parseWarLog = (lineArray, war) => {
|
const parseWarLog = (lineArray, war) => {
|
||||||
|
@ -46,7 +47,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
|
|
||||||
stats.kills.push({
|
stats.kills.push({
|
||||||
war: war._id,
|
war: war._id,
|
||||||
time: getDateTime(line.split(' ')[5]),
|
time: timeStringToDecimal(line.split(' ')[5]),
|
||||||
shooter: shooter ? shooter.name : null,
|
shooter: shooter ? shooter.name : null,
|
||||||
target: target.name,
|
target: target.name,
|
||||||
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
||||||
|
@ -85,7 +86,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
|
|
||||||
stats.flag.push({
|
stats.flag.push({
|
||||||
war: war._id,
|
war: war._id,
|
||||||
time: getDateTime(line.split(' ')[5]),
|
time: timeStringToDecimal(line.split(' ')[5]),
|
||||||
player: playerName,
|
player: playerName,
|
||||||
flagFraction: flagFraction,
|
flagFraction: flagFraction,
|
||||||
capture: capture
|
capture: capture
|
||||||
|
@ -132,7 +133,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
|
|
||||||
stats.revive.push({
|
stats.revive.push({
|
||||||
war: war._id,
|
war: war._id,
|
||||||
time: getDateTime(line.split(' ')[5]),
|
time: timeStringToDecimal(line.split(' ')[5]),
|
||||||
stabilized: stabilized,
|
stabilized: stabilized,
|
||||||
medic: medic.name,
|
medic: medic.name,
|
||||||
patient: patient.name,
|
patient: patient.name,
|
||||||
|
@ -155,7 +156,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
|
|
||||||
stats.transport.push({
|
stats.transport.push({
|
||||||
war: war._id,
|
war: war._id,
|
||||||
time: getDateTime(line.split(' ')[5]),
|
time: timeStringToDecimal(line.split(' ')[5]),
|
||||||
driver: driver.name,
|
driver: driver.name,
|
||||||
passenger: passenger ? passenger.name : null,
|
passenger: passenger ? passenger.name : null,
|
||||||
fraction: driver.fraction,
|
fraction: driver.fraction,
|
||||||
|
@ -187,7 +188,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
const getRespawnEntry = (respawn, playerName, warId) => {
|
const getRespawnEntry = (respawn, playerName, warId) => {
|
||||||
return {
|
return {
|
||||||
war: warId,
|
war: warId,
|
||||||
time: getDateTime(respawn[5]),
|
time: timeStringToDecimal(respawn[5]),
|
||||||
player: playerName
|
player: playerName
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -195,7 +196,7 @@ const getRespawnEntry = (respawn, playerName, warId) => {
|
||||||
const getPointsEntry = (pt, line, warId) => {
|
const getPointsEntry = (pt, line, warId) => {
|
||||||
return {
|
return {
|
||||||
war: warId,
|
war: warId,
|
||||||
time: getDateTime(pt[5]),
|
time: timeStringToDecimal(pt[5]),
|
||||||
ptBlufor: parseInt(pt[12]),
|
ptBlufor: parseInt(pt[12]),
|
||||||
ptOpfor: parseInt(pt[15].slice(0, -1)),
|
ptOpfor: parseInt(pt[15].slice(0, -1)),
|
||||||
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
||||||
|
@ -205,7 +206,7 @@ const getPointsEntry = (pt, line, warId) => {
|
||||||
const getBudgetEntry = (budg, warId) => {
|
const getBudgetEntry = (budg, warId) => {
|
||||||
return {
|
return {
|
||||||
war: warId,
|
war: warId,
|
||||||
time: getDateTime(budg[5]),
|
time: timeStringToDecimal(budg[5]),
|
||||||
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
||||||
oldBudget: transformMoneyString(budg[11]),
|
oldBudget: transformMoneyString(budg[11]),
|
||||||
newBudget: transformMoneyString(budg[14])
|
newBudget: transformMoneyString(budg[14])
|
||||||
|
@ -231,9 +232,4 @@ const transformMoneyString = (budgetString) => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDateTime = (timeString) => {
|
|
||||||
const timeZone = 'Z';
|
|
||||||
return new Date('1999-01-01T0' + timeString + timeZone);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = parseWarLog;
|
module.exports = parseWarLog;
|
||||||
|
|
|
@ -24,5 +24,27 @@ const playerArrayContains = (arr, item) => {
|
||||||
return matchFound;
|
return matchFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const timeStringToDecimal = (timeString) => {
|
||||||
|
const timeArray = timeString.split(':');
|
||||||
|
const hour = parseInt(timeArray[0]);
|
||||||
|
const sek = parseInt(timeArray[1]) * 60 + parseInt(timeArray[2]);
|
||||||
|
|
||||||
|
return hour + sek * (1 / 3600);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const decimalToTimeString = (decimal) => {
|
||||||
|
const hours = parseInt(decimal.toString().split(".")[0]);
|
||||||
|
const minutesFloat = ((decimal % 1) * 3600) / 60;
|
||||||
|
const minutes = parseInt(minutesFloat.toString().split(".")[0]);
|
||||||
|
const seconds = Math.round((minutesFloat - parseInt(minutes)) * 60);
|
||||||
|
|
||||||
|
return (hours < 10 ? '0' + hours : hours) + ':' +
|
||||||
|
(minutes < 10 ? '0' + minutes : minutes) + ':' +
|
||||||
|
(seconds < 10 ? '0' + seconds : seconds);
|
||||||
|
};
|
||||||
|
|
||||||
exports.sortCollection = sortCollectionBy;
|
exports.sortCollection = sortCollectionBy;
|
||||||
exports.arrayContains = playerArrayContains;
|
exports.arrayContains = playerArrayContains;
|
||||||
|
exports.timeStringToDecimal = timeStringToDecimal;
|
||||||
|
exports.decimalToTimeString = decimalToTimeString;
|
||||||
|
|
|
@ -33,8 +33,7 @@ export class WarDetailComponent {
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private warService: WarService,
|
private warService: WarService) {
|
||||||
private logsService: LogsService) {
|
|
||||||
Object.assign(this, this.playerChart)
|
Object.assign(this, this.playerChart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue