From b7a0c47b3257ed04fd9be7c428c31bfd111a4652 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 2 Nov 2017 11:17:16 +0100 Subject: [PATCH 1/4] Fix date util and log parse; Fix fract revive count --- api/tools/log-parse-tool.js | 4 +-- package.json | 2 +- .../war-detail/war-detail.component.html | 1 - .../war-detail/war-detail.component.ts | 26 ++++++++++++++----- static/src/app/utils/chart-utils.ts | 3 +-- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index 0da7a45..ec3b1c6 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -28,7 +28,7 @@ const parseWarLog = (lineArray, war) => { lineArray.some(line => { /** - * sanitize nameToLongError coming up in first line + * sanitize nameTooLongError coming up in first line */ if (line.includes(nameToLongError)) { line = line.substring(line.indexOf(nameToLongError) + nameToLongError.length); @@ -65,7 +65,7 @@ const parseWarLog = (lineArray, war) => { if (line.includes('Endbudget')) { stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]); stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]); - war.endDate = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T0' + budg[5] +'.000+02:00'); + war.endDate = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T0' + budg[5]); } else if (line.includes('Startbudget')) { stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T22:00:00.000+02:00'); stats.war['budgetBlufor'] = transformMoneyString(budg[11]); diff --git a/package.json b/package.json index 945d0b2..f4446c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "author": "Florian Hartwich ", "private": true, diff --git a/static/src/app/statistic/war-detail/war-detail.component.html b/static/src/app/statistic/war-detail/war-detail.component.html index 39bd71a..0fe81e3 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.html +++ b/static/src/app/statistic/war-detail/war-detail.component.html @@ -119,7 +119,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" diff --git a/static/src/app/statistic/war-detail/war-detail.component.ts b/static/src/app/statistic/war-detail/war-detail.component.ts index 232dc44..993e7d2 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.ts +++ b/static/src/app/statistic/war-detail/war-detail.component.ts @@ -187,12 +187,22 @@ export class WarDetailComponent { "name": startDateObj, "value": this.war.budgetOpfor }); - data.budget.forEach(budgetEntry => { - this.tmpBudgetData[budgetEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({ + // This adds an entry for both fractions on every event + for (let i = 0; i < data.budget.length; i++) { + const budgetEntry = data.budget[i]; + const fractionChange = budgetEntry.fraction === 'BLUFOR' ? 0 : 1; + const fractionOld = budgetEntry.fraction !== 'BLUFOR' ? 0 : 1; + + this.tmpBudgetData[fractionChange].series.push({ "name": new Date(budgetEntry.time), "value": budgetEntry.newBudget }); - }); + + this.tmpBudgetData[fractionOld].series.push({ + "name": new Date(budgetEntry.time), + "value": this.tmpBudgetData[fractionOld].series[this.tmpBudgetData[fractionOld].series.length-1].value + }); + } // KILLS let killCountBlufor = 0; @@ -290,11 +300,11 @@ export class WarDetailComponent { if (reviveEntry.stabilized === false) { reviveCountBlufor++; } else { - reviveCountOpfor++; + stabilizeCountBlufor++; } } else { if (reviveEntry.stabilized === false) { - stabilizeCountBlufor++; + reviveCountOpfor++; } else { stabilizeCountOpfor++; } @@ -344,7 +354,9 @@ export class WarDetailComponent { [this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData, this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => { for (let j in [0, 1]) { - if (tmp[j].series[tmp[j].series.length - 1].name < endDate) { + console.log(new Date(tmp[j].series[tmp[j].series.length - 1].name) + '... ' + endDate) + console.log(new Date(tmp[j].series[tmp[j].series.length - 1].name) < endDate) + if (new Date(tmp[j].series[tmp[j].series.length - 1].name) < endDate) { tmp[j].series.push({ 'name': endDate, 'value': tmp[j].series[tmp[j].series.length - 1].value @@ -353,6 +365,8 @@ export class WarDetailComponent { } } }); + // console.log(this.tmpKillData[0].series[this.tmpKillData[0].series.length-1]) + // console.log(this.tmpKillData[1].series[this.tmpKillData[1].series.length-1]) this.pointData = this.tmpPointData; this.budgetData = this.tmpBudgetData; this.transportData = this.tmpTransportData; diff --git a/static/src/app/utils/chart-utils.ts b/static/src/app/utils/chart-utils.ts index 0802e2c..565bcec 100644 --- a/static/src/app/utils/chart-utils.ts +++ b/static/src/app/utils/chart-utils.ts @@ -2,9 +2,8 @@ export class ChartUtils { public static getShortDateString(date): string { const isoDate = date.slice(0, 10); - const dayDate = parseInt(isoDate.slice(8, 10)) + 1; + const dayDate = parseInt(isoDate.slice(8, 10)); return (dayDate < 10 ? "0" + dayDate : dayDate) + '.' + isoDate.slice(5, 7) + '.' + isoDate.slice(2, 4); } - } From b79ccbb1af95fe1c55932a516653aaf9425ea46b Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 2 Nov 2017 11:20:11 +0100 Subject: [PATCH 2/4] rollback fract graphs to standard curve --- .../src/app/statistic/war-detail/war-detail.component.html | 5 ----- static/src/app/statistic/war-detail/war-detail.component.ts | 5 ----- 2 files changed, 10 deletions(-) diff --git a/static/src/app/statistic/war-detail/war-detail.component.html b/static/src/app/statistic/war-detail/war-detail.component.html index 0fe81e3..682afd2 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.html +++ b/static/src/app/statistic/war-detail/war-detail.component.html @@ -136,7 +136,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" @@ -154,7 +153,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" @@ -172,7 +170,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" @@ -190,7 +187,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" @@ -208,7 +204,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel" diff --git a/static/src/app/statistic/war-detail/war-detail.component.ts b/static/src/app/statistic/war-detail/war-detail.component.ts index 993e7d2..2b09dfa 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.ts +++ b/static/src/app/statistic/war-detail/war-detail.component.ts @@ -66,7 +66,6 @@ export class WarDetailComponent { yAxisLabelStabilize = 'Stabilisiert'; yAxisLabelFlag = 'Flaggenbesitz'; - monotoneYCurve = d3.curveMonotoneY; stepCurve = d3.curveStepAfter; gradient = false; yAxis = true; @@ -354,8 +353,6 @@ export class WarDetailComponent { [this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData, this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => { for (let j in [0, 1]) { - console.log(new Date(tmp[j].series[tmp[j].series.length - 1].name) + '... ' + endDate) - console.log(new Date(tmp[j].series[tmp[j].series.length - 1].name) < endDate) if (new Date(tmp[j].series[tmp[j].series.length - 1].name) < endDate) { tmp[j].series.push({ 'name': endDate, @@ -365,8 +362,6 @@ export class WarDetailComponent { } } }); - // console.log(this.tmpKillData[0].series[this.tmpKillData[0].series.length-1]) - // console.log(this.tmpKillData[1].series[this.tmpKillData[1].series.length-1]) this.pointData = this.tmpPointData; this.budgetData = this.tmpBudgetData; this.transportData = this.tmpTransportData; From 9a45a43b7ae6a79924d6543dc256a73eb4e3aa02 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 2 Nov 2017 11:22:27 +0100 Subject: [PATCH 3/4] remove useless date constructor --- static/src/app/statistic/war-detail/war-detail.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/src/app/statistic/war-detail/war-detail.component.ts b/static/src/app/statistic/war-detail/war-detail.component.ts index 2b09dfa..749496d 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.ts +++ b/static/src/app/statistic/war-detail/war-detail.component.ts @@ -353,7 +353,7 @@ export class WarDetailComponent { [this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData, this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => { for (let j in [0, 1]) { - if (new Date(tmp[j].series[tmp[j].series.length - 1].name) < endDate) { + if (tmp[j].series[tmp[j].series.length - 1].name < endDate) { tmp[j].series.push({ 'name': endDate, 'value': tmp[j].series[tmp[j].series.length - 1].value From 89b9867d915e49c9fabb864373bc5fb8c79c26af Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 2 Nov 2017 11:26:10 +0100 Subject: [PATCH 4/4] remove last curve input --- static/src/app/statistic/war-detail/war-detail.component.html | 1 - 1 file changed, 1 deletion(-) diff --git a/static/src/app/statistic/war-detail/war-detail.component.html b/static/src/app/statistic/war-detail/war-detail.component.html index 682afd2..97bec74 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.html +++ b/static/src/app/statistic/war-detail/war-detail.component.html @@ -101,7 +101,6 @@ [gradient]="gradient" [xAxis]="xAxis" [yAxis]="yAxis" - [curve]="monotoneYCurve" [legend]="legend" [legendTitle]="legendTitle" [showXAxisLabel]="showXAxisLabel"