Commit 3db70844 authored by nanahira's avatar nanahira

fix api

parent cae9034e
Pipeline #1521 passed with stages
in 7 minutes and 53 seconds
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectConnection, InjectEntityManager } from '@nestjs/typeorm'; import { InjectConnection, InjectEntityManager } from '@nestjs/typeorm';
import { Connection, EntityManager } from 'typeorm'; import { Connection, EntityManager, LessThan, MoreThanOrEqual } from 'typeorm';
import bunyan, { createLogger } from 'bunyan'; import bunyan, { createLogger } from 'bunyan';
import { UserInfo } from './entities/mycard/UserInfo'; import { UserInfo } from './entities/mycard/UserInfo';
import * as Filter from 'bad-words-chinese'; import * as Filter from 'bad-words-chinese';
...@@ -267,20 +267,22 @@ export class AppService { ...@@ -267,20 +267,22 @@ export class AppService {
.andWhere('start_time >= :fromTime', { fromTime }) .andWhere('start_time >= :fromTime', { fromTime })
.andWhere('start_time < :toTime', { toTime }) .andWhere('start_time < :toTime', { toTime })
.getRawOne(), .getRawOne(),
this.mcdb this.mcdb.getRepository(BattleHistory).find({
.getRepository(BattleHistory) select: ['startTime'],
.createQueryBuilder('battleHistory') where: {
.where('type = :type', { type: 'entertain' }) type: 'entertain',
.andWhere('start_time >= :fromTime', { fromTime }) startTime: MoreThanOrEqual(fromTime),
.andWhere('start_time < :toTime', { toTime }) endTime: LessThan(toTime),
.getMany(), },
this.mcdb }),
.getRepository(BattleHistory) this.mcdb.getRepository(BattleHistory).find({
.createQueryBuilder('battleHistory') select: ['startTime'],
.where('type = :type', { type: 'athletic' }) where: {
.andWhere('start_time >= :fromTime', { fromTime }) type: 'athletic',
.andWhere('start_time < :toTime', { toTime }) startTime: MoreThanOrEqual(fromTime),
.getMany(), endTime: LessThan(toTime),
},
}),
]); ]);
let dateHour = ''; let dateHour = '';
...@@ -335,7 +337,7 @@ export class AppService { ...@@ -335,7 +337,7 @@ export class AppService {
seriesDataAthletic.push({ seriesDataAthletic.push({
name: i, name: i,
avg: ((hourlyAvgMapAthletic[i] || 0) / totalDays).toFixed(2), avg: ((hourlyAvgMapAthletic[i] || 0) / totalDays).toFixed(2),
value: hourlyAvgMapAthletic[i] || 0 value: hourlyAvgMapAthletic[i] || 0,
}); });
} }
...@@ -346,7 +348,7 @@ export class AppService { ...@@ -346,7 +348,7 @@ export class AppService {
seriesDataEntertain.push({ seriesDataEntertain.push({
name: i, name: i,
avg: ((hourlyAvgMapEntertain[i] || 0) / totalDays).toFixed(2), avg: ((hourlyAvgMapEntertain[i] || 0) / totalDays).toFixed(2),
value: hourlyAvgMapEntertain[i] || 0 value: hourlyAvgMapEntertain[i] || 0,
}); });
} }
...@@ -354,12 +356,12 @@ export class AppService { ...@@ -354,12 +356,12 @@ export class AppService {
entertain: { entertain: {
total: entertainTotal, total: entertainTotal,
disconnect: entertainDisconnect, disconnect: entertainDisconnect,
users: entertainUsers users: entertainUsers,
}, },
athletic: { athletic: {
total: athleticTotal, total: athleticTotal,
disconnect: athleticDisconnect, disconnect: athleticDisconnect,
users: athleticUsers users: athleticUsers,
}, },
totalActive: totalActive, totalActive: totalActive,
hourlyDataMap: hourlyDataMap, hourlyDataMap: hourlyDataMap,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment