Skip to content

Commit

Permalink
Merge branch 'master' into contest-judging
Browse files Browse the repository at this point in the history
  • Loading branch information
venix12 authored Jan 26, 2024
2 parents eaed244 + 57b36f5 commit 66c3ab6
Show file tree
Hide file tree
Showing 148 changed files with 1,162 additions and 888 deletions.
4 changes: 2 additions & 2 deletions .env.dusk.local.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
APP_KEY=
APP_ENV=testing

APP_URL=http://localhost:8000
NOTIFICATION_ENDPOINT=ws://notification-server-dusk:2345
APP_URL=http://nginx:8008
NOTIFICATION_ENDPOINT=ws://nginx:8008/home/notifications/feed

DB_DATABASE=osu_test
DB_DATABASE_CHAT=osu_chat_test
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
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 94 > /dev/null'
- run: 'yarn lint --max-warnings 90 > /dev/null'

- run: ./bin/update_licence.sh -nf

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ _ide_helper.php
/vendor
composer.phar

# docker related local files
/compose.override.yml

# OS-specific crud
.DS_Store
Thumbs.db
Expand Down
8 changes: 1 addition & 7 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ Start docker in background:

```
bin/docker_dev.sh -d
# alternatively
# docker compose up -d
```

Start single docker service:
Expand Down Expand Up @@ -188,13 +186,9 @@ docker compose run --rm php mysql
Docker images need to be occasionally updated to make sure they're running latest version of the packages.

```
docker compose down --rmi all
docker compose pull
docker compose build --pull
docker compose build --no-cache
```

(don't use `build --no-cache` as it'll end up rebuilding `php` image multiple times)

#### Faster php commands

When frequently running commands, doing `docker compose run` may feel a little bit slow. An alternative is by running the command in existing instance instead. For example to run `artisan tinker`:
Expand Down
19 changes: 19 additions & 0 deletions app/Enums/ScoreRank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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.

namespace App\Enums;

enum ScoreRank: string
{
case A = 'A';
case B = 'B';
case C = 'C';
case D = 'D';
case F = 'F';
case S = 'S';
case SH = 'SH';
case X = 'X';
case XH = 'XH';
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Libraries\User\PasswordResetData;
use App\Models\User;
use App\Models\UserAccountHistory;
use Carbon\CarbonImmutable;

class PasswordResetController extends Controller
{
Expand Down Expand Up @@ -124,6 +125,7 @@ public function update()
}

$user->validatePasswordConfirmation();
$params['user']['user_lastvisit'] = CarbonImmutable::now();
if ($user->update($params['user'])) {
$user->resetSessions();
$this->login($user);
Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/SessionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public function store()
if ($forceReactivation->isRequired()) {
$forceReactivation->run();

\Session::flash('password_reset_start', [
'reason' => $forceReactivation->getReason(),
'username' => $username,
]);

return ujs_redirect(route('password-reset'));
}

Expand Down
16 changes: 0 additions & 16 deletions app/Libraries/ScoreRank.php

This file was deleted.

9 changes: 7 additions & 2 deletions app/Libraries/Search/ScoreSearchParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ public static function fromArray(array $rawParams): static
return $params;
}

public static function showLegacyForUser(?User $user): bool
/**
* This returns value for isLegacy based on user preference
*/
public static function showLegacyForUser(?User $user): null | true
{
return $user?->userProfileCustomization?->legacy_score_only ?? UserProfileCustomization::DEFAULT_LEGACY_ONLY_ATTRIBUTE;
return $user?->userProfileCustomization?->legacy_score_only ?? UserProfileCustomization::DEFAULT_LEGACY_ONLY_ATTRIBUTE
? true
: null;
}

public function getCountryCode(): string
Expand Down
5 changes: 5 additions & 0 deletions app/Libraries/User/ForceReactivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function __construct($user, $request)
}
}

public function getReason(): ?string
{
return $this->reason;
}

public function isRequired()
{
return $this->reason !== null;
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Beatmapset.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ public function qualify($user)
$this->events()->create(['type' => BeatmapsetEvent::QUALIFY]);

$this->setApproved('qualified', $user);
$this->bssProcessQueues()->create();

// global event
Event::generate('beatmapsetApprove', ['beatmapset' => $this]);
Expand Down Expand Up @@ -829,7 +830,9 @@ public function love(User $user, ?array $beatmapIds = null)

$this->getConnection()->transaction(function () use ($user, $beatmapIds) {
$this->events()->create(['type' => BeatmapsetEvent::LOVE, 'user_id' => $user->user_id]);

$this->setApproved('loved', $user, $beatmapIds);
$this->bssProcessQueues()->create();

Event::generate('beatmapsetApprove', ['beatmapset' => $this]);

Expand Down
8 changes: 2 additions & 6 deletions app/Models/LoginAttempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,11 @@ public static function logAttempt($ip, $user, $type, $password = null)

public static function logLoggedIn($ip, $user)
{
$record = static::find($ip);

if ($record === null) {
return;
}
$record = static::findOrDefault($ip);

$updates = [];

if (!$record->containsUser($user, 'success')) {
if ($record->failed_attempts > 0 && !$record->containsUser($user, 'success')) {
$updates['failed_attempts'] = db_unsigned_increment('failed_attempts', -1);
}

Expand Down
6 changes: 2 additions & 4 deletions app/Models/Solo/Score.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -64,7 +62,7 @@ public static function createFromJsonOrExplode(array $params)
// older lazer builds potentially submit incorrect details here (and we still want to
// accept their scores.
if (!$score->data->passed) {
$score->data->rank = 'D';
$score->data->rank = 'F';
}

$score->saveOrExplode();
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Solo/ScoreData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace App\Models\Solo;

use App\Enums\ScoreRank;
use App\Exceptions\InvariantException;
use App\Libraries\ScoreRank;
use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use JsonSerializable;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function set($model, $key, $value, $attributes)

public function assertCompleted(): void
{
if (!ScoreRank::isValid($this->rank)) {
if (ScoreRank::tryFrom($this->rank) === null) {
throw new InvariantException("'{$this->rank}' is not a valid rank.");
}

Expand Down
2 changes: 1 addition & 1 deletion app/Transformers/UserCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UserCompactTransformer extends TransformerAbstract

protected array $availableIncludes = [
'account_history',
'active_tournament_banner',
'active_tournament_banner', // deprecated
'active_tournament_banners',
'badges',
'beatmap_playcounts_count',
Expand Down
2 changes: 1 addition & 1 deletion app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ function nav_links()
$links['home'] = [
'_' => route('home'),
'page_title.main.news_controller._' => route('news.index'),
'layout.menu.home.team' => wiki_url('Team'),
'layout.menu.home.team' => wiki_url('People/osu!_team'),
'page_title.main.changelog_controller._' => route('changelog.index'),
'page_title.main.home_controller.get_download' => route('download'),
'page_title.main.home_controller.search' => route('search'),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"paypal/paypal-checkout-sdk": "*",
"sentry/sentry-laravel": "*",
"symfony/yaml": "*",
"tightenco/ziggy": ">=0.8.1",
"tightenco/ziggy": "^1.8",
"xsolla/xsolla-sdk-php": "dev-php81"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 66c3ab6

Please sign in to comment.