diff --git a/src/ORM/client-statistics/client-statistics.service.ts b/src/ORM/client-statistics/client-statistics.service.ts index 54846ec..5e94c9a 100644 --- a/src/ORM/client-statistics/client-statistics.service.ts +++ b/src/ORM/client-statistics/client-statistics.service.ts @@ -25,7 +25,8 @@ export class ClientStatisticsService { shares: clientStatistic.shares, acceptedCount: clientStatistic.acceptedCount, updatedAt: new Date() - }) + }); + } public async insert(clientStatistic: Partial) { await this.clientStatisticsRepository.insert(clientStatistic); @@ -151,14 +152,16 @@ export class ClientStatisticsService { if (result.length < 2) { const time = new Date(latestStat.updatedAt).getTime() - new Date(latestStat.createdAt).getTime(); - if (time < 1) { + // 1min + if (time < 1000 * 60) { return 0; } return (parseFloat(latestStat.shares) * 4294967296) / (time / 1000); } else { const secondLatestStat = result[1]; const time = new Date(latestStat.updatedAt).getTime() - new Date(secondLatestStat.createdAt).getTime(); - if (time < 1) { + // 1min + if (time < 1000 * 60) { return 0; } return ((parseFloat(latestStat.shares) + parseFloat(secondLatestStat.shares)) * 4294967296) / (time / 1000);