mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
splash chart data
This commit is contained in:
+23
-5
@@ -1,18 +1,36 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { Controller, Get, Inject } from '@nestjs/common';
|
||||
import { Cache } from 'cache-manager';
|
||||
|
||||
import { ClientStatisticsService } from './ORM/client-statistics/client-statistics.service';
|
||||
import { ClientService } from './ORM/client/client.service';
|
||||
|
||||
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(
|
||||
private clientService: ClientService
|
||||
@Inject(CACHE_MANAGER) private cacheManager: Cache,
|
||||
private clientService: ClientService,
|
||||
private clientStatisticsService: ClientStatisticsService
|
||||
) { }
|
||||
|
||||
@Get('info')
|
||||
public info() {
|
||||
public async info() {
|
||||
|
||||
const CACHE_KEY = 'SITE_HASHRATE_GRAPH';
|
||||
const cachedResult = await this.cacheManager.get(CACHE_KEY);
|
||||
if (cachedResult != null) {
|
||||
return {
|
||||
chartData: cachedResult
|
||||
};
|
||||
}
|
||||
|
||||
const chartData = await this.clientStatisticsService.getChartDataForSite();
|
||||
|
||||
await this.cacheManager.set(CACHE_KEY, chartData, 600)
|
||||
|
||||
return {
|
||||
chartData
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user