diff --git a/laravel_app/app/Console/Commands/BuildReports.php b/laravel_app/app/Console/Commands/BuildReports.php new file mode 100644 index 0000000..f3fed64 --- /dev/null +++ b/laravel_app/app/Console/Commands/BuildReports.php @@ -0,0 +1,33 @@ +schedule(); + } +} diff --git a/laravel_app/app/Console/Kernel.php b/laravel_app/app/Console/Kernel.php index c9ab14d..9a912d2 100644 --- a/laravel_app/app/Console/Kernel.php +++ b/laravel_app/app/Console/Kernel.php @@ -12,8 +12,8 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule): void { -// $schedule->command('invoices:create')->weekdays()->twiceDaily(9,17)->timezone('Europe/Amsterdam'); $schedule->command('queue:work --sansdaemon')->everyMinute()->withoutOverlapping(); + $schedule->command('smartcane:build-reports')->dailyAt('2:00'); } /** diff --git a/laravel_app/app/Enums/Status.php b/laravel_app/app/Enums/Status.php new file mode 100644 index 0000000..c277d0f --- /dev/null +++ b/laravel_app/app/Enums/Status.php @@ -0,0 +1,10 @@ +getErrorOutput()); } - $this->download->update(['status' => 'completed']); + $this->download->setStatusSuccess(); } public static function handleForDate(Project $project, Carbon $date) { $filename = $date->format('Y-m-d') . '.tif'; - if ($project->downloads()->where(['status' => 'completed', 'name' => $filename])->count() > 0) { - return; + if ($project->downloads()->statusSuccess()->where(['name' => $filename])->exists()) { + return new NullJob(); } $path = $project->download_path . '/merged_final_tif/' . $filename; @@ -65,7 +66,6 @@ public static function handleForDate(Project $project, Carbon $date) $project->downloads()->create([ 'name' => $filename, 'path' => $path, - 'status' => 'completed', ]), $date ); diff --git a/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php b/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php index 82240c1..4bd77ce 100644 --- a/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php +++ b/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Enums\Status; use App\Models\Project; use App\Models\ProjectDownload; use App\Models\ProjectMosaic; @@ -19,7 +20,7 @@ class ProjectMosiacGeneratorJob implements ShouldQueue { use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public ProjectMosaic $mosaic; + public ProjectMosaic $mosaic; protected $timeout = 220; @@ -53,6 +54,7 @@ public function handle(): void $process->setEnv(['PATH' => $currentPath.':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']); // $process->setTimeout(36000); // stel een geschikte timeout in $process->start(); + try { $myOutput = []; $process->wait(function ($type, $buffer) use (&$myOutput) { @@ -61,26 +63,31 @@ public function handle(): void logger($buffer); }); $this->processOutput = collect($myOutput)->join('\n'); + $this->mosaic->setStatusSuccess(); } catch (ProcessFailedException $exception) { echo $exception->getMessage(); + $this->mosaic->setStatusFailed(); + } - $this->mosaic->update([ - 'status' => 'complete', - ]); } - public static function handleFor(Project $project, $year, $startWeekNumber) { - if ($project->mosaics()->where(['status' => 'complete', 'year' => $year, 'week' => $startWeekNumber])->count() > 0) { - return; + public static function handleFor(Project $project, $year, $startWeekNumber) + { + if ($project->hasInvalidMosaicFor($year, $startWeekNumber)) { + return new NullJob(); } - $mosaic = $project->mosaics()->create([ - 'name' => sprintf('Week %d, %d', $startWeekNumber, $year), - 'path' => sprintf('%s/%s/%s', $project->download_path, 'mosaics', sprintf('week_%d_%d.tif', $startWeekNumber, $year)), - 'year' => $year, - 'week' => $startWeekNumber, - 'status' => 'pending', - ]); + + $mosaic = $project->mosaics()->updateOrCreate( + [ + 'year' => $year, + 'week' => $startWeekNumber, + ], + [ + 'name' => sprintf('Week %d, %d', $startWeekNumber, $year), + 'path' => sprintf('%s/%s/%s', $project->download_path, 'mosaics', + sprintf('week_%d_%d.tif', $startWeekNumber, $year)), + ]); return new self($mosaic); } } diff --git a/laravel_app/app/Jobs/ProjectReportGeneratorJob.php b/laravel_app/app/Jobs/ProjectReportGeneratorJob.php index dabba42..0b766fc 100644 --- a/laravel_app/app/Jobs/ProjectReportGeneratorJob.php +++ b/laravel_app/app/Jobs/ProjectReportGeneratorJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Livewire\Forms\MailingForm; use App\Models\ProjectReport; use Illuminate\Bus\Batchable; use Illuminate\Bus\Queueable; @@ -18,22 +19,22 @@ class ProjectReportGeneratorJob implements ShouldQueue public $timeout = 220; private ProjectReport $projectReport; + private bool $sendMail; /** * Create a new job instance. */ - public function __construct(ProjectReport $projectReport) + public function __construct(ProjectReport $projectReport, $sendMail = false) { $this->projectReport = $projectReport; - // + $this->sendMail = $sendMail; } /** * Execute the job. */ - public function handle(): void + public function handle() { - logger('in handle'); $this->projectReport->weeksAgo(); $projectFolder = base_path('../'); @@ -68,6 +69,19 @@ public function handle(): void $this->projectReport->setStatusFailed(); } - // + $this->sendMail(); + } + + private function sendMail(): void + { + if ($this->sendMail && $this->projectReport->statusIsSuccessful()) { + logger('sendMail'); + MailingForm::saveAndSendMailing( + $this->projectReport, + $this->projectReport->project->mail_subject, + $this->projectReport->project->mail_template, + $this->projectReport->project->emailRecipients()->get(['email', 'name'])->toArray() + ); + } } } diff --git a/laravel_app/app/Listeners/UpdateMailingStatus.php b/laravel_app/app/Listeners/UpdateMailingStatus.php new file mode 100644 index 0000000..6bf65e3 --- /dev/null +++ b/laravel_app/app/Listeners/UpdateMailingStatus.php @@ -0,0 +1,28 @@ +data['mailing']['id']) + ->update(['status' => 'success']); + } +} diff --git a/laravel_app/app/Livewire/Forms/MailingForm.php b/laravel_app/app/Livewire/Forms/MailingForm.php index e1789f3..34ae986 100644 --- a/laravel_app/app/Livewire/Forms/MailingForm.php +++ b/laravel_app/app/Livewire/Forms/MailingForm.php @@ -28,26 +28,30 @@ public function setReport(ProjectReport $report) $this->subject = $report->project->mail_subject; $this->message = $report->project->mail_template; $this->recipients = $this->report->project->emailRecipients()->get(['email', 'name'])->toArray(); + + } public function save() { $this->validate(); + self::saveAndSendMailing($this->report, $this->subject, $this->message, $this->recipients); - $mailing = $this->report->project->mailings()->create([ - 'subject' => $this->subject, - 'message' => $this->message, + $this->setReport($this->report); + } + + public static function saveAndSendMailing($report, $subject, $message, $recipients) { + $mailing = $report->project->mailings()->create([ + 'subject' => $subject, + 'message' => $message, ]); $mailing->attachments()->create([ - 'name' => $this->report->name, - 'path' => $this->report->path, + 'name' => $report->name, + 'path' => $report->path, ]); - $mailing->recipients()->createMany($this->recipients); - - $this->setReport($this->report); - + $mailing->recipients()->createMany($recipients); Mail::to($mailing->recipients()->pluck('email')->toArray()) ->send(new \App\Mail\ReportMailer($mailing)); diff --git a/laravel_app/app/Livewire/Projects/MosaicManager.php b/laravel_app/app/Livewire/Projects/MosaicManager.php index ce0c3ce..e9b24a2 100644 --- a/laravel_app/app/Livewire/Projects/MosaicManager.php +++ b/laravel_app/app/Livewire/Projects/MosaicManager.php @@ -38,7 +38,6 @@ public function saveMosaic(){ 'year' => $this->formData['year'], 'week' => $this->formData['week'], ],[ - 'status' => 'pending', 'path' => $this->project->getMosaicPath(), ]); diff --git a/laravel_app/app/Livewire/Projects/ReportManager.php b/laravel_app/app/Livewire/Projects/ReportManager.php index cfbe9c3..da95ff0 100644 --- a/laravel_app/app/Livewire/Projects/ReportManager.php +++ b/laravel_app/app/Livewire/Projects/ReportManager.php @@ -42,7 +42,6 @@ private function resetFormData() public function saveProjectReport() { - sleep(1); $this->validate([ 'formData.week' => ['required', 'integer', 'min:1', 'max:53' ], 'formData.year' => 'required|integer|min:2020|max:'.now()->addYear()->year, diff --git a/laravel_app/app/Mail/ReportMailer.php b/laravel_app/app/Mail/ReportMailer.php index 7a130ef..4465ec8 100644 --- a/laravel_app/app/Mail/ReportMailer.php +++ b/laravel_app/app/Mail/ReportMailer.php @@ -26,6 +26,9 @@ class ReportMailer extends Mailable public function __construct(ProjectMailing $mailing) { $this->mailing = $mailing; + $this->withSwiftMessage(function ($message) use ($mailing) { + $message->getHeaders()->addTextHeader('X-Mailing-ID', $mailing->id); + }); } /** @@ -34,7 +37,7 @@ public function __construct(ProjectMailing $mailing) public function envelope(): Envelope { return new Envelope( - subject: $this->mailing->subject, + subject:$this->mailing->subject, ); } @@ -56,11 +59,18 @@ public function content(): Content public function attachments(): array { return $this->mailing->attachments()->get()->map(function (ProjectMailingAttachment $attachment) { + $mime = 'application/pdf'; // default MIME type + $extension = pathinfo($attachment->path, PATHINFO_EXTENSION); + + if ($extension === 'docx') { + $mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + } + return Attachment::fromStorage( - path: $attachment->mailing->project->download_path.$attachment->path + path: $attachment->mailing->project->download_path."/".$attachment->path ) - ->as($attachment->name) - ->withMime('application/pdf'); + ->as($attachment->path) + ->withMime($mime); })->toArray(); } } diff --git a/laravel_app/app/Models/Project.php b/laravel_app/app/Models/Project.php index f7aafbf..b703898 100644 --- a/laravel_app/app/Models/Project.php +++ b/laravel_app/app/Models/Project.php @@ -5,6 +5,7 @@ use App\Jobs\ProjectDownloadTiffJob; use App\Jobs\ProjectMosiacGeneratorJob; use App\Jobs\ProjectReportGeneratorJob; +use App\Livewire\Forms\MailingForm; use Carbon\CarbonPeriod; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -243,12 +244,12 @@ public function getMergedTiffList() public function hasPendingDownload(): bool { - return $this->downloads()->where('status', 'pending')->count() > 0; + return $this->downloads()->statusPending()->count() > 0; } public function hasPendingMosaic(): bool { - return $this->mosaics()->where('status', 'pending')->count() > 0; + return $this->mosaics()->statusPending()->count() > 0; } public function startDownload(Carbon $date) @@ -260,29 +261,69 @@ public function startDownload(Carbon $date) ], [ 'path' => sprintf('%s/%s/%s.tif', $this->download_path, 'merged_final_tif', $date->format('Y-m-d')), - 'status' => 'pending', ] ); ProjectDownloadTiffJob::dispatch($downloadRequest, $date); } - public function scheduleReport($year, $week) + public function schedule() { -// if ($this->reports()->where(['year' => $year, 'week' => $week])->count() > 0) { -// return; -// } - - Bus::chain([ - Bus::batch(self::getFileDownloadsFor($year, $week)), - Bus::batch(self::getMosaicsFor($year, $week)), - Bus::batch(self::getReportFor($year, $week)), - ])->dispatch(); - return "done"; + if ($this->shouldSchedule()) { + $this->scheduleReport(); + } + $this->mail_frequency = 'weekly'; + $this->mail_day = 'friday'; + $this->scheduleReport(); } - public function getReportFor($year, $week) + public function shouldSchedule(): bool { + if (strtolower($this->mail_day) === strtolower(now()->englishDayOfWeek)) { + return strtolower($this->mail_frequency) === 'weekly' || now()->day <= 7; + } + return false; + } + public function hasInvalidMosaicFor($year, $week): bool + { + $dayOfWeekIso = Carbon::parse($this->mail_day)->dayOfWeekIso; + $min_updated_at_date = now() + ->setISODate($year, $week) + ->startOfWeek() + ->addDays($dayOfWeekIso - 1) + ->format('Y-m-d'); + + return $this->mosaics() + ->where('updated_at', '>=', $min_updated_at_date) + ->statusSuccess() + ->where(['year' => $year, 'week' => $week]) + ->exists(); + + } + + public function scheduleReport($year = null, $week = null) + { + // if year, week is in the future set year and week to null; + if (now()->year < $year || (now()->year === $year && now()->weekOfYear < $week)) { + $year = null; + $week = null; + logger('year and week is in the future default to now'); + } + + $year = $year ?? now()->year; + $week = $week ?? now()->weekOfYear; + + Bus::chain([ + Bus::batch($this->getFileDownloadsFor($year, $week)), + Bus::batch($this->getMosaicsFor($year, $week)), + Bus::batch($this->getReportFor($year, $week, true)), + ]) + ->dispatch(); + return "done"; + } + + public function getReportFor($year, $week, $sendMail = false) + { $report = $this->reports()->create([ 'name' => 'Report for week '.$week.' of '.$year, 'week' => $week, @@ -290,27 +331,30 @@ public function getReportFor($year, $week) 'path' => 'reports/week_'.$week.'_'.$year.'.docx', ]); - return new ProjectReportGeneratorJob($report); + return [new ProjectReportGeneratorJob($report, $sendMail)]; } public function getFileDownloadsFor($year, $startWeekNumber) { - $endOfRange = \Illuminate\Support\Carbon::now()->setISODate($year, $startWeekNumber)->endOfWeek(); + $endOfRange = now()->setISODate($year, $startWeekNumber)->endOfWeek(); $startOfRange = (clone $endOfRange)->subWeeks(3)->startOfWeek(); $dateRange = CarbonPeriod::create($startOfRange, $endOfRange); - return collect($dateRange) + $return = collect($dateRange) ->map(fn($date) => ProjectDownloadTiffJob::handleForDate($this, $date)) ->filter() ->toArray(); + return $return; } public function getMosaicsFor($year, $startWeekNumber) { - return collect(range(0, 3)) + $return = collect(range(0, 3)) ->map(fn($weekDiff) => ProjectMosiacGeneratorJob::handleFor($this, $year, $startWeekNumber - $weekDiff)) ->filter() ->toArray(); + + return $return; } } diff --git a/laravel_app/app/Models/ProjectDownload.php b/laravel_app/app/Models/ProjectDownload.php index 84cb300..87a3526 100644 --- a/laravel_app/app/Models/ProjectDownload.php +++ b/laravel_app/app/Models/ProjectDownload.php @@ -2,17 +2,19 @@ namespace App\Models; +use App\Traits\HasStatus; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class ProjectDownload extends Model { use HasFactory; + use HasStatus; + protected $fillable = [ 'name', 'path', - 'status', ]; public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/laravel_app/app/Models/ProjectMailing.php b/laravel_app/app/Models/ProjectMailing.php index 909a8c5..3126b65 100644 --- a/laravel_app/app/Models/ProjectMailing.php +++ b/laravel_app/app/Models/ProjectMailing.php @@ -2,6 +2,8 @@ namespace App\Models; +use App\Traits\HasStatus; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\UploadedFile; @@ -12,6 +14,7 @@ class ProjectMailing extends Model { use HasFactory; + use HasStatus; protected $fillable = [ 'subject', @@ -51,4 +54,13 @@ public function attachments() { return $this->hasMany(ProjectMailingAttachment::class); } + + protected function subject(): Attribute + { + return Attribute::make( + set: function ($value) { + return str_replace(['{date}'], [now()->toDateString()], $value); + } + ); + } } diff --git a/laravel_app/app/Models/ProjectMosaic.php b/laravel_app/app/Models/ProjectMosaic.php index d2cc1b8..7727b26 100644 --- a/laravel_app/app/Models/ProjectMosaic.php +++ b/laravel_app/app/Models/ProjectMosaic.php @@ -8,12 +8,11 @@ class ProjectMosaic extends Model { use HasFactory; + use \App\Traits\HasStatus; protected $fillable = [ 'name', 'path', - 'status', - 'year', 'week', ]; diff --git a/laravel_app/app/Models/ProjectReport.php b/laravel_app/app/Models/ProjectReport.php index 865583e..24e65bb 100644 --- a/laravel_app/app/Models/ProjectReport.php +++ b/laravel_app/app/Models/ProjectReport.php @@ -4,6 +4,7 @@ use App\Jobs\ProjectDownloadTiffJob; use App\Jobs\ProjectMosiacGeneratorJob; +use App\Traits\HasStatus; use Carbon\CarbonPeriod; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -12,19 +13,10 @@ class ProjectReport extends Model { - protected $fillable = ['name', 'path', 'week', 'year', 'status']; + use HasStatus; + protected $fillable = ['name', 'path', 'week', 'year']; - public function setStatusSuccess() - { - $this->status = 'success'; - $this->save(); - } - public function setStatusFailed() - { - $this->status = 'failed'; - $this->save(); - } public function project() { diff --git a/laravel_app/app/Providers/EventServiceProvider.php b/laravel_app/app/Providers/EventServiceProvider.php index 2d65aac..77984d4 100644 --- a/laravel_app/app/Providers/EventServiceProvider.php +++ b/laravel_app/app/Providers/EventServiceProvider.php @@ -2,9 +2,11 @@ namespace App\Providers; +use App\Listeners\UpdateMailingStatus; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use Illuminate\Mail\Events\MessageSent; use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider @@ -18,6 +20,9 @@ class EventServiceProvider extends ServiceProvider Registered::class => [ SendEmailVerificationNotification::class, ], + MessageSent::class => [ + UpdateMailingStatus::class, + ], ]; /** diff --git a/laravel_app/app/Traits/HasStatus.php b/laravel_app/app/Traits/HasStatus.php new file mode 100644 index 0000000..63f1b11 --- /dev/null +++ b/laravel_app/app/Traits/HasStatus.php @@ -0,0 +1,67 @@ +status = $status; + } + + public function setStatusSuccess() + { + $this->status = Status::Success; + $this->save(); + } + + public function setStatusFailed() + { + $this->status = Status::Failed; + $this->save(); + } + + public function setStatusPending() + { + $this->status = Status::Pending; + $this->save(); + } + + public function scopeStatusSuccess(Builder $query): Builder + { + return $query->where('status', Status::Success); + } + + public function scopeStatusFailed(Builder $query): Builder + { + return $query->where('status', Status::Failed); + } + + public function scopeStatusPending(Builder $query): Builder + { + return $query->where('status', Status::Pending); + } + + + public function statusIsSuccessful(): bool + { + return $this->status === Status::Success; + } + + public function statusHasFailed(): bool + { + return $this->status === Status::Failed; + } + + public function statusIsPending(): bool + { + return $this->status === Status::Pending; + } +} diff --git a/laravel_app/database/migrations/2023_11_21_125040_create_project_mailings_table.php b/laravel_app/database/migrations/2023_11_21_125040_create_project_mailings_table.php index 988f90f..f85e0d2 100644 --- a/laravel_app/database/migrations/2023_11_21_125040_create_project_mailings_table.php +++ b/laravel_app/database/migrations/2023_11_21_125040_create_project_mailings_table.php @@ -1,5 +1,6 @@ foreignId('project_id'); $table->string('subject'); $table->text('message'); - $table->string('status')->default('pending'); + $table->string('status')->default(Status::Pending); // $table->text('recipients'); $table->timestamps(); }); diff --git a/laravel_app/database/seeders/DatabaseSeeder.php b/laravel_app/database/seeders/DatabaseSeeder.php index 4372e52..34f122f 100644 --- a/laravel_app/database/seeders/DatabaseSeeder.php +++ b/laravel_app/database/seeders/DatabaseSeeder.php @@ -62,13 +62,13 @@ private function createChembaProject() ]); foreach ($chembaProject->getMergedTiffList() as $mergedTiff) { - $chembaProject->downloads()->create([ + $download = $chembaProject->downloads()->create([ 'name' => basename($mergedTiff), 'path' => $mergedTiff, - 'status' => 'completed', 'created_at' => '2021-01-01 00:00:00', 'updated_at' => '2021-01-01 00:00:00' ]); + $download->setStatusSuccess(); } $chembaProject->emailRecipients()->createMany([ @@ -89,19 +89,20 @@ private function createChembaProject() [ 'subject' => 'Chemba 2021-01-01', 'message' => 'Chemba 2021-01-01', - 'status' => 'completed', // 'pending 'created_at' => '2021-01-01 00:00:00', 'updated_at' => '2021-01-01 00:00:00', ], [ 'subject' => 'Chemba 2021-01-08', 'message' => 'Chemba 2021-01-08', - 'status' => 'completed', 'created_at' => '2021-01-08 00:00:00', 'updated_at' => '2021-01-08 00:00:00', ], ]); + foreach ($chembaProject->mailings as $mailing) { + $mailing->setStatusSuccess(); + $mailing->recipients()->createMany([ [ 'name' => 'Martin Folkerts', @@ -184,19 +185,18 @@ private function createXinavaneProject() [ 'subject' => 'Xinavane 2021-01-01', 'message' => 'Xinavane 2021-01-01', - 'status' => 'completed', 'created_at' => '2021-01-01 00:00:00', 'updated_at' => '2021-01-01 00:00:00', ], [ 'subject' => 'Xinavane 2021-01-08', 'message' => 'Xinavane 2021-01-08', - 'status' => 'completed', 'created_at' => '2021-01-08 00:00:00', 'updated_at' => '2021-01-08 00:00:00', ], ]); foreach ($project->mailings as $mailing) { + $mailing->setStatusSuccess(); $mailing->recipients()->createMany([ [ 'name' => 'Martin Folkerts', diff --git a/laravel_app/resources/views/components/badge.blade.php b/laravel_app/resources/views/components/badge.blade.php index 3501a7f..163cd38 100644 --- a/laravel_app/resources/views/components/badge.blade.php +++ b/laravel_app/resources/views/components/badge.blade.php @@ -1,5 +1,5 @@ @props([ - 'status' => 'success', + 'status' => \App\Enums\Status::Success, ]) ['bg' => 'bg-gray-100', 'text' => 'text-gray-600'], ]; +// If status is an object, try to convert it to a string +if (is_object($status)) { + $status = (string) $status; +} + // Default to 'success' if the provided status is not in the defined array if (!array_key_exists($status, $statusToColors)) { - $status = 'success'; + $status = \App\Enums\Status::Success; } // Get the color class for the given status $colorClasses = $statusToColors[$status]; - ?> diff --git a/laravel_app/resources/views/livewire/project/report-row.blade.php b/laravel_app/resources/views/livewire/project/report-row.blade.php index 87eecf3..d63331c 100644 --- a/laravel_app/resources/views/livewire/project/report-row.blade.php +++ b/laravel_app/resources/views/livewire/project/report-row.blade.php @@ -1,7 +1,7 @@ {{ $report->name }} - @if($report->status == 'pending') + @if($report->status == \App\Enums\Status::Pending) @else diff --git a/laravel_app/resources/views/livewire/projects/download-manager.blade.php b/laravel_app/resources/views/livewire/projects/download-manager.blade.php index ce310ed..4ccbcf5 100644 --- a/laravel_app/resources/views/livewire/projects/download-manager.blade.php +++ b/laravel_app/resources/views/livewire/projects/download-manager.blade.php @@ -9,7 +9,7 @@

Downloads

@if ($project->hasPendingDownload()) - Pending downloads for this project: {{ $project->downloads()->where('status', 'pending')->count() }} + Pending downloads for this project: {{ $project->downloads()->statusPending()->count() }} @endif

diff --git a/laravel_app/tests/Unit/Models/ProjectReportTest.php b/laravel_app/tests/Unit/Models/ProjectReportTest.php index 667ea4d..8088b04 100644 --- a/laravel_app/tests/Unit/Models/ProjectReportTest.php +++ b/laravel_app/tests/Unit/Models/ProjectReportTest.php @@ -58,8 +58,8 @@ public function it_can_get_the_full_path_name() 'year' => 2021, 'week' => 41, 'path' => 'path/doc.pdf', - 'status' => 'success', ]); + $projectReport->setStatusSuccess(); $this->assertEquals(storage_path('app/project_download_path/path/doc.pdf'), $projectReport->getFullPathName()); } @@ -79,8 +79,8 @@ public function it_can_return_the_reportDate($expected, $mail_day, $week, $year) 'year' => $year, 'week' => $week, 'path' => 'path/doc.pdf', - 'status' => 'success', ]); + $projectReport->setStatusSuccess(); $this->assertEquals($expected, $projectReport->getReportDate()); } diff --git a/r_app/Rplots.pdf b/r_app/Rplots.pdf index 6b91ab7..298c1e4 100644 Binary files a/r_app/Rplots.pdf and b/r_app/Rplots.pdf differ