Now organisations and teams can import runners
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import { RunnerGroupNeededError } from '../../errors/RunnerErrors';
|
||||
import { RunnerOrganisationNotFoundError } from '../../errors/RunnerOrganisationErrors';
|
||||
import { RunnerGroup } from '../entities/RunnerGroup';
|
||||
import { RunnerOrganisation } from '../entities/RunnerOrganisation';
|
||||
@@ -29,17 +30,20 @@ export class ImportSchoolRunner extends ImportRunner {
|
||||
return newRunner;
|
||||
}
|
||||
|
||||
public async getGroup(orgID: number): Promise<RunnerGroup> {
|
||||
if (this.class === undefined) {
|
||||
throw new Error("TODO:Error for runner missing teams");
|
||||
public async getGroup(groupID: number): Promise<RunnerGroup> {
|
||||
if (this.class === undefined && groupID === undefined) {
|
||||
throw new RunnerGroupNeededError();
|
||||
}
|
||||
|
||||
let org = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: orgID });
|
||||
let team = await getConnectionManager().get().getRepository(RunnerTeam).findOne({ id: groupID });
|
||||
if (team) { return team; }
|
||||
|
||||
let org = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: groupID });
|
||||
if (!org) {
|
||||
throw new RunnerOrganisationNotFoundError();
|
||||
}
|
||||
|
||||
let team = await getConnectionManager().get().getRepository(RunnerTeam).findOne({ name: this.class, parentGroup: org });
|
||||
team = await getConnectionManager().get().getRepository(RunnerTeam).findOne({ name: this.class, parentGroup: org });
|
||||
if (!team) {
|
||||
let newRunnerTeam: RunnerTeam = new RunnerTeam();
|
||||
newRunnerTeam.name = this.class;
|
||||
|
||||
Reference in New Issue
Block a user