the browser-facing portion of osu!
at master 1.1 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Controllers\InterOp\Indexing; 7 8use App\Http\Controllers\Controller; 9use App\Jobs\EsIndexDocumentBulk; 10use App\Libraries\MorphMap; 11 12class BulkController extends Controller 13{ 14 public function store() 15 { 16 // TODO: limited to these for now. 17 static $allowedTypes = ['beatmapset', 'score', 'user']; 18 19 $params = request()->all(); 20 21 foreach ($params as $type => $paramIds) { 22 if (!in_array($type, $allowedTypes, true)) { 23 continue; 24 } 25 26 $ids = get_param_value($paramIds, 'int[]'); 27 $className = MorphMap::getClass($type); 28 29 if ($type === 'score') { 30 \Artisan::queue('es:index-scores:queue', ['--ids' => $ids]); 31 } else { 32 dispatch(new EsIndexDocumentBulk($className, $ids)); 33 } 34 } 35 36 return response(null, 204); 37 } 38}