Skip to content

Commit 0a3355d

Browse files
authored
Merge pull request #204 from game-node-app/dev
Dev
2 parents 178a338 + f2f5e26 commit 0a3355d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+944
-193
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"dayjs": "^1.11.13",
6565
"fuse.js": "^7.1.0",
6666
"jsonwebtoken": "^9.0.2",
67+
"jsum": "^2.0.0-alpha.4",
6768
"jwks-rsa": "^3.1.0",
6869
"keyv": "^5.3.3",
6970
"mime-types": "^2.1.35",
@@ -95,6 +96,7 @@
9596
"@types/express": "^5.0.0",
9697
"@types/igdb-api-node": "^5.0.3",
9798
"@types/jest": "29.5.14",
99+
"@types/jsum": "^0.1.2",
98100
"@types/mime-types": "^2.1.4",
99101
"@types/node": "^22.13.9",
100102
"@types/supertest": "^6.0.2",

server_swagger.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { AwardsModule } from "./awards/awards.module";
4242
import { UserAccountModule } from "./user/user-account/user-account.module";
4343
import { PreferredPlatformModule } from "./preferred-platform/preferred-platform.module";
4444
import { LoggerModule } from "nestjs-pino";
45+
import { RecapModule } from './recap/recap.module';
4546

4647
/**
4748
* Should only be called after 'ConfigModule' is loaded (e.g. in useFactory)
@@ -201,6 +202,7 @@ function getRedisConfig(target: "cache" | "bullmq" = "cache") {
201202
AwardsModule,
202203
UserAccountModule,
203204
PreferredPlatformModule,
205+
RecapModule,
204206
],
205207
})
206208
export class AppModule implements NestModule {

src/awards/awards.controller.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { AuthGuard } from "../auth/auth.guard";
33
import { ApiTags } from "@nestjs/swagger";
44
import { AwardsService } from "./awards.service";
55
import { Public } from "../auth/public.decorator";
6+
import { AwardsResultService } from "./result/awards-result.service";
67

78
@Controller("awards")
89
@UseGuards(AuthGuard)
910
@ApiTags("awards")
1011
export class AwardsController {
11-
constructor(private readonly awardsService: AwardsService) {}
12+
constructor(
13+
private readonly awardsService: AwardsService,
14+
private readonly awardsResultService: AwardsResultService,
15+
) {}
1216

1317
@Get("events/:id")
1418
@Public()
@@ -33,4 +37,10 @@ export class AwardsController {
3337
public async getCategoriesByEventId(@Param("eventId") eventId: number) {
3438
return this.awardsService.getCategoriesByEventId(eventId);
3539
}
40+
41+
@Get(":eventId/results")
42+
@Public()
43+
public async getResultsByEventId(@Param("eventId") eventId: number) {
44+
return this.awardsResultService.getCategoryResultsByEventId(eventId);
45+
}
3646
}

src/awards/result/awards-result.processor.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ import { AwardsService } from "../awards.service";
44
import { WorkerHostProcessor } from "../../utils/WorkerHostProcessor";
55
import dayjs from "dayjs";
66
import { AwardsEvent } from "../entity/awards-event.entity";
7-
import { DataSource, Repository } from "typeorm";
8-
import { AwardsVote } from "../entity/awards-vote.entity";
9-
import { InjectRepository } from "@nestjs/typeorm";
10-
import { AwardsCategoryResult } from "../entity/awards-category-result.entity";
11-
import { AwardsCategoryResultWinner } from "../entity/awards-category-winner.entity";
7+
import { DataSource } from "typeorm";
128
import { AwardsResultService } from "./awards-result.service";
13-
import { AwardsCategory } from "../entity/awards-category.entity";
149
import { VotableAwardsCategoryDto } from "../dto/votable-awards-category.dto";
1510

1611
@Processor(AWARDS_RESULT_QUEUE_NAME)

src/awards/result/awards-result.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,19 @@ export class AwardsResultService {
2222
) {
2323
return await this.awardsCategoryResultWinnerRepository.save(entity);
2424
}
25+
26+
public async getCategoryResultsByEventId(eventId: number) {
27+
return this.awardsCategoryResultRepository.find({
28+
where: {
29+
category: {
30+
eventId: eventId,
31+
},
32+
},
33+
relations: {
34+
category: true,
35+
winners: true,
36+
},
37+
order: { category: { id: "ASC" }, winners: { position: "ASC" } },
38+
});
39+
}
2540
}

src/collections/collections-entries/collections-entries.service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HttpException, HttpStatus, Injectable } from "@nestjs/common";
22
import { CollectionEntry } from "./entities/collection-entry.entity";
33
import { InjectRepository } from "@nestjs/typeorm";
44
import {
5+
Between,
56
DeepPartial,
67
FindManyOptions,
78
FindOptionsRelations,
@@ -31,6 +32,7 @@ import { GameRepositoryService } from "../../game/game-repository/game-repositor
3132
import { FindRelatedCollectionEntriesResponseDto } from "./dto/find-related-collection-entries.dto";
3233
import { toMap } from "../../utils/toMap";
3334
import { DEFAULT_ORDERING_GAP } from "../../utils/ordering";
35+
import { Cacheable } from "../../utils/cacheable";
3436

3537
@Injectable()
3638
export class CollectionsEntriesService {
@@ -252,6 +254,24 @@ export class CollectionsEntriesService {
252254
});
253255
}
254256

257+
/**
258+
* Find all entries that have been <strong>created/modified</strong> in period.
259+
* @param userId
260+
* @param period
261+
*/
262+
async findAllByUserIdInPeriod(
263+
userId: string,
264+
period: { startDate: Date; endDate: Date },
265+
) {
266+
return this.collectionEntriesRepository.find({
267+
where: {
268+
libraryUserId: userId,
269+
updatedAt: Between(period.startDate, period.endDate),
270+
},
271+
relations: this.relations,
272+
});
273+
}
274+
255275
async findFavoritesByUserId(
256276
userId: string | undefined,
257277
targetUserId: string,

src/collections/collections.service.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@ export class CollectionsService {
6767
},
6868
relations: this.relations,
6969
});
70-
if (!targetUserCollections) {
71-
throw new HttpException(
72-
"No collection found.",
73-
HttpStatus.NOT_FOUND,
74-
);
75-
}
70+
7671
return targetUserCollections.filter((collection) => {
7772
return (
7873
collection.isPublic ||

src/follow/follow.service.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { FollowInfoRequestDto } from "./dto/follow-info-request.dto";
1212
import { buildBaseFindOptions } from "../utils/buildBaseFindOptions";
1313
import { TPaginationData } from "../utils/pagination/pagination-response.dto";
1414
import { ActivitiesQueueService } from "../activities/activities-queue/activities-queue.service";
15+
import { PeriodRange } from "../utils/period";
1516

1617
@Injectable()
1718
export class FollowService {
@@ -24,6 +25,28 @@ export class FollowService {
2425
private readonly activitiesQueueService: ActivitiesQueueService,
2526
) {}
2627

28+
public async countFollowers(
29+
userId: string,
30+
period: PeriodRange,
31+
): Promise<number> {
32+
const qb = this.userFollowRepository
33+
.createQueryBuilder("uf")
34+
.where("uf.followedUserId = :userId", { userId });
35+
36+
if (period.startDate) {
37+
qb.andWhere("uf.createdAt >= :startDate", {
38+
startDate: period.startDate,
39+
});
40+
}
41+
if (period.endDate) {
42+
qb.andWhere("uf.createdAt <= :endDate", {
43+
endDate: period.endDate,
44+
});
45+
}
46+
47+
return qb.getCount();
48+
}
49+
2750
public async findOneById(id: number) {
2851
return this.userFollowRepository.findOne({
2952
where: {
@@ -54,7 +77,7 @@ export class FollowService {
5477
);
5578
}
5679
try {
57-
const persistedEntry = await this.userFollowRepository.save({
80+
await this.userFollowRepository.save({
5881
follower: {
5982
userId: followerUserId,
6083
},

src/game/game-repository/create/game-repository-create.constants.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ import { GameLocalization } from "../entities/game-localization.entity";
1616
import { GameScreenshot } from "../entities/game-screenshot.entity";
1717
import { GameCover } from "../entities/game-cover.entity";
1818

19-
export const MANY_TO_MANY_RELATIONS: (keyof Game)[] = [
20-
"dlcs",
21-
"expansions",
22-
"expandedGames",
23-
"similarGames",
24-
"remakes",
25-
"remasters",
26-
"gameModes",
27-
"genres",
28-
"themes",
29-
"platforms",
30-
"playerPerspectives",
31-
"gameEngines",
32-
];
3319
/**
3420
* Look-up table between resource names and their respective entities
3521
* e.g.: Can be used to quickly retrieve the target repository for a resource

0 commit comments

Comments
 (0)