Skip to content

Commit

Permalink
Add config for anime episode size limit on site
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Mar 27, 2024
1 parent fa5894d commit 5bfb481
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -134,7 +139,7 @@ class SiteController {
SortParameter("langType", SortParameter.Order.ASC),
),
1,
24
configCacheService.getValueAsInt(ConfigPropertyKey.ANIME_EPISODES_SIZE_LIMIT, 24)
)!!.data
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
24 changes: 24 additions & 0 deletions src/main/resources/db/changelog/2024/03/08-changelog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">
<property global="false" name="id" value="1711561869401"/>
<property global="false" name="author" value="Ziedelth"/>

<changeSet id="${id}-1" author="${author}" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*)
FROM config
WHERE property_key = 'anime_episodes_size_limit'</sqlCheck>
</preConditions>

<insert tableName="config">
<column name="uuid" valueComputed="gen_random_uuid()"/>
<column name="property_key" value="anime_episodes_size_limit"/>
<column name="property_value" value="24"/>
</insert>
</changeSet>
</databaseChangeLog>
1 change: 1 addition & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
<include file="/db/changelog/2024/03/05-changelog.xml"/>
<include file="/db/changelog/2024/03/06-changelog.xml"/>
<include file="/db/changelog/2024/03/07-changelog.xml"/>
<include file="/db/changelog/2024/03/08-changelog.xml"/>
</databaseChangeLog>

0 comments on commit 5bfb481

Please sign in to comment.