Compare commits

..

No commits in common. "2fffad3c609b1e8ce83190ba2b0b0168434ec358" and "9c6f74c14f14533c878d18e8c99db355ceefdb06" have entirely different histories.

6 changed files with 49 additions and 127 deletions

View File

@ -85,7 +85,7 @@ const PlayerSchema = new Schema({
performance: { performance: {
type: mongoose.Schema.Types.ObjectId, type: mongoose.Schema.Types.ObjectId,
ref: 'LogServerFpsSchema', ref: 'LogServerFpsSchema',
required: false, required: true,
}, },
}, { }, {
collection: 'player', collection: 'player',

View File

@ -74,37 +74,25 @@ wars.route('/')
if (err) { if (err) {
return next(err); return next(err);
} }
LogKillModel.create(statsResult.kills, (err) => { LogKillModel.create(statsResult.kills, () => {
if (err) console.log(err); LogVehicleKillModel.create(statsResult.vehicles, () => {
LogVehicleKillModel.create(statsResult.vehicles, (err) => { LogRespawnModel.create(statsResult.respawn, () => {
if (err) console.log(err); LogReviveModel.create(statsResult.revive, () => {
LogRespawnModel.create(statsResult.respawn, (err) => { LogFlagModel.create(statsResult.flag, () => {
if (err) console.log(err); LogBudgetModel.create(statsResult.budget, () => {
LogReviveModel.create(statsResult.revive, (err) => { LogTransportModel.create(statsResult.transport, () => {
if (err) console.log(err); LogPlayerCountModel.create(statsResult.playerCount, () => {
LogFlagModel.create(statsResult.flag, (err) => { LogPointsModel.create(statsResult.points, () => {
if (err) console.log(err);
LogBudgetModel.create(statsResult.budget, (err) => {
if (err) console.log(err);
LogTransportModel.create(statsResult.transport, (err) => {
if (err) console.log(err);
LogPlayerCountModel.create(statsResult.playerCount, (err) => {
if (err) console.log(err);
LogPointsModel.create(statsResult.points, (err) => {
if (err) console.log(err);
LogServerFpsModel.create(statsResult.serverFps, (err, serverPerformanceEntries) => { LogServerFpsModel.create(statsResult.serverFps, (err, serverPerformanceEntries) => {
if (err) console.log(err); serverPerformanceEntries.forEach((entry) => {
if (serverPerformanceEntries) { const idx = statsResult.players
serverPerformanceEntries.forEach((entry) => { .findIndex((player) => player.name === entry.entityName);
const idx = statsResult.players if (idx !== -1) {
.findIndex((player) => player.name === entry.entityName); const player = statsResult.players[idx];
if (idx !== -1) { player['performance'] = entry._id;
const player = statsResult.players[idx]; statsResult.players[idx] = player;
player['performance'] = entry._id; }
statsResult.players[idx] = player; });
}
});
}
PlayerModel.create(statsResult.players, (err) => { PlayerModel.create(statsResult.players, (err) => {
if (err) { if (err) {
return next(err); return next(err);

View File

@ -127,7 +127,6 @@ const parseWarLog = (lineArray, war) => {
const kill = { const kill = {
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
friendlyFire: false,
}; };
if (shooter) { if (shooter) {
kill.shooter = shooter.name; kill.shooter = shooter.name;

View File

@ -9,10 +9,9 @@
</mat-button-toggle> </mat-button-toggle>
</mat-button-toggle-group> </mat-button-toggle-group>
<div class="chart-container" *ngIf="showBarChart"> <div class="chart-container">
<ngx-charts-bar-vertical <ngx-charts-bar-vertical
[results]="barChartData" [results]="barChartData"
[scheme]="colorScheme"
[gradient]="gradient" [gradient]="gradient"
[xAxis]="xAxis" [xAxis]="xAxis"
[yAxis]="yAxis" [yAxis]="yAxis"
@ -26,21 +25,20 @@
</ngx-charts-bar-vertical> </ngx-charts-bar-vertical>
</div> </div>
<div class="chart-container" *ngIf="!showBarChart"> <!--<div class="chart-container">-->
<ngx-charts-line-chart <!--<ngx-charts-line-chart-->
[results]="lineChartData" <!--[results]="barChartData"-->
[scheme]="colorScheme" <!--[gradient]="gradient"-->
[gradient]="gradient" <!--[xAxis]="xAxis"-->
[xAxis]="xAxis" <!--[yAxis]="yAxis"-->
[yAxis]="yAxis" <!--[legend]="legend"-->
[legend]="legend" <!--[legendTitle]="legendTitle"-->
[legendTitle]="legendTitle" <!--[showXAxisLabel]="showXAxisLabel"-->
[showXAxisLabel]="showXAxisLabel" <!--[showYAxisLabel]="showYAxisLabel"-->
[showYAxisLabel]="showYAxisLabel" <!--[yAxisLabel]="barChartLabel"-->
[yAxisLabel]="lineChartLabel" <!--[autoScale]="autoscale"-->
[autoScale]="autoscale" <!--[timeline]="timeline"-->
[timeline]="timeline" <!--[roundDomains]="roundDomains">-->
[roundDomains]="roundDomains"> <!--</ngx-charts-line-chart>-->
</ngx-charts-line-chart> <!--</div>-->
</div>
</div> </div>

View File

@ -1,7 +1,6 @@
import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core'; import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
import {War} from '../../../models/model-interfaces'; import {War} from '../../../models/model-interfaces';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {ChartUtils} from '../../../utils/chart-utils';
@Component({ @Component({
@ -21,18 +20,18 @@ export class ServerStatsComponent implements OnInit, OnChanges {
public activeChartSelect: string; public activeChartSelect: string;
showBarChart = true;
barChartData: any[] = []; barChartData: any[] = [];
lineChartData: any[] = []; lineChartData: any[] = [];
showBarChart = true;
tmpSingleAvg; tmpSingleAvg;
tmpSingleMin; tmpSingleMin;
tmpAvgTimeline; tmpAvgTimeline;
tmpMinTimeline; tmpMinTimeline;
tmpServerTimeline; tmpServerTimeline;
barChartLabel: string;
lineChartLabel: string;
readonly labels = { readonly labels = {
singleAvg: 'stats.performance.select.single.avg', singleAvg: 'stats.performance.select.single.avg',
singleMin: 'stats.performance.select.single.min', singleMin: 'stats.performance.select.single.min',
@ -43,6 +42,9 @@ export class ServerStatsComponent implements OnInit, OnChanges {
readonly labelsAsString = Object.keys(this.labels) readonly labelsAsString = Object.keys(this.labels)
.map((key) => this.labels[key]); .map((key) => this.labels[key]);
barChartLabel: string;
lineChartLabel: string;
gradient = false; gradient = false;
yAxis = true; yAxis = true;
xAxis = true; xAxis = true;
@ -53,15 +55,6 @@ export class ServerStatsComponent implements OnInit, OnChanges {
autoscale = true; autoscale = true;
timeline = false; timeline = false;
roundDomains = true; roundDomains = true;
colorScheme = {
name: 'nightLights',
selectable: false,
group: 'Ordinal',
domain: [
'#4e31a5', '#9c25a7', '#3065ab', '#57468b', '#904497', '#46648b',
'#32118d', '#a00fb3', '#1052a2', '#6e51bd', '#b63cc3', '#6c97cb', '#8671c1', '#b455be', '#7496c3'
]
};
constructor(private translate: TranslateService) { constructor(private translate: TranslateService) {
} }
@ -71,16 +64,19 @@ export class ServerStatsComponent implements OnInit, OnChanges {
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if ((changes.war || changes.performanceData) && this.performanceData) { if (changes.war || changes.performanceData) {
this.initializeChartData(); this.initializeChartData();
Object.assign(this, [this.barChartData]); Object.assign(this, [this.barChartData]);
this.activeChartSelect = this.labels.singleAvg; this.activeChartSelect = this.labels.singleAvg;
this.startDateObj = new Date(this.war.date);
this.startDateObj.setHours(0);
this.startDateObj.setMinutes(1);
} }
} }
selectChart(newSelection) { selectChart(newSelection) {
this.activeChartSelect = newSelection; this.activeChartSelect = newSelection;
if (this.activeChartSelect === this.labels.singleAvg || this.activeChartSelect === this.labels.singleMin) { if (this.activeChartSelect !== this.labels.serverFps) {
this.showBarChart = true; this.showBarChart = true;
this.setBarChartLabel(this.activeChartSelect); this.setBarChartLabel(this.activeChartSelect);
switch (this.activeChartSelect) { switch (this.activeChartSelect) {
@ -108,52 +104,9 @@ export class ServerStatsComponent implements OnInit, OnChanges {
} }
initializeChartData() { initializeChartData() {
this.tmpAvgTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max');
this.tmpMinTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max');
this.tmpServerTimeline = ChartUtils.getMultiDataArray('min', 'avg');
const diffMs = (new Date(this.war.endDate).getTime() - new Date(this.war.date).getTime());
const warDurationMinutes = Math.round(diffMs / 60000);
const dateObj = new Date(this.war.date);
dateObj.setHours(0);
dateObj.setMinutes(1);
this.tmpSingleAvg = []; this.tmpSingleAvg = [];
this.tmpSingleMin = []; this.tmpSingleMin = [];
const maxAvgIdx = Math.min(this.performanceData.map(p => p.avgFps.length)
.sort((a, b) => b - a)[0], warDurationMinutes);
const maxMinIdx = Math.min(this.performanceData.map(p => p.avgFps.length)
.sort((a, b) => b - a)[0], warDurationMinutes);
let tmpAvgArray = new Array(maxAvgIdx).fill(0);
const tmpAvgMin = new Array(maxAvgIdx).fill(1000);
const tmpAvgMax = new Array(maxAvgIdx).fill(0);
let tmpMinArray = new Array(maxMinIdx).fill(0);
const tmpMinMin = new Array(maxMinIdx).fill(1000);
const tmpMinMax = new Array(maxMinIdx).fill(0);
this.performanceData.forEach((entry) => { this.performanceData.forEach((entry) => {
if (entry.entityName !== 'SERVER') {
// PLAYER AVERAGE TIMELINE DATA
for (let i = 0; i < entry.avgFps.length && i < tmpAvgArray.length; i++) {
tmpAvgArray[i] = tmpAvgArray[i] + entry.avgFps[i];
tmpAvgMin[i] = Math.round(Math.min(tmpAvgMin[i], entry.avgFps[i]));
tmpAvgMax[i] = Math.round(Math.max(tmpAvgMax[i], entry.avgFps[i]));
}
// PLAYER MINIMUM TIMELINE DATA
for (let i = 0; i < entry.minFps.length && i < tmpMinArray.length; i++) {
tmpMinArray[i] = tmpMinArray[i] + entry.minFps[i];
tmpMinMin[i] = Math.round(Math.min(tmpMinMin[i], entry.minFps[i]));
tmpMinMax[i] = Math.round(Math.max(tmpMinMax[i], entry.minFps[i]));
}
} else {
// SERVER TIMELINE DATA
for (let i = 0; i < entry.avgFps.length && i < warDurationMinutes; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpServerTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, entry.minFps[i]));
this.tmpServerTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, entry.avgFps[i]));
}
}
this.tmpSingleAvg.push({ this.tmpSingleAvg.push({
name: entry.entityName, name: entry.entityName,
value: entry.singleAvgFps value: entry.singleAvgFps
@ -163,21 +116,6 @@ export class ServerStatsComponent implements OnInit, OnChanges {
value: entry.singleMinFps value: entry.singleMinFps
}); });
}); });
tmpAvgArray = tmpAvgArray.map(x => Math.round(x / this.performanceData.length));
for (let i = 0; i < tmpAvgArray.length; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpAvgTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMin[i]));
this.tmpAvgTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgArray[i]));
this.tmpAvgTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMax[i]));
}
tmpMinArray = tmpMinArray.map(x => Math.round(x / this.performanceData.length));
for (let i = 0; i < tmpMinArray.length; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpMinTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMin[i]));
this.tmpMinTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinArray[i]));
this.tmpMinTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMax[i]));
}
this.tmpSingleAvg.sort((a, b) => a.value - b.value); this.tmpSingleAvg.sort((a, b) => a.value - b.value);
this.tmpSingleMin.sort((a, b) => a.value - b.value); this.tmpSingleMin.sort((a, b) => a.value - b.value);
this.barChartData = this.tmpSingleAvg; this.barChartData = this.tmpSingleAvg;

View File

@ -48,9 +48,8 @@
{{'stats.scoreboard.tab.player' | translate}} {{'stats.scoreboard.tab.player' | translate}}
</a> </a>
</li> </li>
<li class="nav-item" [ngClass]="{active :tab === 3}" (click)="switchTab(3)" <li class="nav-item" [ngClass]="{active :tab === 3}" (click)="switchTab(3)" *ngIf="war && war.players[0].performance">
*ngIf="war && war.players && war.players[0] && war.players[0].performance"> <a class="nav-link">
<a class="nav-link">
<mat-icon svgIcon="stats-performance" class="mat-icon-stats-performance"></mat-icon> <mat-icon svgIcon="stats-performance" class="mat-icon-stats-performance"></mat-icon>
{{'stats.scoreboard.tab.performance' | translate}} {{'stats.scoreboard.tab.performance' | translate}}
</a> </a>