Skip to content

Commit

Permalink
Merge branch 'score-solo-index' into solo-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Sep 7, 2023
2 parents 16ece1e + a81f454 commit 4eea110
Show file tree
Hide file tree
Showing 619 changed files with 6,187 additions and 5,200 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module.exports = {
env: {
es2017: true,
es2020: true,
node: true,
},
extends: [
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
tools: composer:v2
php-version: '8.1'
php-version: '8.2'
coverage: none

- name: Get composer cache directory
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Install js dependencies
run: yarn --frozen-lockfile

- run: 'yarn lint --max-warnings 102 > /dev/null'
- run: 'yarn lint --max-warnings 98 > /dev/null'

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

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
tests:
strategy:
matrix:
php: ['8.1']
php: ['8.2']
name: Tests
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -143,8 +143,8 @@ jobs:
- name: Setup indices
run: |
php artisan es:create-search-blacklist
php artisan es:index-documents --yes
php artisan es:index-wiki --create-only --yes
php artisan es:index-documents --no-interaction
php artisan es:index-wiki --create-only --no-interaction
- name: Generate docs
run: php artisan scribe:generate
Expand All @@ -158,7 +158,7 @@ jobs:
# but has since been fixed.
# Something should still be done regarding es index between tests though.
- name: Clean indexes
run: php artisan es:index-documents --yes
run: php artisan es:index-documents --no-interaction

- name: Run Dusk
run: ./bin/run_dusk.sh
Expand Down
28 changes: 14 additions & 14 deletions Dockerfile.deployment
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ RUN DEBIAN_FRONTEND=noninteractive apt install -y \
jhead \
nginx \
nodejs \
php8.1-common \
php8.1-curl \
php8.1-ds \
php8.1-gd \
php8.1-intl \
php8.1-mbstring \
php8.1-mysql \
php8.1-redis \
php8.1-sqlite3 \
php8.1-swoole \
php8.1-tokenizer \
php8.1-xml \
php8.1-zip \
php8.1 \
php8.2 \
php8.2-common \
php8.2-curl \
php8.2-ds \
php8.2-gd \
php8.2-intl \
php8.2-mbstring \
php8.2-mysql \
php8.2-redis \
php8.2-sqlite3 \
php8.2-swoole \
php8.2-tokenizer \
php8.2-xml \
php8.2-zip \
zip

RUN npm install -g yarn
Expand Down
28 changes: 14 additions & 14 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ RUN DEBIAN_FRONTEND=noninteractive apt install -y \
libnss3 \
netcat-openbsd \
nodejs \
php8.1 \
php8.1-common \
php8.1-curl \
php8.1-ds \
php8.1-gd \
php8.1-intl \
php8.1-mbstring \
php8.1-mysql \
php8.1-redis \
php8.1-sqlite3 \
php8.1-swoole \
php8.1-tokenizer \
php8.1-xml \
php8.1-zip \
php8.2 \
php8.2-common \
php8.2-curl \
php8.2-ds \
php8.2-gd \
php8.2-intl \
php8.2-mbstring \
php8.2-mysql \
php8.2-redis \
php8.2-sqlite3 \
php8.2-swoole \
php8.2-tokenizer \
php8.2-xml \
php8.2-zip \
zip

RUN npm install -g yarn
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The browser-facing portion of [osu!](https://osu.ppy.sh/home).

## Requirements

- A PHP 8.1+ environment
- A PHP 8.2 environment
- MySQL 8.0+
- Elasticsearch

Expand Down
24 changes: 20 additions & 4 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ There are multiple services involved:
- redis: cache and session server. Can be skipped just like db service
- elasticsearch: search database. Can be skipped just like db service
- nginx: proxies php and notification-server(-dusk) so they can be accessed under same host
- score-indexer: `Solo\Score` indexer.
- score-indexer-test: `Solo\Score` indexer used by tests.

#### Modifying environment (`.env`, `.env.dusk.local`) files

Expand Down Expand Up @@ -223,8 +225,6 @@ php artisan tinker

## Generating assets

Using Laravel's [Mix](https://laravel.com/docs/6.x/mix).

```bash
# build assets (should be done automatically if using docker)
yarn run development
Expand Down Expand Up @@ -272,13 +272,13 @@ Once the env files are set, database for testing will need to be setup:
Tests should be run against an empty database, to initialize an empty database:

```
APP_ENV=testing php artisan migrate:fresh --yes
APP_ENV=testing php artisan migrate:fresh --no-interaction
```

or if using docker:

```
docker compose run --rm -e APP_ENV=testing php artisan migrate:fresh --yes
docker compose run --rm -e APP_ENV=testing php artisan migrate:fresh --no-interaction
```

---
Expand Down Expand Up @@ -308,6 +308,22 @@ Regular PHPUnit arguments are accepted, e.g.:
bin/phpunit.sh --filter=Route --stop-on-failure
```

## Test groups

Some tests are marked with a `@group` they require a specific service to be available.
These groups can be used to exclude tests:

bin/phpunit.sh --exclude=RequiresScoreIndexer,RequiresBeatmapDifficultyLookupCache

or run only those tests:

bin/phpunit.sh --group=RequiresScoreIndexer

- `RequiresBeatmapDifficultyLookupCache`: Requires `beatmap-difficulty-lookup-cache` to be running
- `RequiresScoreIndexer`: Requires a score indexing schema to be set and `score-indexer-test` service to be running

Most tests require `elasticsearch` and `redis` to be available, so these are not optional.

## Browser tests

Browser tests are run using Laravel Dusk:
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/BeatmapLeadersRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BeatmapLeadersRefresh extends Command
*/
public function handle()
{
$continue = $this->option('yes') || $this->confirm('This will recalculate beatmap leaders, continue?');
$continue = $this->option('yes') || $this->confirm('This will recalculate beatmap leaders, continue?', true);

if (!$continue) {
return $this->error('User aborted!');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/EsIndexDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ protected function starterMessage(array $oldIndices)
$confirmMessage = 'This will create new indices';
}

return $this->yes || $this->confirm("{$confirmMessage}, begin indexing?");
return $this->yes || $this->confirm("{$confirmMessage}, begin indexing?", true);
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/EsIndexWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function starterMessage()
);
}

return $this->yes || $this->confirm("This index to {$this->indexName}, begin indexing?");
return $this->yes || $this->confirm("This index to {$this->indexName}, begin indexing?", true);
}

private function updateSitemap()
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/ForumTopicCoversCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handle()
$createdBefore = now()->subDays(get_int($this->option('maxdays')) ?? 30);
$this->line("This will delete unused topic covers before {$createdBefore}.");

if (!$this->option('yes') && !$this->confirm('Proceed?')) {
if (!$this->option('yes') && !$this->confirm('Proceed?', true)) {
$this->error('Aborted.');
return;
}
Expand Down
7 changes: 4 additions & 3 deletions app/Console/Commands/MigrateFreshAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function handle()
$this->warn("{$name} => {$config['database']}");
}

$continue = $this->option('yes') || $this->confirm('continue?');
$continue = $this->option('yes') || $this->confirm('continue?', true);
if (!$continue) {
$this->error('User aborted!');
return 1;
Expand All @@ -34,6 +34,7 @@ public function handle()
$this->warn($database);
$this->call('db:wipe', [
'--database' => $database,
'--drop-views' => true,
]);
}

Expand All @@ -47,13 +48,13 @@ public function handle()

$this->call('es:index-documents', [
'--cleanup' => true,
'--yes' => $this->option('yes'),
'--no-interaction' => $this->option('no-interaction'),
]);

$this->call('es:index-wiki', [
'--cleanup' => true,
'--create-only' => true,
'--yes' => $this->option('yes'),
'--no-interaction' => $this->option('no-interaction'),
]);

$this->call('es:create-search-blacklist');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/MigrateFreshOrRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle()
private function fresh()
{
$this->info('Database is empty. Calling migrate:fresh to initalise database and elasticsearch.');
$this->call('migrate:fresh', ['--yes' => true]);
$this->call('migrate:fresh', ['--no-interaction' => true]);
}

private function migrate()
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function schedule(Schedule $schedule)
->everyThirtyMinutes()
->onOneServer();

$schedule->command('forum:topic-cover-cleanup --yes')
$schedule->command('forum:topic-cover-cleanup --no-interaction')
->daily()
->withoutOverlapping()
->onOneServer();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BeatmapPacksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BeatmapPacksController extends Controller

public function index()
{
$type = presence(Request::input('type')) ?? BeatmapPack::DEFAULT_TYPE;
$type = presence(get_string(Request::input('type'))) ?? BeatmapPack::DEFAULT_TYPE;
$packs = BeatmapPack::getPacks($type);
if ($packs === null) {
abort(404);
Expand Down
13 changes: 12 additions & 1 deletion app/Http/Controllers/Chat/Channels/MessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Controllers\Chat\Controller as BaseController;
use App\Libraries\Chat;
use App\Models\Chat\Channel;
use App\Models\Chat\Message;
use App\Transformers\Chat\MessageTransformer;
use App\Transformers\UserCompactTransformer;

Expand All @@ -16,6 +17,14 @@
*/
class MessagesController extends BaseController
{
public function __construct()
{
$this->middleware('require-scopes:chat.read', ['only' => ['index']]);
$this->middleware('require-scopes:chat.write', ['only' => ['store']]);

parent::__construct();
}

/**
* Get Channel Messages
*
Expand Down Expand Up @@ -103,7 +112,7 @@ public function index($channelId)
}

$messages = $channel
->filteredMessages()
->messages()
->with(['channel', 'sender'])
->limit($limit);

Expand All @@ -119,6 +128,8 @@ public function index($channelId)
$messages = $messages->orderBy('message_id', 'desc')->get()->reverse();
}

$messages = Message::filterBacklogs($channel, $messages);

if (!$returnObject) {
return json_collection(
$messages,
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Chat/ChannelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ChannelsController extends Controller
{
public function __construct()
{
$this->middleware('require-scopes:chat.write', ['only' => 'store']);
$this->middleware('require-scopes:chat.read', ['only' => ['index', 'markAsRead', 'show']]);
$this->middleware('require-scopes:chat.write_manage', ['only' => ['part', 'join', 'store']]);

parent::__construct();
}
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/Chat/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class ChatController extends Controller
{
public function __construct()
{
$this->middleware('require-scopes:chat.write', ['only' => 'newConversation']);
$this->middleware('require-scopes:chat.read', ['only' => ['ack']]);
$this->middleware('require-scopes:chat.write', ['only' => ['newConversation']]);

// TODO: remove as it's already defined in parent controller?
$this->middleware('auth');

parent::__construct();
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function opensearch()

public function quickSearch()
{
$quickSearch = new QuickSearch(request(), ['user' => auth()->user()]);
$quickSearch = new QuickSearch(Request::all(), ['user' => auth()->user()]);
$searches = $quickSearch->searches();

$result = [];
Expand Down Expand Up @@ -177,18 +177,20 @@ public function quickSearch()
*/
public function search()
{
if (request('mode') === 'beatmapset') {
return ujs_redirect(route('beatmapsets.index', ['q' => request('query')]));
$currentUser = Auth::user();
$allSearch = new AllSearch(Request::all(), ['user' => $currentUser]);

if ($allSearch->getMode() === 'beatmapset') {
return ujs_redirect(route('beatmapsets.index', ['q' => $allSearch->getRawQuery()]));
}

$allSearch = new AllSearch(request(), ['user' => Auth::user()]);
$isSearchPage = true;

if (is_api_request()) {
return response()->json($allSearch->toJson());
}

$fields = Auth::user()?->isModerator() ?? false ? [] : ['includeDeleted' => null];
$fields = $currentUser?->isModerator() ?? false ? [] : ['includeDeleted' => null];

return ext_view('home.search', compact('allSearch', 'fields', 'isSearchPage'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/InterOp/ArtistTracksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function reindexAll()
'--cleanup' => $params['cleanup'] ?? true,
'--inplace' => $params['inplace'] ?? true,
'--types' => 'artist_tracks',
'--yes' => true,
'--no-interaction' => true,
]);

return response()->noContent();
Expand Down
Loading

0 comments on commit 4eea110

Please sign in to comment.