Throttle recalculating scores.
This commit is contained in:
parent
33bca1cfdf
commit
4f317f1458
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers\Tabulation;
|
||||
|
||||
use App\Actions\Tabulation\CalculateAuditionScores;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Audition;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SeatingStatusController extends Controller
|
||||
{
|
||||
|
|
@ -13,6 +15,24 @@ class SeatingStatusController extends Controller
|
|||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
if (! Cache::has('seating_status_audition_totaler_throttle')) {
|
||||
$lock = Cache::lock('seating_status_audition_totaler_lock');
|
||||
|
||||
if ($lock->get()) {
|
||||
try {
|
||||
$totaler = app(CalculateAuditionScores::class);
|
||||
foreach (Audition::forSeating()->with('judges')->get() as $audition) {
|
||||
$totaler($audition);
|
||||
}
|
||||
|
||||
// set throttle
|
||||
Cache::put('seating_status_audition_totaler_throttle', true, 15);
|
||||
} finally {
|
||||
$lock->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$auditions = Audition::forSeating()
|
||||
->withCount([
|
||||
'entries' => function ($query) {
|
||||
|
|
@ -25,6 +45,7 @@ class SeatingStatusController extends Controller
|
|||
},
|
||||
])
|
||||
->with('flags')
|
||||
->with('entries')
|
||||
->get();
|
||||
$auditionData = [];
|
||||
foreach ($auditions as $audition) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue