style(): yet another formatting improvements

This commit is contained in:
ITQ
2026-05-20 03:24:37 +03:00
parent 967c1b818c
commit b94599a652
6 changed files with 206 additions and 20 deletions
+9
View File
@@ -7,3 +7,12 @@ comments:
active: false active: false
UndocumentedPublicProperty: UndocumentedPublicProperty:
active: false active: false
style:
MagicNumber:
active: false
ReturnCount:
max: 3
complexity:
active: false
@@ -70,7 +70,10 @@ class FilmLibraryRepository(
): FilmLibrary? { ): FilmLibrary? {
val entries = val entries =
jdbc.query( 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, filmLibraryRowMapper,
userId, userId,
filmId, filmId,
@@ -33,8 +33,11 @@ class FilmRatingRepository(
jdbc.update( jdbc.update(
""" """
UPDATE film_ratings UPDATE film_ratings
SET score = ?, note = ?, updated_at = ? SET score = ?,
WHERE user_id = ? AND film_id = ? note = ?,
updated_at = ?
WHERE user_id = ?
AND film_id = ?
""".trimIndent(), """.trimIndent(),
entity.score, entity.score,
entity.note, entity.note,
@@ -46,7 +49,15 @@ class FilmRatingRepository(
if (updatedRows == 0) { if (updatedRows == 0) {
jdbc.update( 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 (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
""".trimIndent(), """.trimIndent(),
entity.id, entity.id,
@@ -65,7 +76,17 @@ class FilmRatingRepository(
override fun findByUserId(userId: UUID): List<FilmRating> = override fun findByUserId(userId: UUID): List<FilmRating> =
jdbc jdbc
.query( .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, rowMapper,
userId, userId,
).map { it.toDomain() } ).map { it.toDomain() }
@@ -76,7 +97,18 @@ class FilmRatingRepository(
): FilmRating? = ): FilmRating? =
jdbc jdbc
.query( .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, rowMapper,
userId, userId,
filmId, filmId,
@@ -41,7 +41,18 @@ class FilmRepository(
jdbc.update( jdbc.update(
""" """
UPDATE films 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 = ? WHERE id = ?
""".trimIndent(), """.trimIndent(),
film.title, film.title,
@@ -61,7 +72,21 @@ class FilmRepository(
if (updatedRows == 0) { if (updatedRows == 0) {
jdbc.update( 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""".trimIndent(), """.trimIndent(),
film.id, film.id,
@@ -85,7 +110,23 @@ class FilmRepository(
override fun findById(id: UUID): Film? { override fun findById(id: UUID): Film? {
val films = val films =
jdbc.query( 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, filmRowMapper,
id, id,
) )
@@ -95,7 +136,23 @@ class FilmRepository(
override fun findByJellyfinItemId(jellyfinItemId: String): Film? { override fun findByJellyfinItemId(jellyfinItemId: String): Film? {
val films = val films =
jdbc.query( 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, filmRowMapper,
jellyfinItemId, jellyfinItemId,
) )
@@ -105,7 +162,23 @@ class FilmRepository(
override fun findByJellyfinLibraryId(jellyfinLibraryId: String): Film? { override fun findByJellyfinLibraryId(jellyfinLibraryId: String): Film? {
val films = val films =
jdbc.query( 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, filmRowMapper,
jellyfinLibraryId, jellyfinLibraryId,
) )
@@ -114,11 +187,32 @@ class FilmRepository(
override fun findAll(): List<Film> = override fun findAll(): List<Film> =
jdbc.query( 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, filmRowMapper,
) )
override fun deleteById(id: UUID) { override fun deleteById(id: UUID) {
jdbc.update("DELETE FROM films WHERE id = ?", id) jdbc.update(
"""
DELETE FROM films
WHERE id = ?
""".trimIndent(),
id,
)
} }
} }
@@ -30,7 +30,11 @@ class JellyfinSyncStateRepository(
jdbc.update( jdbc.update(
""" """
UPDATE jellyfin_sync_state 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 = ? WHERE user_id = ?
""".trimIndent(), """.trimIndent(),
entity.lastSyncedAt, entity.lastSyncedAt,
@@ -43,7 +47,13 @@ class JellyfinSyncStateRepository(
if (updatedRows == 0) { if (updatedRows == 0) {
jdbc.update( 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 (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?)
""".trimIndent(), """.trimIndent(),
entity.userId, entity.userId,
@@ -60,7 +70,15 @@ class JellyfinSyncStateRepository(
override fun findByUserId(userId: UUID): JellyfinSyncState? = override fun findByUserId(userId: UUID): JellyfinSyncState? =
jdbc jdbc
.query( .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, rowMapper,
userId, userId,
).firstOrNull() ).firstOrNull()
@@ -69,7 +87,14 @@ class JellyfinSyncStateRepository(
override fun findAll(): List<JellyfinSyncState> = override fun findAll(): List<JellyfinSyncState> =
jdbc jdbc
.query( .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, rowMapper,
).map { it.toDomain() } ).map { it.toDomain() }
} }
@@ -32,7 +32,12 @@ class UserPreferencesRepository(
jdbc.update( jdbc.update(
""" """
UPDATE user_preferences 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 = ? WHERE user_id = ?
""".trimIndent(), """.trimIndent(),
entity.weightedGenres, entity.weightedGenres,
@@ -47,7 +52,15 @@ class UserPreferencesRepository(
if (updatedRows == 0) { if (updatedRows == 0) {
jdbc.update( 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 (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
""".trimIndent(), """.trimIndent(),
entity.userId, entity.userId,
@@ -66,7 +79,17 @@ class UserPreferencesRepository(
override fun findByUserId(userId: UUID): UserPreferences? = override fun findByUserId(userId: UUID): UserPreferences? =
jdbc jdbc
.query( .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, rowMapper,
userId, userId,
).firstOrNull() ).firstOrNull()