From 7b7c15329e432cf760490c59c3b422f2692663c9 Mon Sep 17 00:00:00 2001 From: nanaya Date: Wed, 24 Jan 2024 17:26:34 +0900 Subject: [PATCH] Configurable score processing queue --- .env.example | 1 + app/Models/Solo/Score.php | 4 +--- config/osu.php | 1 + tests/Controllers/Solo/ScoresControllerTest.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index a6b68b781f0..388820fa363 100644 --- a/.env.example +++ b/.env.example @@ -307,6 +307,7 @@ CLIENT_CHECK_VERSION=false # SCORES_ES_CACHE_DURATION= # SCORES_EXPERIMENTAL_RANK_AS_DEFAULT=false # SCORES_EXPERIMENTAL_RANK_AS_EXTRA=false +# SCORES_PROCESSING_QUEUE=osu-queue:score-statistics # SCORES_RANK_CACHE_LOCAL_SERVER=0 # SCORES_RANK_CACHE_MIN_USERS=35000 # SCORES_RANK_CACHE_SERVER_URL= diff --git a/app/Models/Solo/Score.php b/app/Models/Solo/Score.php index 1c4841b188c..38e9c536e76 100644 --- a/app/Models/Solo/Score.php +++ b/app/Models/Solo/Score.php @@ -39,8 +39,6 @@ class Score extends Model implements Traits\ReportableInterface { use Traits\Reportable, Traits\WithWeightedPp; - const PROCESSING_QUEUE = 'osu-queue:score-statistics'; - public $timestamps = false; protected $casts = [ @@ -101,7 +99,7 @@ public static function extractParams(array $params, ScoreToken|MultiplayerScoreL */ public static function queueForProcessing(array $scoreJson): void { - LaravelRedis::lpush(static::PROCESSING_QUEUE, json_encode([ + LaravelRedis::lpush($GLOBALS['cfg']['osu']['scores']['processing_queue'], json_encode([ 'Score' => [ 'beatmap_id' => $scoreJson['beatmap_id'], 'id' => $scoreJson['id'], diff --git a/config/osu.php b/config/osu.php index 33af7ae8d4a..43148a067d4 100644 --- a/config/osu.php +++ b/config/osu.php @@ -172,6 +172,7 @@ 'es_cache_duration' => 60 * (get_float(env('SCORES_ES_CACHE_DURATION')) ?? 0.5), // in minutes, converted to seconds 'experimental_rank_as_default' => get_bool(env('SCORES_EXPERIMENTAL_RANK_AS_DEFAULT')) ?? false, 'experimental_rank_as_extra' => get_bool(env('SCORES_EXPERIMENTAL_RANK_AS_EXTRA')) ?? false, + 'processing_queue' => presence(env('SCORES_PROCESSING_QUEUE')) ?? 'osu-queue:score-statistics', 'rank_cache' => [ 'local_server' => get_bool(env('SCORES_RANK_CACHE_LOCAL_SERVER')) ?? false, 'min_users' => get_int(env('SCORES_RANK_CACHE_MIN_USERS')) ?? 35000, diff --git a/tests/Controllers/Solo/ScoresControllerTest.php b/tests/Controllers/Solo/ScoresControllerTest.php index a5dc22bebd1..084cbfcd481 100644 --- a/tests/Controllers/Solo/ScoresControllerTest.php +++ b/tests/Controllers/Solo/ScoresControllerTest.php @@ -130,11 +130,11 @@ public function tearDown(): void parent::tearDown(); static::createApp(); - LaravelRedis::del(Score::PROCESSING_QUEUE); + LaravelRedis::del($GLOBALS['cfg']['osu']['scores']['processing_queue']); } private function processingQueueCount(): int { - return LaravelRedis::llen(Score::PROCESSING_QUEUE); + return LaravelRedis::llen($GLOBALS['cfg']['osu']['scores']['processing_queue']); } }