style(): yet another formatting improvements
This commit is contained in:
+4
-1
@@ -70,7 +70,10 @@ class FilmLibraryRepository(
|
||||
): FilmLibrary? {
|
||||
val entries =
|
||||
jdbc.query(
|
||||
"SELECT id, user_id, film_id, comment, is_viewed, watched_at FROM favorites WHERE user_id = ? AND film_id = ?",
|
||||
"""
|
||||
SELECT id, user_id, film_id, comment, is_viewed, watched_at
|
||||
FROM favorites WHERE user_id = ? AND film_id = ?
|
||||
""".trimIndent(),
|
||||
filmLibraryRowMapper,
|
||||
userId,
|
||||
filmId,
|
||||
|
||||
+37
-5
@@ -33,8 +33,11 @@ class FilmRatingRepository(
|
||||
jdbc.update(
|
||||
"""
|
||||
UPDATE film_ratings
|
||||
SET score = ?, note = ?, updated_at = ?
|
||||
WHERE user_id = ? AND film_id = ?
|
||||
SET score = ?,
|
||||
note = ?,
|
||||
updated_at = ?
|
||||
WHERE user_id = ?
|
||||
AND film_id = ?
|
||||
""".trimIndent(),
|
||||
entity.score,
|
||||
entity.note,
|
||||
@@ -46,7 +49,15 @@ class FilmRatingRepository(
|
||||
if (updatedRows == 0) {
|
||||
jdbc.update(
|
||||
"""
|
||||
INSERT INTO film_ratings (id, user_id, film_id, score, note, created_at, updated_at)
|
||||
INSERT INTO film_ratings (
|
||||
id,
|
||||
user_id,
|
||||
film_id,
|
||||
score,
|
||||
note,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""".trimIndent(),
|
||||
entity.id,
|
||||
@@ -65,7 +76,17 @@ class FilmRatingRepository(
|
||||
override fun findByUserId(userId: UUID): List<FilmRating> =
|
||||
jdbc
|
||||
.query(
|
||||
"SELECT id, user_id, film_id, score, note, created_at, updated_at FROM film_ratings WHERE user_id = ?",
|
||||
"""
|
||||
SELECT id,
|
||||
user_id,
|
||||
film_id,
|
||||
score,
|
||||
note,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM film_ratings
|
||||
WHERE user_id = ?
|
||||
""".trimIndent(),
|
||||
rowMapper,
|
||||
userId,
|
||||
).map { it.toDomain() }
|
||||
@@ -76,7 +97,18 @@ class FilmRatingRepository(
|
||||
): FilmRating? =
|
||||
jdbc
|
||||
.query(
|
||||
"SELECT id, user_id, film_id, score, note, created_at, updated_at FROM film_ratings WHERE user_id = ? AND film_id = ?",
|
||||
"""
|
||||
SELECT id,
|
||||
user_id,
|
||||
film_id,
|
||||
score,
|
||||
note,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM film_ratings
|
||||
WHERE user_id = ?
|
||||
AND film_id = ?
|
||||
""".trimIndent(),
|
||||
rowMapper,
|
||||
userId,
|
||||
filmId,
|
||||
|
||||
+101
-7
@@ -41,7 +41,18 @@ class FilmRepository(
|
||||
jdbc.update(
|
||||
"""
|
||||
UPDATE films
|
||||
SET title = ?, description = ?, content_type = ?, release_year = ?, genres = ?, cast_members = ?, directors = ?, imdb_rating = ?, platform_rating = ?, external_url = ?, jellyfin_item_id = ?, jellyfin_library_id = ?
|
||||
SET title = ?,
|
||||
description = ?,
|
||||
content_type = ?,
|
||||
release_year = ?,
|
||||
genres = ?,
|
||||
cast_members = ?,
|
||||
directors = ?,
|
||||
imdb_rating = ?,
|
||||
platform_rating = ?,
|
||||
external_url = ?,
|
||||
jellyfin_item_id = ?,
|
||||
jellyfin_library_id = ?
|
||||
WHERE id = ?
|
||||
""".trimIndent(),
|
||||
film.title,
|
||||
@@ -61,7 +72,21 @@ class FilmRepository(
|
||||
if (updatedRows == 0) {
|
||||
jdbc.update(
|
||||
"""
|
||||
INSERT INTO films (id, title, description, content_type, release_year, genres, cast_members, directors, imdb_rating, platform_rating, external_url, jellyfin_item_id, jellyfin_library_id)
|
||||
INSERT INTO films (
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
content_type,
|
||||
release_year,
|
||||
genres,
|
||||
cast_members,
|
||||
directors,
|
||||
imdb_rating,
|
||||
platform_rating,
|
||||
external_url,
|
||||
jellyfin_item_id,
|
||||
jellyfin_library_id
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""".trimIndent(),
|
||||
film.id,
|
||||
@@ -85,7 +110,23 @@ class FilmRepository(
|
||||
override fun findById(id: UUID): Film? {
|
||||
val films =
|
||||
jdbc.query(
|
||||
"SELECT id, title, description, content_type, release_year, genres, cast_members, directors, imdb_rating, platform_rating, external_url, jellyfin_item_id, jellyfin_library_id FROM films WHERE id = ?",
|
||||
"""
|
||||
SELECT id,
|
||||
title,
|
||||
description,
|
||||
content_type,
|
||||
release_year,
|
||||
genres,
|
||||
cast_members,
|
||||
directors,
|
||||
imdb_rating,
|
||||
platform_rating,
|
||||
external_url,
|
||||
jellyfin_item_id,
|
||||
jellyfin_library_id
|
||||
FROM films
|
||||
WHERE id = ?
|
||||
""".trimIndent(),
|
||||
filmRowMapper,
|
||||
id,
|
||||
)
|
||||
@@ -95,7 +136,23 @@ class FilmRepository(
|
||||
override fun findByJellyfinItemId(jellyfinItemId: String): Film? {
|
||||
val films =
|
||||
jdbc.query(
|
||||
"SELECT id, title, description, content_type, release_year, genres, cast_members, directors, imdb_rating, platform_rating, external_url, jellyfin_item_id, jellyfin_library_id FROM films WHERE jellyfin_item_id = ?",
|
||||
"""
|
||||
SELECT id,
|
||||
title,
|
||||
description,
|
||||
content_type,
|
||||
release_year,
|
||||
genres,
|
||||
cast_members,
|
||||
directors,
|
||||
imdb_rating,
|
||||
platform_rating,
|
||||
external_url,
|
||||
jellyfin_item_id,
|
||||
jellyfin_library_id
|
||||
FROM films
|
||||
WHERE jellyfin_item_id = ?
|
||||
""".trimIndent(),
|
||||
filmRowMapper,
|
||||
jellyfinItemId,
|
||||
)
|
||||
@@ -105,7 +162,23 @@ class FilmRepository(
|
||||
override fun findByJellyfinLibraryId(jellyfinLibraryId: String): Film? {
|
||||
val films =
|
||||
jdbc.query(
|
||||
"SELECT id, title, description, content_type, release_year, genres, cast_members, directors, imdb_rating, platform_rating, external_url, jellyfin_item_id, jellyfin_library_id FROM films WHERE jellyfin_library_id = ?",
|
||||
"""
|
||||
SELECT id,
|
||||
title,
|
||||
description,
|
||||
content_type,
|
||||
release_year,
|
||||
genres,
|
||||
cast_members,
|
||||
directors,
|
||||
imdb_rating,
|
||||
platform_rating,
|
||||
external_url,
|
||||
jellyfin_item_id,
|
||||
jellyfin_library_id
|
||||
FROM films
|
||||
WHERE jellyfin_library_id = ?
|
||||
""".trimIndent(),
|
||||
filmRowMapper,
|
||||
jellyfinLibraryId,
|
||||
)
|
||||
@@ -114,11 +187,32 @@ class FilmRepository(
|
||||
|
||||
override fun findAll(): List<Film> =
|
||||
jdbc.query(
|
||||
"SELECT id, title, description, content_type, release_year, genres, cast_members, directors, imdb_rating, platform_rating, external_url, jellyfin_item_id, jellyfin_library_id FROM films",
|
||||
"""
|
||||
SELECT id,
|
||||
title,
|
||||
description,
|
||||
content_type,
|
||||
release_year,
|
||||
genres,
|
||||
cast_members,
|
||||
directors,
|
||||
imdb_rating,
|
||||
platform_rating,
|
||||
external_url,
|
||||
jellyfin_item_id,
|
||||
jellyfin_library_id
|
||||
FROM films
|
||||
""".trimIndent(),
|
||||
filmRowMapper,
|
||||
)
|
||||
|
||||
override fun deleteById(id: UUID) {
|
||||
jdbc.update("DELETE FROM films WHERE id = ?", id)
|
||||
jdbc.update(
|
||||
"""
|
||||
DELETE FROM films
|
||||
WHERE id = ?
|
||||
""".trimIndent(),
|
||||
id,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+29
-4
@@ -30,7 +30,11 @@ class JellyfinSyncStateRepository(
|
||||
jdbc.update(
|
||||
"""
|
||||
UPDATE jellyfin_sync_state
|
||||
SET last_synced_at = ?, last_successful_sync_at = ?, last_error = ?, synced_item_count = ?, updated_at = CURRENT_TIMESTAMP
|
||||
SET last_synced_at = ?,
|
||||
last_successful_sync_at = ?,
|
||||
last_error = ?,
|
||||
synced_item_count = ?,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE user_id = ?
|
||||
""".trimIndent(),
|
||||
entity.lastSyncedAt,
|
||||
@@ -43,7 +47,13 @@ class JellyfinSyncStateRepository(
|
||||
if (updatedRows == 0) {
|
||||
jdbc.update(
|
||||
"""
|
||||
INSERT INTO jellyfin_sync_state (user_id, last_synced_at, last_successful_sync_at, last_error, synced_item_count)
|
||||
INSERT INTO jellyfin_sync_state (
|
||||
user_id,
|
||||
last_synced_at,
|
||||
last_successful_sync_at,
|
||||
last_error,
|
||||
synced_item_count
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""".trimIndent(),
|
||||
entity.userId,
|
||||
@@ -60,7 +70,15 @@ class JellyfinSyncStateRepository(
|
||||
override fun findByUserId(userId: UUID): JellyfinSyncState? =
|
||||
jdbc
|
||||
.query(
|
||||
"SELECT user_id, last_synced_at, last_successful_sync_at, last_error, synced_item_count FROM jellyfin_sync_state WHERE user_id = ?",
|
||||
"""
|
||||
SELECT user_id,
|
||||
last_synced_at,
|
||||
last_successful_sync_at,
|
||||
last_error,
|
||||
synced_item_count
|
||||
FROM jellyfin_sync_state
|
||||
WHERE user_id = ?
|
||||
""".trimIndent(),
|
||||
rowMapper,
|
||||
userId,
|
||||
).firstOrNull()
|
||||
@@ -69,7 +87,14 @@ class JellyfinSyncStateRepository(
|
||||
override fun findAll(): List<JellyfinSyncState> =
|
||||
jdbc
|
||||
.query(
|
||||
"SELECT user_id, last_synced_at, last_successful_sync_at, last_error, synced_item_count FROM jellyfin_sync_state",
|
||||
"""
|
||||
SELECT user_id,
|
||||
last_synced_at,
|
||||
last_successful_sync_at,
|
||||
last_error,
|
||||
synced_item_count
|
||||
FROM jellyfin_sync_state
|
||||
""".trimIndent(),
|
||||
rowMapper,
|
||||
).map { it.toDomain() }
|
||||
}
|
||||
|
||||
+26
-3
@@ -32,7 +32,12 @@ class UserPreferencesRepository(
|
||||
jdbc.update(
|
||||
"""
|
||||
UPDATE user_preferences
|
||||
SET weighted_genres = ?, plot_types = ?, eras = ?, cast_and_directors = ?, moods = ?, content_types = ?
|
||||
SET weighted_genres = ?,
|
||||
plot_types = ?,
|
||||
eras = ?,
|
||||
cast_and_directors = ?,
|
||||
moods = ?,
|
||||
content_types = ?
|
||||
WHERE user_id = ?
|
||||
""".trimIndent(),
|
||||
entity.weightedGenres,
|
||||
@@ -47,7 +52,15 @@ class UserPreferencesRepository(
|
||||
if (updatedRows == 0) {
|
||||
jdbc.update(
|
||||
"""
|
||||
INSERT INTO user_preferences (user_id, weighted_genres, plot_types, eras, cast_and_directors, moods, content_types)
|
||||
INSERT INTO user_preferences (
|
||||
user_id,
|
||||
weighted_genres,
|
||||
plot_types,
|
||||
eras,
|
||||
cast_and_directors,
|
||||
moods,
|
||||
content_types
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""".trimIndent(),
|
||||
entity.userId,
|
||||
@@ -66,7 +79,17 @@ class UserPreferencesRepository(
|
||||
override fun findByUserId(userId: UUID): UserPreferences? =
|
||||
jdbc
|
||||
.query(
|
||||
"SELECT user_id, weighted_genres, plot_types, eras, cast_and_directors, moods, content_types FROM user_preferences WHERE user_id = ?",
|
||||
"""
|
||||
SELECT user_id,
|
||||
weighted_genres,
|
||||
plot_types,
|
||||
eras,
|
||||
cast_and_directors,
|
||||
moods,
|
||||
content_types
|
||||
FROM user_preferences
|
||||
WHERE user_id = ?
|
||||
""".trimIndent(),
|
||||
rowMapper,
|
||||
userId,
|
||||
).firstOrNull()
|
||||
|
||||
Reference in New Issue
Block a user