Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
chromium-52 committed Dec 4, 2023
1 parent 3b7951a commit a65d10f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 12 deletions.
4 changes: 0 additions & 4 deletions apps/backend/src/applications/application.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export class Application {
@IsPositive()
id: number;

// @Column()
// @IsPositive()
// applicantId: number;

@ManyToOne(() => User, (user) => user.applications)
@JoinColumn()
user: User;
Expand Down
7 changes: 3 additions & 4 deletions apps/backend/src/applications/applications.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {
UseGuards,
BadRequestException,
} from '@nestjs/common';
import { ApplicationsService } from './applications.service';
import { CurrentUserInterceptor } from '../interceptors/current-user.interceptor';
import { AuthGuard } from '@nestjs/passport';
import { ApplicationDTO } from './dto/application.dto';
import { ApplicationDTO as GetApplicationDTO } from './dto/get-application.dto';
import { instanceToPlain, plainToClass } from 'class-transformer';
import { UsersService } from '../users/users.service';
import { getAppForCurrentCycle } from './utils';
Expand All @@ -27,14 +26,14 @@ export class ApplicationsController {
@Param('userId', ParseIntPipe) userId: number,
//TODO: make req.user.applications unaccessible
@Request() req,
): Promise<ApplicationDTO> {
): Promise<GetApplicationDTO> {
const user = await this.usersService.findOne(req.user, userId);
const app = getAppForCurrentCycle(user.applications);
const appObject = instanceToPlain(app);
if (appObject === null) {
throw new BadRequestException('There are no applications');
}
appObject['numApps'] = user.applications.length;
return plainToClass(ApplicationDTO, appObject);
return plainToClass(GetApplicationDTO, appObject);
}
}
2 changes: 0 additions & 2 deletions apps/backend/src/applications/applications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export class ApplicationsService {
}

const applicant = await this.usersService.findOne(currentUser, userId);

console.log(applicant);
const currentApp = getAppForCurrentCycle(applicant.applications ?? []);
if (currentApp == null) {
throw new BadRequestException('Application not found');
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/users/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
IsArray,
IsEmail,
IsEnum,
IsObject,
IsPositive,
IsString,
IsUrl,
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class UsersService {
}

async findOne(currentUser: User, userId: number): Promise<User> {
// const user = await this.usersRepository.findOneBy({ userId });
const user = await this.usersRepository.findOne({
where: { userId },
relations: ['applications'],
Expand Down

0 comments on commit a65d10f

Please sign in to comment.