-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing primary key in Jobs_history + option to disable feedback …
…completely. (#2457) * Add missing primary key in Jobs_history + option to disable feedback completely. (#2457) * Wrap collections to avoid double queries (#2458)
- Loading branch information
Showing
10 changed files
with
148 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Livewire\DTO; | ||
|
||
use App\Exceptions\Internal\LycheeLogicException; | ||
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* @template T | ||
*/ | ||
class ProtectedCollection | ||
{ | ||
/** | ||
* @param bool $is_loaded | ||
* @param Collection<int,T>|null $collection | ||
* | ||
* @return void | ||
*/ | ||
public function __construct( | ||
private string $type, | ||
private bool $is_loaded = false, | ||
private ?Collection $collection = null, | ||
) { | ||
} | ||
|
||
/** | ||
* @return Collection<int,T>|null collection encapsulated | ||
* | ||
* @throws LycheeLogicException we queried it too early | ||
*/ | ||
public function get(): Collection|null | ||
{ | ||
if ($this->is_loaded) { | ||
return $this->collection; | ||
} | ||
|
||
throw new LycheeLogicException(sprintf('Collection %s data is not available.', $this->type)); | ||
} | ||
|
||
/** | ||
* Set the collection. | ||
* | ||
* @param Collection<int,T>|null $collection | ||
* | ||
* @return void | ||
*/ | ||
public function set(Collection|null $collection) | ||
{ | ||
$this->is_loaded = true; | ||
$this->collection = $collection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
database/migrations/2024_06_08_093403_primary_key_job_history.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('jobs_history', function (Blueprint $table) { | ||
$table->index(['owner_id', 'status']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// We cannot remove index key because owner_id is used for FK constraint. | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_06_08_103842_add_config_display_processing_queue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use App\Models\Extensions\BaseConfigMigration; | ||
|
||
return new class() extends BaseConfigMigration { | ||
public const PROCESSING = 'Image Processing'; | ||
public const BOOL = '0|1'; | ||
|
||
public function getConfigs(): array | ||
{ | ||
return [ | ||
[ | ||
'key' => 'job_processing_queue_visible', | ||
'value' => '1', | ||
'is_secret' => false, | ||
'cat' => self::PROCESSING, | ||
'type_range' => self::BOOL, | ||
'description' => 'Enable the processing queue in the bottom left corner.', | ||
], | ||
]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters