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

[Backend] Store scraped movie data #10

Merged
merged 13 commits into from
Apr 28, 2024
Merged

[Backend] Store scraped movie data #10

merged 13 commits into from
Apr 28, 2024

Conversation

mathiasberggren
Copy link
Owner

@mathiasberggren mathiasberggren commented Apr 9, 2024

Description

API

  • Add support for storing scraped movie data by adding Movie and MovieTitles tables in the DB schema

Motivation and Context

How Has This Been Tested?

Running locally and CI

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mathiasberggren mathiasberggren changed the title (feat): Enable having multiple schema files for prisma before https:/… (feat): Basic database schemas Apr 9, 2024
@mathiasberggren mathiasberggren changed the title (feat): Basic database schemas [Backend]: Basic database schemas Apr 11, 2024
@mathiasberggren mathiasberggren changed the title [Backend]: Basic database schemas [Backend] Basic database schemas Apr 11, 2024
@mathiasberggren mathiasberggren changed the title [Backend] Basic database schemas [Backend] Store scraped movie data Apr 11, 2024
async create (@Body() createMovieDto: CreateMovieDto) {
if (createMovieDto.movieTitles.length === 0) {
throw new BadRequestException('At least one movie title is required')
}
Copy link
Collaborator

@rasouza rasouza Apr 15, 2024

Choose a reason for hiding this comment

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

You can delegate the validation responsibility to the DTO instead of the Controller. I left a suggestion up there that you can remove this if here

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good call! Will remove this

Comment on lines +2 to +14
export class CreateMovieDto {
genre: string
director: string
duration: number
subtitles: string[]
releaseDate: Date
movieTitles: CreateMovieTitleDto[]
}

export class CreateMovieTitleDto {
language: string
title: string
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export class CreateMovieDto {
genre: string
director: string
duration: number
subtitles: string[]
releaseDate: Date
movieTitles: CreateMovieTitleDto[]
}
export class CreateMovieTitleDto {
language: string
title: string
}
import { createZodDto } from "nestjs-zod"
import { z } from "nestjs-zod/z"
const CreateMovieSchema = z.object({
genre: z.string(),
director: z.string(),
duration: z.number().int(),
subtitles: z.string().array().optional(),
releaseDate: z.date(),
movieTitles: z.object({
language: z.string(),
title: z.string()
}).array().nonempty()
})
export class CreateMovieDto extends createZodDto(CreateMovieSchema) {}

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think this is mainly since I didn't push the pairing session we did :D will do now

Copy link
Owner Author

Choose a reason for hiding this comment

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

Realized now they come in this branch, would it be OK to merge this branch to master as is and then merge the other one with the DTO changes removing the "if" above?

Copy link
Collaborator

Choose a reason for hiding this comment

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

absolutely, no worries

@rasouza
Copy link
Collaborator

rasouza commented Apr 25, 2024

Sorry the delay 😅

@mathiasberggren mathiasberggren merged commit aa4f0a9 into main Apr 28, 2024
1 check passed
@mathiasberggren mathiasberggren deleted the basic-database branch April 28, 2024 17:21
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