From 1a00989de7ca02637ce583129ed81c0e5b4d25e9 Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Wed, 27 Mar 2024 18:52:23 +0100 Subject: [PATCH] Add config for anime episode size limit on site --- .../controllers/site/SiteController.kt | 7 +++++- .../entities/enums/ConfigPropertyKey.kt | 1 + .../db/changelog/2024/03/08-changelog.xml | 24 +++++++++++++++++++ .../db/changelog/db.changelog-master.xml | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/changelog/2024/03/08-changelog.xml diff --git a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt index c1d0bf0c..fed1536d 100644 --- a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt +++ b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt @@ -3,9 +3,11 @@ package fr.shikkanime.controllers.site import com.google.inject.Inject import fr.shikkanime.dtos.AnimeDto import fr.shikkanime.entities.SortParameter +import fr.shikkanime.entities.enums.ConfigPropertyKey import fr.shikkanime.entities.enums.CountryCode import fr.shikkanime.entities.enums.Link import fr.shikkanime.services.caches.AnimeCacheService +import fr.shikkanime.services.caches.ConfigCacheService import fr.shikkanime.services.caches.EpisodeCacheService import fr.shikkanime.services.caches.SimulcastCacheService import fr.shikkanime.utils.routes.Controller @@ -28,6 +30,9 @@ class SiteController { @Inject private lateinit var simulcastCacheService: SimulcastCacheService + @Inject + private lateinit var configCacheService: ConfigCacheService + @Path("404") @Get private fun error404(): Response { @@ -134,7 +139,7 @@ class SiteController { SortParameter("langType", SortParameter.Order.ASC), ), 1, - 24 + configCacheService.getValueAsInt(ConfigPropertyKey.ANIME_EPISODES_SIZE_LIMIT, 24) )!!.data ) ) diff --git a/src/main/kotlin/fr/shikkanime/entities/enums/ConfigPropertyKey.kt b/src/main/kotlin/fr/shikkanime/entities/enums/ConfigPropertyKey.kt index be5dd5f4..575116f9 100644 --- a/src/main/kotlin/fr/shikkanime/entities/enums/ConfigPropertyKey.kt +++ b/src/main/kotlin/fr/shikkanime/entities/enums/ConfigPropertyKey.kt @@ -28,4 +28,5 @@ enum class ConfigPropertyKey(val key: String) { ANALYTICS_SCRIPT("analytics_script"), CRUNCHYROLL_FETCH_API_SIZE("crunchyroll_fetch_api_size"), ANIMATION_DITIGAL_NETWORK_SIMULCAST_DETECTION_REGEX("animation_digital_network_simulcast_detection_regex"), + ANIME_EPISODES_SIZE_LIMIT("anime_episodes_size_limit"), } \ No newline at end of file diff --git a/src/main/resources/db/changelog/2024/03/08-changelog.xml b/src/main/resources/db/changelog/2024/03/08-changelog.xml new file mode 100644 index 00000000..13cb7449 --- /dev/null +++ b/src/main/resources/db/changelog/2024/03/08-changelog.xml @@ -0,0 +1,24 @@ + + + + + + + + SELECT COUNT(*) + FROM config + WHERE property_key = 'anime_episodes_size_limit' + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/db/changelog/db.changelog-master.xml b/src/main/resources/db/changelog/db.changelog-master.xml index df345569..7ec47419 100644 --- a/src/main/resources/db/changelog/db.changelog-master.xml +++ b/src/main/resources/db/changelog/db.changelog-master.xml @@ -37,4 +37,5 @@ + \ No newline at end of file