diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 7d2a6cb..8bf1867 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -2,9 +2,9 @@ name: Explode Build Test on: push: - branches: [ "master" ] + branches: [ "v3" ] pull_request: - branches: [ "master" ] + branches: [ "v3" ] permissions: contents: read @@ -15,18 +15,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'temurin' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v6 - name: Build with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: build -x test + run: ./gradlew build -x test - name: Upload Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Explode path: | diff --git a/DEV_README.md b/DEV_README.md index e454391..73a06fa 100644 --- a/DEV_README.md +++ b/DEV_README.md @@ -14,3 +14,14 @@ ### 数据提供 Labyrinth +## Artifacts + +The final JARs you can get from this project are: + +- explode-all-(version).jar +- explode-all-(version)-all.jar +- explode-proxy-(version).jar +- explode-proxy-(version)-all.jar + +For server deploying, use explode-all-(version)-all.jar, and run it with + `java -cp explode-all-(version)-ALL.jar explode2.booster.BoosterMainKt` diff --git a/README.md b/README.md index 1b70f9e..78948ce 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Or join our [Discord](https://discord.gg/BS5UZnsvVZ) server for English support. There is no well-documented code nor a helpful documentation to set up and use, so you need to figure it out by yourself or simply contact the contributors for help. +Maybe you can refer to DEV_README.md? + ### Env Vars *DB_URL*: The connection string to the database. \ No newline at end of file diff --git a/booster/src/main/kotlin/explode2/booster/MainLogics.kt b/booster/src/main/kotlin/explode2/booster/MainLogics.kt index 6adc8ec..9470328 100644 --- a/booster/src/main/kotlin/explode2/booster/MainLogics.kt +++ b/booster/src/main/kotlin/explode2/booster/MainLogics.kt @@ -31,7 +31,7 @@ object MainLogics : KoinComponent { // output Maze provider info gqlLogger.info("Using Maze: ${Colors.TianYi}${MazeProvider.getProvider().javaClass.canonicalName}") - val welcome = listOf("❄", "❤", "\uD83D\uDCE2", "\uD83D\uDCE3") + val welcome = listOf("❄", "❤", "\uD83D\uDCE2", "\uD83D\uDCE3", "氦") val playground = Application::class.java.classLoader.getResource("graphql-playground/index.html")?.readText() ?.replace( "\$BACKEND_URL\$", diff --git a/booster/src/main/kotlin/explode2/booster/graphql/BasicMaze.kt b/booster/src/main/kotlin/explode2/booster/graphql/BasicMaze.kt index 7de26fe..c6e4e7b 100644 --- a/booster/src/main/kotlin/explode2/booster/graphql/BasicMaze.kt +++ b/booster/src/main/kotlin/explode2/booster/graphql/BasicMaze.kt @@ -219,6 +219,7 @@ object BasicMaze : ExplodeQuery, ExplodeMutation, MazeProvider { val u = env.getUser() + // category mapping val cate = when { isHidden == 1 -> SearchCategory.HIDDEN isOfficial == 1 -> SearchCategory.OFFICIAL @@ -226,12 +227,17 @@ object BasicMaze : ExplodeQuery, ExplodeMutation, MazeProvider { isRanked == -1 -> SearchCategory.UNRANKED else -> SearchCategory.ALL } + + // sort type mapping + // see ExplodeX/labyrinth/src/main/kotlin/explode2/labyrinth/SearchEnums.kt for details val sort = when { playCountOrder == -1 -> SearchSort.DESCENDING_BY_PLAY_COUNT publishTimeOrder == -1 -> SearchSort.DESCENDING_BY_PUBLISH_TIME + publishTimeOrder == 1 -> SearchSort.ASCENDING_BY_PUBLISH_TIME else -> boom("invalid ordering") } + // return result return songRepo.searchSongSets( musicTitle, cate, diff --git a/booster/src/main/kotlin/explode2/booster/graphql/RefreshingRankingList.kt b/booster/src/main/kotlin/explode2/booster/graphql/RefreshingRankingList.kt index f62b16a..af6592e 100644 --- a/booster/src/main/kotlin/explode2/booster/graphql/RefreshingRankingList.kt +++ b/booster/src/main/kotlin/explode2/booster/graphql/RefreshingRankingList.kt @@ -26,11 +26,12 @@ data class RefreshingRankingList( lastUpdateTime = LocalDateTime.now() } + // fix hardcoded 24 hours refreshing fun get(): List { val lastUpdateTime = lastUpdateTime if( lastUpdateTime == null || - lastUpdateTime + 24.hours.toJavaDuration() <= LocalDateTime.now() || + lastUpdateTime + expireHours.hours.toJavaDuration() <= LocalDateTime.now() || cache == null ) { update() @@ -45,11 +46,12 @@ data class RefreshingRankingList( return get().drop(skip).take(limit) } + // fix hardcoded 24 hours refreshing fun get(playerId: String): PlayRecordWithRankModel? { val lastUpdateTime = lastUpdateTime if( lastUpdateTime == null || - lastUpdateTime + 24.hours.toJavaDuration() <= LocalDateTime.now() || + lastUpdateTime + expireHours.hours.toJavaDuration() <= LocalDateTime.now() || cache == null ) { update() diff --git a/booster/src/main/kotlin/goodbird/GoodBirdOracle.kt b/booster/src/main/kotlin/goodbird/GoodBirdOracle.kt index 2cbd8fd..47bf9e0 100644 --- a/booster/src/main/kotlin/goodbird/GoodBirdOracle.kt +++ b/booster/src/main/kotlin/goodbird/GoodBirdOracle.kt @@ -6,6 +6,7 @@ import kotlin.math.pow * 来自某位 `一般路过鸟` 的神谕。 * * 我们只需要铭记这位好鸟,不必知晓他的真实身份。如果你知道,也请你保密。 + * i.e. the R calculation logic */ object GoodBirdOracle { diff --git a/explode-all/build.gradle.kts b/explode-all/build.gradle.kts index c08fd4e..f0930bb 100644 --- a/explode-all/build.gradle.kts +++ b/explode-all/build.gradle.kts @@ -4,8 +4,9 @@ plugins { id("com.github.johnrengelman.shadow") version "7.1.2" } +// It's explode v3 now group = "explode" -version = "1.0" +version = "3.0.3" repositories { mavenCentral() diff --git a/explode-proxy/build.gradle.kts b/explode-proxy/build.gradle.kts index 45bbf5c..c69fd46 100644 --- a/explode-proxy/build.gradle.kts +++ b/explode-proxy/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "explode" -version = "1.0" +version = "3.0.3" repositories { mavenCentral() diff --git a/gateau/src/main/kotlin/explode2/gateau/SongState.kt b/gateau/src/main/kotlin/explode2/gateau/SongState.kt index a33bc55..24d199b 100644 --- a/gateau/src/main/kotlin/explode2/gateau/SongState.kt +++ b/gateau/src/main/kotlin/explode2/gateau/SongState.kt @@ -2,6 +2,7 @@ package explode2.gateau +/* The interface of how we parse the set entries of the database. */ interface SongState { var category: Int diff --git a/labyrinth-mongodb/src/main/kotlin/explode2/labyrinth/mongo/LabyrinthMongo.kt b/labyrinth-mongodb/src/main/kotlin/explode2/labyrinth/mongo/LabyrinthMongo.kt index 7593ef2..3d3e245 100644 --- a/labyrinth-mongodb/src/main/kotlin/explode2/labyrinth/mongo/LabyrinthMongo.kt +++ b/labyrinth-mongodb/src/main/kotlin/explode2/labyrinth/mongo/LabyrinthMongo.kt @@ -244,10 +244,15 @@ class MongoManager(private val provider: LabyrinthMongoBuilder = LabyrinthMongoB // 排序顺序 when(sortBy) { - null, SearchSort.DESCENDING_BY_PUBLISH_TIME -> { + null, + // Descending by time + SearchSort.DESCENDING_BY_PUBLISH_TIME -> { pipeline += sort(descending(MongoSongSet::publishTime, MongoSongSet::musicName, MongoSongSet::id)) } - + // Ascending by time (Updated 2026.6.2) + SearchSort.ASCENDING_BY_PUBLISH_TIME -> { + pipeline += sort(ascending(MongoSongSet::publishTime, MongoSongSet::musicName, MongoSongSet::id)) + } // FIXME: 修复性能问题 SearchSort.DESCENDING_BY_PLAY_COUNT -> { // 添加游玩次数查询 diff --git a/labyrinth/src/main/kotlin/explode2/labyrinth/SearchEnums.kt b/labyrinth/src/main/kotlin/explode2/labyrinth/SearchEnums.kt index ebe1c0d..ab05f83 100644 --- a/labyrinth/src/main/kotlin/explode2/labyrinth/SearchEnums.kt +++ b/labyrinth/src/main/kotlin/explode2/labyrinth/SearchEnums.kt @@ -4,7 +4,9 @@ enum class SearchCategory { HIDDEN, OFFICIAL, RANKED, UNRANKED, REVIEW, ALL } +// Update 2026.6.2: added ASCENDING_BY_PUBLISH_TIME enum class SearchSort { DESCENDING_BY_PLAY_COUNT, - DESCENDING_BY_PUBLISH_TIME + DESCENDING_BY_PUBLISH_TIME, + ASCENDING_BY_PUBLISH_TIME } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 0321d48..e9087a7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,7 +5,7 @@ include("labyrinth") include("labyrinth-mongodb") include("booster") include("resource") -include("booster-maintain") +// includePlugin("maintain") // useless include("gatekeeper") include("explode-all") include("explode-proxy") diff --git a/src/main/kotlin/explode2/tests/Main.kt b/src/main/kotlin/explode2/tests/Main.kt index 313e11f..d4992ab 100644 --- a/src/main/kotlin/explode2/tests/Main.kt +++ b/src/main/kotlin/explode2/tests/Main.kt @@ -28,7 +28,7 @@ fun main(skip: Int = 0, limit: Int = 9) { val matchingName = "" val matchingCategory = SearchCategory.ALL - val sortBy = SearchSort.DESCENDING_BY_PUBLISH_TIME + val sortBy = SearchSort.ASCENDING_BY_PUBLISH_TIME class SongSetWithCharts(val charts: List) class SongSetWithPlayCount(val playCount: Int) @@ -176,6 +176,10 @@ fun main(skip: Int = 0, limit: Int = 9) { pipeline += sort(descending(MongoSongSet::publishTime, MongoSongSet::musicName, MongoSongSet::id)) } + SearchSort.ASCENDING_BY_PUBLISH_TIME -> { + pipeline += sort(ascending(MongoSongSet::publishTime, MongoSongSet::musicName, MongoSongSet::id)) + } + // FIXME: 修复性能问题 SearchSort.DESCENDING_BY_PLAY_COUNT -> { // 添加游玩次数查询