Skip to content
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
8 changes: 6 additions & 2 deletions apps/api/src/app/movies/dto/movie-credits.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ export class MovieCastingDto {
@IsInt()
personId!: number;

@ApiProperty({ description: 'The primary ordering index for this actor' })
@ApiProperty({
description: 'The primary ordering index for this actor',
nullable: true,
})
@Expose()
@IsNullable()
@IsInt()
order!: number;
order!: number | null;

@ApiProperty({ type: () => PersonCompactDto })
@Expose()
Expand Down
13 changes: 8 additions & 5 deletions apps/api/src/app/movies/movies.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ export class MoviesService {
personId: tmdbMovieCredit.personId,
order: sql<number>`MIN(${tmdbMovieRole.order})`.as('min_order'),
roles: sql<Pick<typeof tmdbMovieRole.$inferSelect, 'character' | 'order'>[]>`
jsonb_agg(
jsonb_build_object(
'character', ${tmdbMovieRole.character},
'order', ${tmdbMovieRole.order}
) ORDER BY ${tmdbMovieRole.order} ASC
COALESCE(
jsonb_agg(
jsonb_build_object(
'character', ${tmdbMovieRole.character},
'order', ${tmdbMovieRole.order}
) ORDER BY ${tmdbMovieRole.order} ASC
) FILTER (WHERE ${tmdbMovieRole.creditId} IS NOT NULL),
'[]'::jsonb
)
`.as('roles_agg'),
})
Expand Down
8 changes: 6 additions & 2 deletions apps/api/src/app/tv-series/dto/tv-series-credits.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ export class TvSeriesCastingDto {
@IsInt()
personId!: number;

@ApiProperty({ description: 'The primary ordering index for this actor' })
@ApiProperty({
description: 'The primary ordering index for this actor',
nullable: true,
})
@Expose()
@IsNullable()
@IsInt()
order!: number;
order!: number | null;

@ApiProperty({ type: () => PersonCompactDto })
@Expose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IsString,
ValidateNested,
} from 'class-validator';
import { IsNullable } from '../../../../common/decorators/is-nullable.decorator';
import { Expose, Transform, Type } from 'class-transformer';
import { PaginatedResponseDto, PaginationQueryDto } from '../../../../common/dto/pagination.dto';
import { SortOrder } from '../../../../common/dto/sort.dto';
Expand Down Expand Up @@ -84,10 +85,11 @@ export class TvEpisodeDto {
@IsString()
overview!: string | null;

@ApiProperty({ example: 60 })
@ApiProperty({ example: 60, nullable: true })
@Expose()
@IsNullable()
@IsInt()
runtime!: number;
runtime!: number | null;

@ApiProperty({ example: '101', nullable: true })
@Expose()
Expand Down
13 changes: 8 additions & 5 deletions apps/api/src/app/tv-series/tv-series.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ export class TvSeriesService {
personId: tmdbTvSeriesCredit.personId,
order: sql<number>`MIN(${tmdbTvSeriesRole.order})`.as('min_order'),
roles: sql<Pick<typeof tmdbTvSeriesRole.$inferSelect, 'character' | 'order'>[]>`
jsonb_agg(
jsonb_build_object(
'character', ${tmdbTvSeriesRole.character},
'order', ${tmdbTvSeriesRole.order}
) ORDER BY ${tmdbTvSeriesRole.order} ASC
COALESCE(
jsonb_agg(
jsonb_build_object(
'character', ${tmdbTvSeriesRole.character},
'order', ${tmdbTvSeriesRole.order}
) ORDER BY ${tmdbTvSeriesRole.order} ASC
) FILTER (WHERE ${tmdbTvSeriesRole.creditId} IS NOT NULL),
'[]'::jsonb
)
`.as('roles_agg'),
})
Expand Down
Loading