Skip to content

feat(apps/server/rest): find-video history#107

Merged
99mini merged 14 commits intomainfrom
server-rest/feat/find-video-log
Jun 28, 2025
Merged

feat(apps/server/rest): find-video history#107
99mini merged 14 commits intomainfrom
server-rest/feat/find-video-log

Conversation

@99mini
Copy link
Copy Markdown
Owner

@99mini 99mini commented Jun 28, 2025

No description provided.

@99mini 99mini self-assigned this Jun 28, 2025
Copilot AI review requested due to automatic review settings June 28, 2025 08:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new “find-video” history feature to the REST API, including endpoints to create, list, and delete user history entries, as well as a daily batch job to clean up old deleted logs. It also updates CORS settings, deployment scripts, and the Prisma schema to support these new models.

  • Introduce HistoryService, HistoryController, DTOs, and entities for CRUD of video/image history.
  • Add a scheduled batch job to remove “deleted” logs older than one month.
  • Integrate the new module into the app’s main module and update CORS origins and deploy scripts.

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/modules/find-video/history/history.service.ts Implements CRUD operations for user history via Prisma
src/modules/find-video/history/history.controller.ts Exposes REST endpoints for history create, get, and delete
src/modules/find-video/history/dto/*.dto.ts Defines request/query DTOs for history APIs
src/modules/find-video/history/entities/history.entity.ts Defines response entities for history API
prisma/schema.prisma Adds FindVideoUser and FindVideoLog models
src/modules/find-video/batch/find-video-batch.service.ts Adds a cron job to purge old deleted logs
src/main.ts Updates CORS to allow additional Chrome extension origins
.scripts/deploy.sh Enhances deploy script to support a “--clean” flag
src/modules/auth/guards/api-key.guard.ts Refactors API key guard initialization
app.module.ts Registers the new FindVideoModule
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (3)

apps/server/rest/src/modules/find-video/history/history.service.ts:16

  • [nitpick] The parameter name historys is a nonstandard pluralization. Consider renaming it to histories for clarity and consistency.
  async createHistoryBulk({ historys }: { historys: HistoryDto[] }) {

apps/server/rest/src/modules/find-video/history/history.controller.ts:85

  • userId is a query parameter, but @ApiParam documents path parameters. Switch to @ApiQuery for accurate Swagger docs.
  @ApiParam({ name: 'userId', required: true })

apps/server/rest/src/modules/find-video/history/dto/get-history.dto.ts:5

  • GetHistoryDto properties currently lack validation decorators. Add class-validator annotations (e.g., @IsString(), @IsNotEmpty(), @IsNumber()) or use @Type() pipes for robust DTO validation.
  userId: string;

Comment thread apps/server/rest/src/modules/find-video/history/history.service.ts Outdated
*/
async deleteHistory({ userId, historyId }: { userId: string; historyId: string }) {
try {
await this.prismaService.findVideoLog.update({
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

Prisma's update requires a unique identifier for where. Specifying both id and userId without a compound unique index will error. Use updateMany or add a compound unique constraint on (id, userId).

Copilot uses AI. Check for mistakes.
@ApiResponse({ status: HttpStatus.OK, type: HistoryDto })
@ApiInternalServerErrorResponse({ description: 'Internal server error' })
@ApiBadRequestResponse({ description: 'Bad request body is required' })
async createHistory(@Res() res: Response, @Body() body: HistoryDto[] | HistoryDto, @Query('bulk') bulk: boolean) {
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

Query parameters remain strings by default. Consider using @Query('bulk', ParseBoolPipe) bulk: boolean to ensure bulk is properly parsed to a boolean.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +9
const oneMonthAgo = now;
oneMonthAgo.setMonth(now.getMonth() - 1);
const fifteenDaysAgo = now;
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

oneMonthAgo and fifteenDaysAgo are both assigned the same Date object, so mutations affect both. Clone the date before adjusting, e.g. const oneMonthAgo = new Date(now);.

Suggested change
const oneMonthAgo = now;
oneMonthAgo.setMonth(now.getMonth() - 1);
const fifteenDaysAgo = now;
const oneMonthAgo = new Date(now);
oneMonthAgo.setMonth(now.getMonth() - 1);
const fifteenDaysAgo = new Date(now);

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +11
const fifteenDaysAgo = now;
fifteenDaysAgo.setDate(now.getDate() - 15);

Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

The variable fifteenDaysAgo is defined but never used. Consider removing it to avoid confusion.

Suggested change
const fifteenDaysAgo = now;
fifteenDaysAgo.setDate(now.getDate() - 15);

Copilot uses AI. Check for mistakes.
@99mini 99mini merged commit 62075bb into main Jun 28, 2025
1 check passed
@99mini 99mini deleted the server-rest/feat/find-video-log branch June 28, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants