From 1d02e3e436596977d63938e645290cbdf0e1225c Mon Sep 17 00:00:00 2001 From: "nise.moe" Date: Wed, 12 Jun 2024 17:18:08 +0200 Subject: [PATCH] Added mod selector --- .../search/score/ScoreSearchController.kt | 2 +- .../score/ScoreSearchSchemaController.kt | 4 +- .../nise/search/score/ScoreSearchService.kt | 4 +- .../src/app/search/search.component.html | 3 ++ .../src/app/search/search.component.ts | 9 ++-- .../query-builder/query-builder.component.ts | 4 +- .../components/query/query.component.html | 23 ++++++++++ .../components/query/query.component.ts | 43 ++++++++++++++++++- 8 files changed, 81 insertions(+), 11 deletions(-) diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchController.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchController.kt index edf9685..33340ed 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchController.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchController.kt @@ -73,7 +73,7 @@ class ScoreSearchController( val count_miss: Int?, val date: String?, val max_combo: Int?, - val mods: Int?, + val mods: List?, val perfect: Boolean?, val pp: Double?, val rank: String?, diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchSchemaController.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchSchemaController.kt index 5a217f7..cd419c4 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchSchemaController.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchSchemaController.kt @@ -46,7 +46,7 @@ class ScoreSearchSchemaController( InternalSchemaField("count_miss", "Misses", Category.score, Type.number, false, "missed hits in score", databaseField = SCORES.COUNT_MISS), InternalSchemaField("date", "Date", Category.score, Type.datetime, true, "when score was achieved", databaseField = SCORES.DATE), InternalSchemaField("max_combo", "Max Combo", Category.score, Type.number, false, "highest combo in score", databaseField = SCORES.MAX_COMBO), - InternalSchemaField("mods", "Mods", Category.score, Type.number, false, "game modifiers used", databaseField = SCORES.MODS), + InternalSchemaField("mods", "Mods", Category.score, Type.mods, false, "game modifiers used", databaseField = SCORES.MODS), InternalSchemaField("perfect", "Perfect", Category.score, Type.boolean, false, "if score is a full combo", databaseField = SCORES.PERFECT), InternalSchemaField("pp", "Score PP", Category.score, Type.number, true, "performance points for score", databaseField = SCORES.PP), InternalSchemaField("rank", "Rank", Category.score, Type.grade, false, "score grade", databaseField = SCORES.RANK), @@ -109,7 +109,7 @@ class ScoreSearchSchemaController( } enum class Type { - number, string, flag, grade, boolean, datetime, playtime + number, string, flag, grade, boolean, datetime, playtime, mods } data class SearchSchema( diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchService.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchService.kt index dfeb354..d93b33b 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchService.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/search/score/ScoreSearchService.kt @@ -4,6 +4,7 @@ import com.nisemoe.generated.tables.references.BEATMAPS import com.nisemoe.generated.tables.references.SCORES import com.nisemoe.generated.tables.references.USERS import com.nisemoe.nise.Format +import com.nisemoe.nise.osu.Mod import com.nisemoe.nise.service.AuthService import org.jooq.* import org.jooq.impl.DSL @@ -164,7 +165,7 @@ class ScoreSearchService( count_miss = it.get(SCORES.COUNT_MISS), date = it.get(SCORES.DATE)?.let { it1 -> Format.formatLocalDateTime(it1) }, max_combo = it.get(SCORES.MAX_COMBO), - mods = it.get(SCORES.MODS), + mods = Mod.parseModCombination(it.get(SCORES.MODS, Int::class.java)), perfect = it.get(SCORES.PERFECT), pp = it.get(SCORES.PP)?.roundToInt()?.toDouble(), rank = it.get(SCORES.RANK), @@ -248,6 +249,7 @@ class ScoreSearchService( "grade" -> buildGradeCondition(field as Field, predicate.operator.operatorType, predicate.value) "datetime" -> buildDatetimeCondition(field as Field, predicate.operator.operatorType, predicate.value) "playtime" -> buildNumberCondition(field as Field, predicate.operator.operatorType, predicate.value.toDouble()) + "mods" -> buildNumberCondition(field as Field, predicate.operator.operatorType, predicate.value.toDouble()) else -> throw IllegalArgumentException("Invalid field type") } } diff --git a/nise-frontend/src/app/search/search.component.html b/nise-frontend/src/app/search/search.component.html index 447dc09..8f18dbe 100644 --- a/nise-frontend/src/app/search/search.component.html +++ b/nise-frontend/src/app/search/search.component.html @@ -148,6 +148,9 @@ ✗ + + {{ getValue(entry, column.name) }} + {{ formatDuration(getValue(entry, column.name)) }} diff --git a/nise-frontend/src/app/search/search.component.ts b/nise-frontend/src/app/search/search.component.ts index 4c32ece..b5652f5 100644 --- a/nise-frontend/src/app/search/search.component.ts +++ b/nise-frontend/src/app/search/search.component.ts @@ -21,7 +21,7 @@ export interface SchemaField { name: string; shortName: string; category: 'user' | 'score' | 'beatmap' | 'metrics'; - type: 'number' | 'string' | 'flag' | 'grade' | 'boolean' | 'datetime' | 'playtime'; + type: 'number' | 'string' | 'flag' | 'grade' | 'boolean' | 'datetime' | 'playtime' | 'mods'; validOperators: Operator[]; active: boolean; description: string; @@ -80,7 +80,7 @@ export class SearchComponent implements OnInit { private route: ActivatedRoute, public downloadFilesService: DownloadFilesService) { } - currentSchemaVersion = 2 + currentSchemaVersion = 2; isError = false; isLoading = false; @@ -135,7 +135,7 @@ export class SearchComponent implements OnInit { switch (fieldType) { case 'number': return ['=', '>', '<', '>=', '<=', '!='] - .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'any'}) as Operator); + .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'number'}) as Operator); case 'string': return ['=', 'contains', 'like'] .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'any'}) as Operator); @@ -148,6 +148,9 @@ export class SearchComponent implements OnInit { case 'grade': return ['=', '!='] .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'grade'}) as Operator); + case 'mods': + return ['=', '!='] + .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'mods'}) as Operator); case 'datetime': return ['before', 'after'] .map((operatorType: String) => ({operatorType: operatorType, acceptsValues: 'datetime'}) as Operator); diff --git a/nise-frontend/src/corelib/components/query-builder/query-builder.component.ts b/nise-frontend/src/corelib/components/query-builder/query-builder.component.ts index b7ae1c6..7d33205 100644 --- a/nise-frontend/src/corelib/components/query-builder/query-builder.component.ts +++ b/nise-frontend/src/corelib/components/query-builder/query-builder.component.ts @@ -4,9 +4,9 @@ import {NgForOf, NgIf} from "@angular/common"; import {QueryComponent} from "../query/query.component"; import {SchemaField} from "../../../app/search/search.component"; -export type FieldType = 'number' | 'string' | 'flag' | 'grade' | 'boolean' | 'datetime' | 'playtime'; +export type FieldType = 'number' | 'string' | 'flag' | 'grade' | 'boolean' | 'datetime' | 'playtime' | 'mods'; export type OperatorType = '=' | '>' | '<' | 'contains' | 'like' | '>=' | '<=' | '!='; -export type ValueType = 'any' | 'boolean' | 'flag' | 'grade' | 'datetime'; +export type ValueType = 'any' | 'boolean' | 'flag' | 'grade' | 'datetime' | 'number' | 'mods'; export interface Predicate { field: SchemaField | null; diff --git a/nise-frontend/src/corelib/components/query/query.component.html b/nise-frontend/src/corelib/components/query/query.component.html index 173a8b1..692051b 100644 --- a/nise-frontend/src/corelib/components/query/query.component.html +++ b/nise-frontend/src/corelib/components/query/query.component.html @@ -44,6 +44,18 @@ + +
+ +
+
+
+ +
+
@@ -51,6 +63,17 @@ + + + + + + + Select mods + {{ getSelectedMods(predicate).join(', ') }} + + +