ref #205
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, QueryParam } from 'routing-controllers';
 | 
			
		||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
 | 
			
		||||
import { getConnectionManager, Repository } from 'typeorm';
 | 
			
		||||
import { Repository, getConnectionManager } from 'typeorm';
 | 
			
		||||
import { StatsClientNotFoundError } from '../errors/StatsClientErrors';
 | 
			
		||||
import { TrackNotFoundError } from "../errors/TrackErrors";
 | 
			
		||||
import { CreateStatsClient } from '../models/actions/create/CreateStatsClient';
 | 
			
		||||
@@ -24,9 +24,16 @@ export class StatsClientController {
 | 
			
		||||
	@Authorized("STATSCLIENT:GET")
 | 
			
		||||
	@ResponseSchema(ResponseStatsClient, { isArray: true })
 | 
			
		||||
	@OpenAPI({ description: 'Lists all stats clients. Please remember that the key can only be viewed on creation.' })
 | 
			
		||||
	async getAll() {
 | 
			
		||||
	async getAll(@QueryParam("page", { required: false }) page: number, @QueryParam("page_size", { required: false }) page_size: number = 100) {
 | 
			
		||||
		let responseClients: ResponseStatsClient[] = new Array<ResponseStatsClient>();
 | 
			
		||||
		const clients = await this.clientRepository.find();
 | 
			
		||||
		let clients: Array<StatsClient>;
 | 
			
		||||
 | 
			
		||||
		if (page) {
 | 
			
		||||
			clients = await this.clientRepository.find({ skip: page * page_size, take: page_size });
 | 
			
		||||
		} else {
 | 
			
		||||
			clients = await this.clientRepository.find();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		clients.forEach(clients => {
 | 
			
		||||
			responseClients.push(new ResponseStatsClient(clients));
 | 
			
		||||
		});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user