RunnerTeam Pagination
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
ref #205
This commit is contained in:
parent
538622aa18
commit
0fa663a341
|
@ -1,6 +1,6 @@
|
|||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
|
||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { getConnectionManager, Repository } from 'typeorm';
|
||||
import { Repository, getConnectionManager } from 'typeorm';
|
||||
import { RunnerTeamHasRunnersError, RunnerTeamIdsNotMatchingError, RunnerTeamNotFoundError } from '../errors/RunnerTeamErrors';
|
||||
import { CreateRunnerTeam } from '../models/actions/create/CreateRunnerTeam';
|
||||
import { UpdateRunnerTeam } from '../models/actions/update/UpdateRunnerTeam';
|
||||
|
@ -27,11 +27,18 @@ export class RunnerTeamController {
|
|||
@Authorized("TEAM:GET")
|
||||
@ResponseSchema(ResponseRunnerTeam, { isArray: true })
|
||||
@OpenAPI({ description: 'Lists all teams. <br> This includes their parent organization and contact (if existing/associated).' })
|
||||
async getAll() {
|
||||
async getAll(@QueryParam("page", { required: false }) page: number, @QueryParam("page_size", { required: false }) page_size: number = 100) {
|
||||
let responseTeams: ResponseRunnerTeam[] = new Array<ResponseRunnerTeam>();
|
||||
const runners = await this.runnerTeamRepository.find({ relations: ['parentGroup', 'contact'] });
|
||||
runners.forEach(runner => {
|
||||
responseTeams.push(new ResponseRunnerTeam(runner));
|
||||
let teams: Array<RunnerTeam>;
|
||||
|
||||
if (page) {
|
||||
teams = await this.runnerTeamRepository.find({ relations: ['parentGroup', 'contact'], skip: page * page_size, take: page_size });
|
||||
} else {
|
||||
teams = await this.runnerTeamRepository.find({ relations: ['parentGroup', 'contact'] });
|
||||
}
|
||||
|
||||
teams.forEach(team => {
|
||||
responseTeams.push(new ResponseRunnerTeam(team));
|
||||
});
|
||||
return responseTeams;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue