Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate all MongoRepository instances to Repository #74

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/backend/src/applications/applications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Injectable,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { MongoRepository } from 'typeorm';
import { Repository } from 'typeorm';
import { UsersService } from '../users/users.service';
import { Application } from './application.entity';
import {
Expand All @@ -24,7 +24,7 @@ import { stagesMap } from './applications.constants';
export class ApplicationsService {
constructor(
@InjectRepository(Application)
private readonly applicationsRepository: MongoRepository<Application>,
private readonly applicationsRepository: Repository<Application>,
private readonly usersService: UsersService,
) {}

Expand Down
15 changes: 2 additions & 13 deletions apps/backend/src/reviews/reviews.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { MongoRepository } from 'typeorm';
import { Repository } from 'typeorm';
import { Review } from './review.entity';
import { ApplicationsService } from '../applications/applications.service';
import { User } from '../users/user.entity';
Expand All @@ -10,7 +10,7 @@ import { SubmitReviewRequestDTO } from './dto/submit-review.request.dto';
export class ReviewsService {
constructor(
@InjectRepository(Review)
private reviewsRepository: MongoRepository<Review>,
private reviewsRepository: Repository<Review>,
private applicationsService: ApplicationsService,
) {}

Expand All @@ -37,15 +37,4 @@ export class ReviewsService {

return this.reviewsRepository.save(review);
}

/**
* Get all reviews of an application with the given ID
*/
async getReviews(applicationId: number): Promise<Review[]> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this unused?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this function is unecessary since the reviews are already included when querying applications

const application = await this.applicationsService.findCurrent(
applicationId,
);

return this.reviewsRepository.find({ application });
}
}
4 changes: 2 additions & 2 deletions apps/backend/src/users/users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { NotFoundException } from '@nestjs/common';
import { getRepositoryToken } from '@nestjs/typeorm';
import { Test, TestingModule } from '@nestjs/testing';
import { MongoRepository } from 'typeorm';
import { Repository } from 'typeorm';

import { UsersService } from './users.service';
import { User } from './user.entity';
import { userFactory } from '../testing/factories/user.factory';
import { UserStatus } from './types';

const mockUsersRepository: Partial<MongoRepository<User>> = {
const mockUsersRepository: Partial<Repository<User>> = {
findOne: jest.fn(),
};

Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BadRequestException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { MongoRepository } from 'typeorm';
import { Not, Repository } from 'typeorm';
import { User } from './user.entity';
import { UpdateUserRequestDTO } from './dto/update-user.request.dto';
import { UserStatus } from './types';
Expand All @@ -14,7 +14,7 @@ import { UserStatus } from './types';
export class UsersService {
constructor(
@InjectRepository(User)
private usersRepository: MongoRepository<User>,
private usersRepository: Repository<User>,
) {}

async create(
Expand Down Expand Up @@ -42,7 +42,7 @@ export class UsersService {

const users: User[] = await this.usersRepository.find({
where: {
status: { $not: { $eq: UserStatus.APPLICANT } },
status: Not(UserStatus.APPLICANT),
},
});

Expand Down
Loading