diff --git a/app/Models/ChangelogEntry.php b/app/Models/ChangelogEntry.php index 474bc36113d..0c7a4ee0eeb 100644 --- a/app/Models/ChangelogEntry.php +++ b/app/Models/ChangelogEntry.php @@ -83,9 +83,20 @@ public static function guessCategory($data) foreach ($data['pull_request']['labels'] as $label) { $name = $label['name']; - if (!in_array(strtolower($name), $ignored, true)) { - return ucwords($name); + if (in_array(strtolower($name), $ignored, true)) { + continue; } + + $separatorPos = strpos($name, ':'); + if ($separatorPos !== false) { + $name = substr($name, $separatorPos + 1); + } + + if (strpos($name, ' ') === false) { + $name = str_replace('-', ' ', $name); + } + + return ucwords($name); } } @@ -108,6 +119,7 @@ public static function importFromGithub($data) 'created_at' => Carbon::parse($data['pull_request']['merged_at']), 'github_pull_request_id' => $data['pull_request']['number'], 'message' => $data['pull_request']['body'], + 'private' => static::isPrivate($data), 'title' => $data['pull_request']['title'], 'type' => static::guessType($data), ]); @@ -128,6 +140,23 @@ public static function importFromGithub($data) return $entry; } + public static function isPrivate($data) + { + static $privateCategories = [ + 'dependencies', + ]; + + foreach ($data['pull_request']['labels'] as $label) { + $name = $label['name']; + + if (in_array(strtolower($name), $privateCategories, true)) { + return true; + } + } + + return false; + } + public static function placeholder() { return new static([ diff --git a/app/Transformers/BeatmapTransformer.php b/app/Transformers/BeatmapTransformer.php index 7f10a99a8fe..f5a39934922 100644 --- a/app/Transformers/BeatmapTransformer.php +++ b/app/Transformers/BeatmapTransformer.php @@ -25,7 +25,6 @@ public function transform(Beatmap $beatmap) 'count_circles' => $beatmap->countNormal, 'count_sliders' => $beatmap->countSlider, 'count_spinners' => $beatmap->countSpinner, - 'count_total' => $beatmap->countTotal, 'cs' => $beatmap->diff_size, 'deleted_at' => $beatmap->deleted_at, 'drain' => $beatmap->diff_drain, diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php index ebdf4ec3195..9a542bc42d5 100644 --- a/app/Transformers/UserTransformer.php +++ b/app/Transformers/UserTransformer.php @@ -39,18 +39,14 @@ public function transform(User $user) 'total' => $user->osu_kudostotal, 'available' => $user->osu_kudosavailable, ], - 'last_visit' => json_time($user->displayed_last_visit), 'lastfm' => $user->user_lastfm, 'location' => $user->user_from, - 'is_online' => $user->isOnline(), 'max_blocks' => $user->maxBlocks(), 'max_friends' => $user->maxFriends(), 'occupation' => $user->user_occ, 'playmode' => $user->playmode, 'playstyle' => $user->osu_playstyle, - 'pm_friends_only' => $user->pm_friends_only, 'post_count' => $user->user_posts, - 'profile_colour' => $user->user_colour, 'profile_order' => $profileCustomization->extras_order, 'skype' => $user->user_msnm, 'title' => $user->title(), diff --git a/config/schemas/beatmaps.json b/config/schemas/beatmaps.json index 9def0444963..113ffd7c95c 100644 --- a/config/schemas/beatmaps.json +++ b/config/schemas/beatmaps.json @@ -68,9 +68,6 @@ "countSpinner": { "type": "long" }, - "countTotal": { - "type": "long" - }, "diff_approach": { "type": "double" }, diff --git a/database/factories/BeatmapFactory.php b/database/factories/BeatmapFactory.php index cd6dcc047f5..4c56ea9ab5f 100644 --- a/database/factories/BeatmapFactory.php +++ b/database/factories/BeatmapFactory.php @@ -29,7 +29,6 @@ 'version' => $faker->domainWord, 'total_length' => $length, 'hit_length' => ($length - rand(0, 20)), - 'countTotal' => $hits, 'countNormal' => $hitsNormal, 'countSlider' => $hitsSlider, 'countSpinner' => $hitsSpinner, diff --git a/database/factories/ScoreBestFactory.php b/database/factories/ScoreBestFactory.php index c8a79599791..9759463d82f 100644 --- a/database/factories/ScoreBestFactory.php +++ b/database/factories/ScoreBestFactory.php @@ -14,7 +14,7 @@ $beatmap = factory(Beatmap::class)->create([ 'playmode' => $modeInt, // force playmode to match score type ]); - $maxCombo = rand(1, $beatmap->countTotal); + $maxCombo = rand(1, $beatmap->countNormal); return [ 'user_id' => function () { diff --git a/database/seeds/ModelSeeders/BeatmapSeeder.php b/database/seeds/ModelSeeders/BeatmapSeeder.php index 030caa2cf9a..f42b9526aee 100644 --- a/database/seeds/ModelSeeders/BeatmapSeeder.php +++ b/database/seeds/ModelSeeders/BeatmapSeeder.php @@ -121,7 +121,6 @@ private function createBeatmap($json) 'total_length' => $json->total_length, 'hit_length' => $json->hit_length, 'bpm' => $json->bpm, - 'countTotal' => $json->max_combo !== null ? $json->max_combo : 1500, 'countNormal' => round(intval($json->max_combo) - (0.2 * intval($json->max_combo))), 'countSlider' => round(intval($json->max_combo) - (0.8 * intval($json->max_combo))), 'countSpinner' => 1, diff --git a/database/seeds/ModelSeeders/ScoreSeeder.php b/database/seeds/ModelSeeders/ScoreSeeder.php index fca45eece29..58aa5aee784 100644 --- a/database/seeds/ModelSeeders/ScoreSeeder.php +++ b/database/seeds/ModelSeeders/ScoreSeeder.php @@ -47,7 +47,7 @@ public function run() //add 20 osu! Standard scores foreach ($osuBeatmaps as $bm) { $bms = $allBeatmapsets->find($bm->beatmapset_id); - $maxcombo = rand(1, $bm->countTotal); + $maxcombo = rand(1, $bm->countNormal); $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt $sc = App\Models\Score\Osu::create([ 'user_id' => $u->user_id, @@ -89,7 +89,7 @@ public function run() //Taiko scores foreach ($taikoBeatmaps as $bm) { $bms = $allBeatmapsets->find($bm->beatmapset_id); - $maxcombo = rand(1, $bm->countTotal); + $maxcombo = rand(1, $bm->countNormal); $possible_mods = [0, 16, 24, 64, 72]; $sc3 = App\Models\Score\Taiko::create([ 'user_id' => $u->user_id, @@ -131,7 +131,7 @@ public function run() //Fruits scores foreach ($fruitsBeatmaps as $bm) { $bms = $allBeatmapsets->find($bm->beatmapset_id); - $maxcombo = rand(1, $bm->countTotal); + $maxcombo = rand(1, $bm->countNormal); $possible_mods = [0, 16, 24, 64, 72]; $sc5 = App\Models\Score\Fruits::create([ 'user_id' => $u->user_id, @@ -173,7 +173,7 @@ public function run() //Mania scores foreach ($maniaBeatmaps as $bm) { $bms = $allBeatmapsets->find($bm->beatmapset_id); - $maxcombo = rand(1, $bm->countTotal); + $maxcombo = rand(1, $bm->countNormal); $possible_mods = [0, 16, 24, 64, 72]; // hr, hd/hr, dt, hd/dt $sc7 = App\Models\Score\Mania::create([ 'user_id' => $u->user_id, diff --git a/database/seeds/ModelSeeders/SpotlightSeeder.php b/database/seeds/ModelSeeders/SpotlightSeeder.php index 0ec2b8605d0..749159a32a9 100644 --- a/database/seeds/ModelSeeders/SpotlightSeeder.php +++ b/database/seeds/ModelSeeders/SpotlightSeeder.php @@ -104,7 +104,7 @@ private static function seedData($spotlight) $possible_ranks = ['A', 'S', 'B', 'SH', 'XH', 'X']; foreach ($beatmaps as $beatmap) { - $maxcombo = rand(1, $beatmap->countTotal); + $maxcombo = rand(1, $beatmap->countNormal); $score = new $scoresClass([ 'user_id' => $user->user_id, 'beatmap_id' => $beatmap->beatmap_id, diff --git a/resources/assets/lib/interfaces/beatmap-json-extended.ts b/resources/assets/lib/interfaces/beatmap-json-extended.ts index e7efb70cd75..8ab0d70ba78 100644 --- a/resources/assets/lib/interfaces/beatmap-json-extended.ts +++ b/resources/assets/lib/interfaces/beatmap-json-extended.ts @@ -16,7 +16,6 @@ export default interface BeatmapJsonExtended extends BeatmapJson { count_circles: number; count_sliders: number; count_spinners: number; - count_total: number; cs: number; deleted_at: string | null; drain: number; diff --git a/tests/Models/ChangelogEntryTest.php b/tests/Models/ChangelogEntryTest.php index 9d54638f1db..aee0019f14b 100644 --- a/tests/Models/ChangelogEntryTest.php +++ b/tests/Models/ChangelogEntryTest.php @@ -67,4 +67,87 @@ public function testConvertLegacyChangelogWithMessage() $this->assertSame($message, $converted->title); $this->assertNull($converted->messageHTML()); } + + public function testGuessCategoryCapitalise() + { + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'forum'], + ], + ], + ]; + + $this->assertSame('Forum', ChangelogEntry::guessCategory($data)); + } + + public function testGuessCategoryDashToSpace() + { + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'beatmapset-discussion'], + ], + ], + ]; + + $this->assertSame('Beatmapset Discussion', ChangelogEntry::guessCategory($data)); + } + + public function testGuessCategoryMixedDashAndSpaceNoConversion() + { + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'beatmapset - discussion'], + ], + ], + ]; + + $this->assertSame('Beatmapset - Discussion', ChangelogEntry::guessCategory($data)); + } + + public function testGuessCategoryPrefixRemoval() + { + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'area:forum'], + ], + ], + ]; + + $this->assertSame('Forum', ChangelogEntry::guessCategory($data)); + } + + public function testIsPrivate() + { + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'javascript'], + ['name' => 'area:forum'], + ], + ], + ]; + + $this->assertFalse(ChangelogEntry::isPrivate($data)); + + $data = [ + 'repository' => ['full_name' => ''], + 'pull_request' => [ + 'labels' => [ + ['name' => 'javascript'], + ['name' => 'dependencies'], + ], + ], + ]; + + $this->assertTrue(ChangelogEntry::isPrivate($data)); + } }