Replaced /mining/pools?interval=X by /mining/pools/X

This commit is contained in:
nymkappa 2022-02-02 19:03:07 +09:00
parent 95c8e72b58
commit e48a2f73e4
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
4 changed files with 23 additions and 17 deletions

View File

@ -256,7 +256,16 @@ class Server {
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1y', routes.$getStatisticsByTime.bind(routes, '1y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2y', routes.$getStatisticsByTime.bind(routes, '2y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3y', routes.$getStatisticsByTime.bind(routes, '3y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools', routes.$getPools)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/24h', routes.$getPools.bind(routes, '24h'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/3d', routes.$getPools.bind(routes, '3d'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/1w', routes.$getPools.bind(routes, '1w'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/1m', routes.$getPools.bind(routes, '1m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/3m', routes.$getPools.bind(routes, '3m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/6m', routes.$getPools.bind(routes, '6m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/1y', routes.$getPools.bind(routes, '1y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/2y', routes.$getPools.bind(routes, '2y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/3y', routes.$getPools.bind(routes, '3y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/all', routes.$getPools.bind(routes, 'all'))
;
}

View File

@ -532,9 +532,9 @@ class Routes {
}
}
public async $getPools(req: Request, res: Response) {
public async $getPools(interval: string, req: Request, res: Response) {
try {
let stats = await miningStats.$getPoolsStats(req.query.interval as string);
let stats = await miningStats.$getPoolsStats(interval);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());

View File

@ -122,10 +122,6 @@ export class ApiService {
}
listPools$(interval: string | null) : Observable<PoolsStats> {
let params = {};
if (interval) {
params = new HttpParams().set('interval', interval);
}
return this.httpClient.get<PoolsStats>(this.apiBaseUrl + this.apiBasePath + '/api/v1/mining/pools', {params});
return this.httpClient.get<PoolsStats>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pools/${interval}`);
}
}

View File

@ -11,15 +11,16 @@ do for url in / \
'/api/v1/statistics/1y' \
'/api/v1/statistics/2y' \
'/api/v1/statistics/3y' \
'/api/v1/mining/pools?interval=24h' \
'/api/v1/mining/pools?interval=3d' \
'/api/v1/mining/pools?interval=1w' \
'/api/v1/mining/pools?interval=1m' \
'/api/v1/mining/pools?interval=3m' \
'/api/v1/mining/pools?interval=6m' \
'/api/v1/mining/pools?interval=1y' \
'/api/v1/mining/pools?interval=2y' \
'/api/v1/mining/pools?interval=3y' \
'/api/v1/mining/pools/24h' \
'/api/v1/mining/pools/3d' \
'/api/v1/mining/pools/1w' \
'/api/v1/mining/pools/1m' \
'/api/v1/mining/pools/3m' \
'/api/v1/mining/pools/6m' \
'/api/v1/mining/pools/1y' \
'/api/v1/mining/pools/2y' \
'/api/v1/mining/pools/3y' \
'/api/v1/mining/pools/all' \
do
curl -s "https://${hostname}${url}" >/dev/null