Set ebook placeholders to not be in progress when a project is marked as abandoned

This commit is contained in:
Alex Cabal 2024-12-16 23:54:40 -06:00
parent 97021ce26d
commit 28b7384769
2 changed files with 32 additions and 0 deletions

View file

@ -118,6 +118,27 @@ class EbookPlaceholder{
$this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes]); $this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes]);
} }
/**
* @throws Exceptions\InvalidEbookPlaceholderException
*/
public function Save(): void{
$this->Validate();
Db::Query('
UPDATE
EbookPlaceholders
set
YearPublished = ?,
Difficulty = ?,
TranscriptionUrl = ?,
IsWanted = ?,
IsInProgress = ?,
IsPatron = ?,
Notes = ?
where EbookId = ?
', [$this->YearPublished, $this->Difficulty, $this->TranscriptionUrl,
$this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes, $this->EbookId]);
}
public function Delete(): void{ public function Delete(): void{
Db::Query(' Db::Query('
DELETE DELETE

View file

@ -65,6 +65,17 @@ foreach($projects as $project){
// A stalled `Project` is now abandoned. // A stalled `Project` is now abandoned.
$project->Status = Enums\ProjectStatusType::Abandoned; $project->Status = Enums\ProjectStatusType::Abandoned;
// Set the corresponding `EbookPlaceholder` to not be "in progress" any more.
if($project->Ebook->EbookPlaceholder !== null){
try{
$project->Ebook->EbookPlaceholder->IsInProgress = false;
$project->Ebook->EbookPlaceholder->Save();
}
catch(Exceptions\InvalidEbookPlaceholderException){
// Pass.
}
}
// Send a notification to the producer. // Send a notification to the producer.
$project->SendReminder(Enums\ProjectReminderType::Abandoned); $project->SendReminder(Enums\ProjectReminderType::Abandoned);
} }