From 46204b8579d97f30d49c0faabfc87088317b1450 Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Tue, 6 Oct 2020 21:41:17 -0400 Subject: [PATCH 1/3] add: job batching migration --- ..._10_07_012129_create_job_batches_table.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 database/migrations/2020_10_07_012129_create_job_batches_table.php diff --git a/database/migrations/2020_10_07_012129_create_job_batches_table.php b/database/migrations/2020_10_07_012129_create_job_batches_table.php new file mode 100644 index 0000000000..85ccbf89a7 --- /dev/null +++ b/database/migrations/2020_10_07_012129_create_job_batches_table.php @@ -0,0 +1,39 @@ +string('id')->primary(); + $table->string('name'); + $table->integer('total_jobs'); + $table->integer('pending_jobs'); + $table->integer('failed_jobs'); + $table->text('failed_job_ids'); + $table->text('options')->nullable(); + $table->integer('cancelled_at')->nullable(); + $table->integer('created_at'); + $table->integer('finished_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('job_batches'); + } +} From eb0b6380d34ca1db7db539d29b9950210a606733 Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Tue, 6 Oct 2020 21:43:04 -0400 Subject: [PATCH 2/3] update: mass action controller - pull cached groups that should not be included in the MassPM. - update users query to not included exempt group and only pluck the users id. --- app/Http/Controllers/Staff/MassActionController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Staff/MassActionController.php b/app/Http/Controllers/Staff/MassActionController.php index 09145dc55c..0d54495cd4 100644 --- a/app/Http/Controllers/Staff/MassActionController.php +++ b/app/Http/Controllers/Staff/MassActionController.php @@ -48,7 +48,12 @@ public function create() */ public function store(Request $request) { - $users = User::all(); + $banned_group = \cache()->rememberForever('banned_group', fn () => Group::where('slug', '=', 'banned')->pluck('id')); + $validating_group = \cache()->rememberForever('validating_group', fn () => Group::where('slug', '=', 'validating')->pluck('id')); + $disabled_group = \cache()->rememberForever('disabled_group', fn () => Group::where('slug', '=', 'disabled')->pluck('id')); + $pruned_group = \cache()->rememberForever('pruned_group', fn () => Group::where('slug', '=', 'pruned')->pluck('id')); + $users = User::whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->pluck('id'); + $subject = $request->input('subject'); $message = $request->input('message'); @@ -61,8 +66,9 @@ public function store(Request $request) return \redirect()->route('staff.mass-pm.create') ->withErrors($v->errors()); } - foreach ($users as $user) { - $this->dispatch(new ProcessMassPM(self::SENDER_ID, $user->id, $subject, $message)); + + foreach ($users as $user_id) { + ProcessMassPM::dispatch(self::SENDER_ID, $user_id, $subject, $message); } return \redirect()->route('staff.mass-pm.create') From e703bc77650e91ecdd6ca7eae31b728b46dc23e1 Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Wed, 7 Oct 2020 01:43:19 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI [ci skip] [skip ci] --- app/Http/Controllers/Staff/MassActionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Staff/MassActionController.php b/app/Http/Controllers/Staff/MassActionController.php index 0d54495cd4..4cd6e3c7f7 100644 --- a/app/Http/Controllers/Staff/MassActionController.php +++ b/app/Http/Controllers/Staff/MassActionController.php @@ -53,7 +53,7 @@ public function store(Request $request) $disabled_group = \cache()->rememberForever('disabled_group', fn () => Group::where('slug', '=', 'disabled')->pluck('id')); $pruned_group = \cache()->rememberForever('pruned_group', fn () => Group::where('slug', '=', 'pruned')->pluck('id')); $users = User::whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->pluck('id'); - + $subject = $request->input('subject'); $message = $request->input('message');