Skip to content

Commit e194e23

Browse files
author
Your Name
committed
wip
1 parent bf43af6 commit e194e23

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

backend/src/services/project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class ProjectService implements IProjectService {
5353
) {}
5454

5555
/**
56-
* Sets up the user service.
56+
* Sets up the project service.
5757
*/
5858
public async bootstrap(): Promise<void> {
5959
this._projects = this._database.getRepository(Project);

backend/src/services/rating-service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ForbiddenError } from "routing-controller";
1+
import { ForbiddenError } from "routing-controllers";
22
import { Inject, Service, Token } from "typedi";
33
import { Repository } from "typeorm";
44
import { IService } from ".";
@@ -9,6 +9,8 @@ import {
99
convertBetweenEntityAndDTO,
1010
} from "../controllers/dto";
1111
import { User } from "../entities/user";
12+
import { Team } from "../entities/team";
13+
import { Project } from "../entities/project";
1214
import { Criteria } from "../entities/criteria";
1315
import { Rating } from "../entities/rating";
1416

@@ -68,6 +70,8 @@ export const RatingServiceToken = new Token<IRatingService>();
6870
@Service(RatingServiceToken)
6971
export class RatingService implements IRatingService {
7072
private _ratings!: Repository<Rating>;
73+
private _projects!: Repository<Project>;
74+
private _teams!: Repository<Team>;
7175
private _users!: Repository<User>;
7276

7377
public constructor(
@@ -150,13 +154,13 @@ export class RatingService implements IRatingService {
150154
throw new ForbiddenError("Cannot create rating due to application settings")
151155
}
152156

153-
const project = await this._projects.getProject(data.id);
157+
const project = await await this._projects.findOneBy({ id: data.id });
154158
if (!project.allowRating) {
155159
// TODO test
156160
throw new ForbiddenError("Creating a rating for this project is not allowed")
157161
}
158162

159-
const team = await this._teams.getTeamById(project.teamId)
163+
const team = await this._teams.findOneById(project.teamId)
160164
if (team.users.inclues(user.id)) {
161165
// TODO test
162166
throw new ForbiddenError("You can't rate your own project")

0 commit comments

Comments
 (0)