Skip to content

Commit

Permalink
Merge branch 'master' into bss2-editable-description
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya authored Jan 29, 2025
2 parents 6f8dade + 4a1d92a commit 223d72c
Show file tree
Hide file tree
Showing 158 changed files with 3,119 additions and 1,236 deletions.
104 changes: 51 additions & 53 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module.exports = {
'typescript-sort-keys',
],
rules: {
'@stylistic/member-delimiter-style': 'error',
'@stylistic/type-annotation-spacing': 'error',
'@typescript-eslint/array-type': [
'error',
{
Expand All @@ -41,20 +43,6 @@ module.exports = {
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': [
'error',
2,
{
FunctionDeclaration: {
parameters: 'first',
},
FunctionExpression: {
parameters: 'first',
},
SwitchCase: 1,
},
],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/member-ordering': [
'error',
{
Expand Down Expand Up @@ -101,17 +89,17 @@ module.exports = {
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', ignoreRestSiblings: true }],
'@typescript-eslint/no-unused-vars': [
'error', {
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true },
],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
Expand All @@ -121,21 +109,17 @@ module.exports = {
allowNumber: true,
},
],
'@typescript-eslint/semi': ['error', 'always'],
// TODO: make more strict.
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowNullableBoolean: true,
},
],
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unified-signatures': 'error',
'dot-notation': 'off',
'no-invalid-this': 'off',
'no-shadow': 'off',
'object-curly-spacing': 'off',
quotes: 'off',
'react-hooks/exhaustive-deps': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-spacing': 'error',
Expand Down Expand Up @@ -190,22 +174,57 @@ module.exports = {
sourceType: 'module',
},
plugins: [
'@stylistic',
'eslint-plugin-jsdoc',
'eslint-plugin-import',
],
rules: {
'@stylistic/arrow-parens': 'error',
'@stylistic/arrow-spacing': 'error',
'@stylistic/brace-style': 'error',
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/eol-last': 'error',
'@stylistic/indent': [
'error',
2,
{
FunctionDeclaration: {
parameters: 'first',
},
FunctionExpression: {
parameters: 'first',
},
SwitchCase: 1,
},
],
'@stylistic/max-len': 'off',
'@stylistic/new-parens': 'error',
'@stylistic/no-multiple-empty-lines': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/quotes': [
'error',
'single',
{ avoidEscape: true },
],
'@stylistic/semi': ['error', 'always'],
'@stylistic/space-before-function-paren': [
'error',
{
anonymous: 'never',
asyncArrow: 'always',
named: 'never',
},
],
'@stylistic/spaced-comment': 'error',
'arrow-body-style': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'brace-style': 'error',
'comma-dangle': ['error', 'always-multiline'],
complexity: 'off',
curly: ['error', 'multi-line'],
'dot-notation': 'error',
'eol-last': 'error',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'id-blacklist': [
'id-denylist': [
'error',
'any',
'Number',
Expand All @@ -221,43 +240,22 @@ module.exports = {
'import/order': ['error', { alphabetize: { order: 'asc' } }],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/newline-after-description': 'error',
'jsdoc/tag-lines': ['error', 'never', { startLines: 1 }],
'max-classes-per-file': 'error',
'max-len': 'off',
'new-parens': 'error',
'no-bitwise': 'error',
'no-caller': 'error',
'no-console': ['error', { allow: ['error', 'warn'] }],
'no-empty-function': 'error',
'no-eval': 'error',
'no-invalid-this': 'error',
'no-multiple-empty-lines': 'error',
'no-new-wrappers': 'error',
'no-shadow': ['error', { hoist: 'all' }],
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-unsafe-finally': 'error',
'object-curly-spacing': ['error', 'always'],
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'quote-props': ['error', 'as-needed'],
quotes: [
'error',
'single',
{ avoidEscape: true },
],
radix: 'error',
semi: ['error', 'always'],
'sort-keys': ['error', 'asc', { caseSensitive: false }],
'space-before-function-paren': [
'error',
{
anonymous: 'never',
asyncArrow: 'always',
named: 'never',
},
],
'spaced-comment': 'error',
},
};
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install js dependencies
run: yarn --frozen-lockfile

- run: 'yarn lint --max-warnings 87 > /dev/null'
- run: 'yarn lint --max-warnings 82 > /dev/null'

- run: yarn pretty

Expand Down
63 changes: 63 additions & 0 deletions app/Console/Commands/UserSeasonScoresRecalculate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

declare(strict_types=1);

namespace App\Console\Commands;

use App\Models\Multiplayer\UserScoreAggregate;
use App\Models\Season;
use App\Models\User;
use Illuminate\Console\Command;

class UserSeasonScoresRecalculate extends Command
{
protected $signature = 'user-season-scores:recalculate {--season-id=}';
protected $description = 'Recalculate user scores for all active seasons or a specified season.';

public function handle(): void
{
$seasonId = $this->option('season-id');

if (present($seasonId)) {
$this->recalculate(Season::findOrFail(get_int($seasonId)));
} else {
$activeSeasons = Season::active()->get();

foreach ($activeSeasons as $season) {
$this->recalculate($season);
}
}
}

protected function recalculate(Season $season): void
{
$scoreUserIds = UserScoreAggregate::whereIn('room_id', $season->rooms->pluck('id'))
->distinct('user_id')
->pluck('user_id');

$bar = $this->output->createProgressBar($scoreUserIds->count());

User::whereIn('user_id', $scoreUserIds)
->chunkById(100, function ($userChunk) use ($bar, $season) {
foreach ($userChunk as $user) {
$seasonScore = $user->seasonScores()
->where('season_id', $season->getKey())
->firstOrNew();

$seasonScore->season()->associate($season);
$seasonScore->calculate(false);
if ($seasonScore->total_score > 0) {
$seasonScore->save();
}

$bar->advance();
}
});

$bar->finish();
$this->newLine();
}
}
16 changes: 0 additions & 16 deletions app/Http/Controllers/BeatmapTagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ public function __construct()
'destroy',
],
]);

$this->middleware('require-scopes:public', ['only' => 'index']);
}

public function index($beatmapId)
{
$topBeatmapTags = cache_remember_mutexed(
"beatmap_tags:{$beatmapId}",
$GLOBALS['cfg']['osu']['tags']['beatmap_tags_cache_duration'],
[],
fn () => Tag::topTags($beatmapId),
);

return [
'beatmap_tags' => $topBeatmapTags,
];
}

public function destroy($beatmapId, $tagId)
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/BeatmapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class BeatmapsController extends Controller
{
const DEFAULT_API_INCLUDES = ['beatmapset.ratings', 'failtimes', 'max_combo'];
const DEFAULT_API_INCLUDES = ['beatmapset.ratings', 'failtimes', 'max_combo', 'owners'];
const DEFAULT_SCORE_INCLUDES = ['user', 'user.country', 'user.cover', 'user.team'];

public function __construct()
Expand Down Expand Up @@ -194,7 +194,7 @@ public function attributes($id)
*
* Field | Type | Description
* -------- | ------------------------------------- | -----------
* beatmaps | [BeatmapExtended](#beatmapextended)[] | Includes `beatmapset` (with `ratings`), `failtimes`, and `max_combo`.
* beatmaps | [BeatmapExtended](#beatmapextended)[] | Includes `beatmapset` (with `ratings`), `failtimes`, `max_combo`, and `owners`.
*
* @queryParam ids[] integer Beatmap IDs to be returned. Specify once for each beatmap ID requested. Up to 50 beatmaps can be requested at once. Example: 1
*
Expand All @@ -216,6 +216,7 @@ public function index()
::whereIn('beatmap_id', $ids)
->whereHas('beatmapset')
->with([
'beatmapOwners.user',
'beatmapset',
'beatmapset.userRatings' => fn ($q) => $q->select('beatmapset_id', 'rating'),
'failtimes',
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/BeatmapsetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ private function showJson($beatmapset)
'beatmaps.failtimes',
'beatmaps.max_combo',
'beatmaps.owners',
'beatmaps.top_tag_ids',
'converts',
'converts.failtimes',
'converts.owners',
Expand All @@ -415,6 +416,7 @@ private function showJson($beatmapset)
'pack_tags',
'ratings',
'recent_favourites',
'related_tags',
'related_users',
'user',
]);
Expand Down
14 changes: 7 additions & 7 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Models\NewsPost;
use App\Models\UserDonation;
use App\Transformers\MenuImageTransformer;
use App\Transformers\UserCompactTransformer;
use Auth;
use Jenssegers\Agent\Agent;
use Request;
Expand Down Expand Up @@ -142,12 +143,11 @@ public function quickSearch()
$result[$mode]['total'] = $search->count();
}

$result['user']['users'] = json_collection($searches['user']->data(), 'UserCompact', [
'country',
'cover',
'groups',
'support_level',
]);
$result['user']['users'] = json_collection(
$searches['user']->data(),
new UserCompactTransformer(),
[...UserCompactTransformer::CARD_INCLUDES, 'support_level'],
);
$result['beatmapset']['beatmapsets'] = json_collection($searches['beatmapset']->data(), 'Beatmapset', ['beatmaps']);
}

Expand Down Expand Up @@ -210,7 +210,7 @@ public function setLocale()
]);
}

return ext_view('layout.ujs-reload', [], 'js')
return ext_view('layout.ujs_full_reload', [], 'js')
->withCookie(cookie()->forever('locale', $newLocale));
}

Expand Down
Loading

0 comments on commit 223d72c

Please sign in to comment.