Skip to content

Commit

Permalink
add indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwitr0 committed Jul 6, 2024
1 parent 203f5e2 commit f52556f
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/common/models/award.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class NominationAward {
title: string;

@ApiNullableProperty()
@Prop()
@Prop({ index: true })
year: number;
}

Expand All @@ -32,9 +32,9 @@ export class Award {
winning: boolean;

@ApiNullableProperty()
@Prop()
@Prop({ index: true })
updatedAt: Date;
@ApiNullableProperty()
@Prop()
@Prop({ index: true })
createdAt: Date;
}
4 changes: 2 additions & 2 deletions src/image/schemas/image.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export class Image {
@Prop()
width?: number;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}
export const ImageSchema = SchemaFactory.createForClass(Image);
4 changes: 2 additions & 2 deletions src/keyword/schemas/keyword.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export class Keyword {
@Prop()
movies: MovieFromKeyword;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
4 changes: 2 additions & 2 deletions src/list/schemas/list.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class List {
@Prop({ type: () => ShortImage })
cover: ShortImage;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}
export const ListSchema = SchemaFactory.createForClass(List);
44 changes: 22 additions & 22 deletions src/movie/schemas/movie.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class Distributor {

export class Premiere {
@ApiNullableProperty({ example: 'США' })
@Prop()
@Prop({ index: true })
country: string;

@ApiNullableProperty({
Expand Down Expand Up @@ -285,15 +285,15 @@ export class Images {

export class FactInMovie {
@ApiProperty()
@Prop()
@Prop({ index: true })
value: string;

@ApiNullableProperty()
@Prop()
@Prop({ index: true })
type: string;

@ApiNullableProperty()
@Prop()
@Prop({ index: true })
spoiler: boolean;
}

Expand Down Expand Up @@ -363,7 +363,7 @@ export class Watchability {

export class WatchabilityItem {
@ApiNullableProperty()
@Prop()
@Prop({ index: true })
name: string;

@Prop({ type: () => Logo })
Expand All @@ -383,26 +383,26 @@ export class Technology {

export class YearRange {
@ApiNullableProperty({ example: 2022, description: 'Год начала' })
@Prop()
@Prop({ index: true })
start: number;

@ApiNullableProperty({ example: 2023, description: 'Год окончания' })
@Prop()
@Prop({ index: true })
end: number;
}

export class Audience {
@ApiNullableProperty({ example: 1000, description: 'Количество просмотров в кино' })
@Prop()
@Prop({ index: true })
count: number;

@ApiNullableProperty({ example: 'Россия', description: 'Страна в которой проходил показ' })
@Prop()
@Prop({ index: true })
country: string;
}

export class NetworkItem {
@Prop()
@Prop({ index: true })
name: string;

@Prop({ type: () => Logo })
Expand Down Expand Up @@ -478,20 +478,20 @@ export class Movie {
votes: Votes;

// INFO: Length value
@Prop()
@Prop({ index: true })
movieLength: number;

@Prop()
@Prop({ index: true })
totalSeriesLength: number;

@Prop()
@Prop({ index: true })
seriesLength: number;

// INFO: Age rating values
@Prop()
@Prop({ index: true })
ratingMpaa: string;

@Prop()
@Prop({ index: true })
ageRating: number;

// INFO: Image values
Expand Down Expand Up @@ -553,30 +553,30 @@ export class Movie {
@Prop({ type: () => [YearRange] })
releaseYears: YearRange[];

@Prop()
@Prop({ index: true })
top10?: number | null;

@Prop()
@Prop({ index: true })
top250?: number | null;

@Prop()
@Prop({ index: true })
isSeries: boolean;

@Prop({ type: () => [Audience] })
audience: Audience[];

@Prop()
@Prop({ index: true })
ticketsOnSale: boolean;

@Prop()
@Prop({ index: true })
lists: string[];

@Prop({ type: () => Networks })
networks: Networks;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
4 changes: 2 additions & 2 deletions src/person/schemas/person-award.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { READ_PREFERENCE } from '../../common/configs/mongo.config';

class Movie {
@ApiProperty()
@Prop()
@Prop({ index: true })
id: number;

@ApiNullableProperty()
Expand All @@ -30,7 +30,7 @@ export type PersonAwardDocument = HydratedDocument<PersonAward>;
})
export class PersonAward extends Award {
@ApiProperty()
@Prop()
@Prop({ index: true })
personId: number;

@ApiNullableProperty({ type: () => Movie })
Expand Down
4 changes: 2 additions & 2 deletions src/person/schemas/person.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export class Person {
@Prop({ items: MovieInPerson })
movies: MovieInPerson[];

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
4 changes: 2 additions & 2 deletions src/review/schemas/review.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export class Review {
@Prop()
authorId: number;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
4 changes: 2 additions & 2 deletions src/season/schemas/season.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export class Season {
@Prop({ type: () => [Episode] })
episodes: Episode[];

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
8 changes: 4 additions & 4 deletions src/studio/schemas/studio.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ export class Studio {
id: string;

@ApiNullableProperty()
@Prop()
@Prop({ index: true })
subType: string;

@ApiNullableProperty()
@Prop()
title: string;

@ApiPropertyOptional()
@Prop({ enum: StudioType })
@Prop({ enum: StudioType, index: true })
type: StudioType;

@ApiPropertyOptional({ type: () => MovieFromStudio })
@Prop()
movies: MovieFromStudio;

@Prop()
@Prop({ index: true })
updatedAt: Date;
@Prop()
@Prop({ index: true })
createdAt: Date;
}

Expand Down
5 changes: 4 additions & 1 deletion src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import * as ApiKey from 'uuid-apikey';
export class UserService {
private readonly logger = new Logger(UserService.name);

constructor(@InjectModel(User.name) private readonly userRepository: Model<UserDocument>, @InjectRedis() private readonly redis: Redis) {}
constructor(
@InjectModel(User.name) private readonly userRepository: Model<UserDocument>,
@InjectRedis() private readonly redis: Redis,
) {}

@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)
async resetRequestsUsedAndCache() {
Expand Down

0 comments on commit f52556f

Please sign in to comment.