fix: address copilot review issues - explicit imports, trailing commas, 404 for not-found search, tests for available-films endpoint

Agent-Logs-Url: https://github.com/devitq/movienight-backend/sessions/60cd9b1b-e3e1-46a1-bfd9-04a75bd0d569

Co-authored-by: devitq <118541411+devitq@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-03 12:02:31 +00:00
committed by GitHub
co-authored by devitq
parent f563c3e7cf
commit b7a246e0b4
6 changed files with 317 additions and 174 deletions
@@ -57,10 +57,11 @@ class FilmController(
FilmResponse.fromDomain(
editFilmUseCase.edit(
id = id,
command = EditFilmCommand(
title = request.title,
description = request.description,
),
command =
EditFilmCommand(
title = request.title,
description = request.description,
),
),
)
@@ -73,12 +74,10 @@ class FilmController(
@GetMapping("/{id}")
fun getById(
@PathVariable id: UUID,
): FilmResponse =
FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
): FilmResponse = FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
@GetMapping
fun getAll(): List<FilmResponse> =
getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
fun getAll(): List<FilmResponse> = getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
@GetMapping("/search")
fun searchByTitle(
@@ -64,9 +64,10 @@ class FilmLibraryController(
fun getAllFilmsInLibrary(
@PathVariable userId: UUID,
): List<FilmResponse> {
val library = getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
val library =
getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
val film = getFilmByIdUseCase.getById(library.filmId)
return listOf(FilmResponse.fromDomain(film))
}
@@ -102,21 +103,23 @@ class FilmLibraryController(
fun getAvailableFilms(
@PathVariable userId: UUID,
): List<FilmResponse> {
val userLibrary = try {
getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
} catch (e: EntityNotFoundException) {
null
}
val userLibrary =
try {
getFilmLibraryUseCase.getLibrary(
GetFilmLibraryQuery(userId = userId),
)
} catch (e: EntityNotFoundException) {
null
}
val allFilms = getAllFilmsUseCase.getAll()
val availableFilms = if (userLibrary != null) {
allFilms.filter { it.id != userLibrary.filmId }
} else {
allFilms
}
val availableFilms =
if (userLibrary != null) {
allFilms.filter { it.id != userLibrary.filmId }
} else {
allFilms
}
return availableFilms.map { FilmResponse.fromDomain(it) }
}