diff --git a/.idea/codeception.xml b/.idea/codeception.xml
new file mode 100644
index 0000000..2edf080
--- /dev/null
+++ b/.idea/codeception.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
index 4a1d1e0..dce468a 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -12,7 +12,6 @@
-
@@ -33,7 +32,6 @@
-
@@ -135,6 +133,7 @@
+
diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml
new file mode 100644
index 0000000..355ae6b
--- /dev/null
+++ b/.idea/phpspec.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/smartCane.iml b/.idea/smartCane.iml
index 3c7f70d..5c0edc3 100644
--- a/.idea/smartCane.iml
+++ b/.idea/smartCane.iml
@@ -6,6 +6,9 @@
+
+
+
@@ -24,8 +27,6 @@
-
-
@@ -132,6 +133,7 @@
+
diff --git a/build_report.sh b/build_report.sh
index 2959f36..125b122 100755
--- a/build_report.sh
+++ b/build_report.sh
@@ -47,5 +47,5 @@ echo 'zx28tb' | /usr/bin/sudo -S launchctl load -w /System/Library/LaunchAgents/
cd /Users/mfolkerts/smartCane/r_app
#Rscript -e "rmarkdown::render('/Users/mfolkerts/smartCane/r_app/CI_Report_dashboard_planet.Rmd', 'all')"
#Rscript 1_harvest_data_EcoFarm_v2.R
-Rscript 2_CI_data_prep.R $weeks_ago
+#Rscript 2_CI_data_prep.R $weeks_ago
Rscript -e "rmarkdown::render('CI_report_dashboard_planet.Rmd', output_file='$filename', params=list(ref='$ref', report_date='$report_date'))"
\ No newline at end of file
diff --git a/laravel_app/app/Jobs/ProjectDownloadTiffJob.php b/laravel_app/app/Jobs/ProjectDownloadTiffJob.php
index 9a7d9fb..4897c76 100644
--- a/laravel_app/app/Jobs/ProjectDownloadTiffJob.php
+++ b/laravel_app/app/Jobs/ProjectDownloadTiffJob.php
@@ -25,7 +25,7 @@ class ProjectDownloadTiffJob implements ShouldQueue
/**
* Create a new job instance.
*/
- public function __construct(ProjectDownload $download, Carbon $date, )
+ public function __construct(ProjectDownload $download, Carbon $date,)
{
$this->date = $date;
$this->download = $download;
@@ -36,7 +36,7 @@ public function __construct(ProjectDownload $download, Carbon $date, )
*/
public function handle(): void
{
- $projectFolder = base_path('../');
+ $projectFolder = base_path('../');
$command = [
sprintf('%srunpython.sh', $projectFolder),
@@ -51,7 +51,7 @@ public function handle(): void
$process->start();
try {
- $process->wait(function ($type, $buffer) use (&$myOutput){
+ $process->wait(function ($type, $buffer) use (&$myOutput) {
logger($buffer);
});
} catch (ProcessFailedException $exception) {
@@ -62,4 +62,21 @@ public function handle(): void
'status' => 'completed',
]);
}
+
+ public static function handleForDate(Project $project, Carbon $date)
+ {
+ if ($project->downloads()->where(['status' => 'completed', 'date' => $date])->count() > 0) {
+ return;
+ }
+ $filename = sprintf('%s.tif', $date->format('Y-m-d'));
+ $path = sprintf('%s/%s/%s', $project->download_path, 'merged_final_tif', $filename);
+ return new self(
+ $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 49474e8..39daf60 100644
--- a/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php
+++ b/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php
@@ -68,4 +68,16 @@ public function handle(): void
'status' => 'complete',
]);
}
+
+ public static function handleFor(Project $project, $year, $startWeekNumber) {
+ if ($project->mosaics()->where(['status' => 'complete', 'year' => $year, 'week' => $startWeekNumber])->count() > 0) {
+ return;
+ }
+ $mosaic = $project->mosaics()->create([
+ 'year' => $year,
+ 'week' => $startWeekNumber,
+ 'status' => 'pending',
+ ]);
+ return new self($mosaic);
+ }
}
diff --git a/laravel_app/app/Livewire/Projects/DownloadManager.php b/laravel_app/app/Livewire/Projects/DownloadManager.php
index 2129881..f104c25 100644
--- a/laravel_app/app/Livewire/Projects/DownloadManager.php
+++ b/laravel_app/app/Livewire/Projects/DownloadManager.php
@@ -63,7 +63,7 @@ public function saveDownloads()
public function render()
{
- $downloads = $this->project->downloads()->orderBy('name', 'desc')->paginate();
+ $downloads = $this->project->downloads()->orderBy('name', 'desc')->paginate(10, pageName: 'downloadPage');
return view('livewire.projects.download-manager',
compact('downloads')
diff --git a/laravel_app/app/Livewire/Projects/MailingManager.php b/laravel_app/app/Livewire/Projects/MailingManager.php
index 16428f3..d1bac0b 100644
--- a/laravel_app/app/Livewire/Projects/MailingManager.php
+++ b/laravel_app/app/Livewire/Projects/MailingManager.php
@@ -5,9 +5,12 @@
use App\Models\Project;
use App\Models\ProjectMailing;
use Livewire\Component;
+use Livewire\WithPagination;
class MailingManager extends Component
{
+ use WithPagination;
+
public $project;
public $mailingDetailsModal = false;
@@ -22,12 +25,7 @@ public function mount(Project $project)
$this->resetFormData();
}
- public function render()
- {
- return view('livewire.projects.mailing-manager', [
- 'mailings' => $this->project->mailings()->orderBy('created_at', 'desc')->get(),
- ]);
- }
+
public function showMailingDetailsModal(ProjectMailing $mailing)
{
@@ -54,4 +52,10 @@ private function resetFormData()
'recipients' => [],
];
}
+ public function render()
+ {
+ return view('livewire.projects.mailing-manager', [
+ 'mailings' => $this->project->mailings()->orderBy('created_at', 'desc')->paginate(10, pageName: 'mailingPage'),
+ ]);
+ }
}
diff --git a/laravel_app/app/Models/ProjectReport.php b/laravel_app/app/Models/ProjectReport.php
index 1f29a30..1f999fc 100644
--- a/laravel_app/app/Models/ProjectReport.php
+++ b/laravel_app/app/Models/ProjectReport.php
@@ -2,6 +2,9 @@
namespace App\Models;
+use App\Jobs\ProjectDownloadTiffJob;
+use App\Jobs\ProjectMosiacGeneratorJob;
+use Carbon\CarbonPeriod;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
@@ -78,4 +81,39 @@ public function deleteMe()
}
$this->delete();
}
+
+ public static function schedule($year, $week)
+ {
+ Bus::chain([
+ Bus::batch(self::getFileDownloadsFor($year, $week)),
+ Bus::batch(self::getMosiacsFor($year, $week)),
+ Bus::batch(self::getReport($year, $week)),
+ ]);
+ }
+
+ public static function getFileDownloadsFor($project, $year, $startWeekNumber)
+ {
+ $endOfRange = Carbon::now()->setISODate($year, $startWeekNumber)->endOfWeek();
+ $startOfRange = (clone $endOfRange)->subWeeks(2)->startOfWeek();
+
+ $dateRange = CarbonPeriod::create($startOfRange, $endOfRange);
+
+ return collect($dateRange)
+ ->map(fn ($date) => ProjectDownloadTiffJob::handleForDate($project, $date))
+ ->filter();
+ }
+
+ public static function getMosaicsFor($project, $year, $startWeekNumber)
+ {
+ $jobs = [];
+
+ foreach (range(0,2) as $weekDiff) {
+ $job = ProjectMosiacGeneratorJob::handleFor($project, $year, $startWeekNumber - $weekDiff);
+ if ($job) {
+ $jobs[] = $job;
+ }
+ }
+
+ return $jobs;
+ }
}
diff --git a/laravel_app/resources/views/components/icon/exclamation.blade.php b/laravel_app/resources/views/components/icon/exclamation.blade.php
new file mode 100644
index 0000000..96e14f0
--- /dev/null
+++ b/laravel_app/resources/views/components/icon/exclamation.blade.php
@@ -0,0 +1,6 @@
+
diff --git a/laravel_app/resources/views/components/icon/magnifying-glass.blade.php b/laravel_app/resources/views/components/icon/magnifying-glass.blade.php
new file mode 100644
index 0000000..852d5c7
--- /dev/null
+++ b/laravel_app/resources/views/components/icon/magnifying-glass.blade.php
@@ -0,0 +1,3 @@
+
diff --git a/laravel_app/resources/views/components/notification.blade.php b/laravel_app/resources/views/components/notification.blade.php
new file mode 100644
index 0000000..ac4b743
--- /dev/null
+++ b/laravel_app/resources/views/components/notification.blade.php
@@ -0,0 +1,58 @@
+@props(['notificationTimeout' => 5000])
+
{ remove(message) }, {{ $notificationTimeout }})"
+ class="fixed inset-0 flex flex-col items-end justify-center px-4 py-6 pointer-events-none sm:p-6 sm:justify-start space-y-4"
+ style="z-index:1000"
+>
+
+
+
+
diff --git a/laravel_app/resources/views/components/search.blade.php b/laravel_app/resources/views/components/search.blade.php
new file mode 100644
index 0000000..5bc0c7a
--- /dev/null
+++ b/laravel_app/resources/views/components/search.blade.php
@@ -0,0 +1,7 @@
+
diff --git a/laravel_app/resources/views/layouts/app.blade.php b/laravel_app/resources/views/layouts/app.blade.php
index 6d443a7..d3de7f3 100644
--- a/laravel_app/resources/views/layouts/app.blade.php
+++ b/laravel_app/resources/views/layouts/app.blade.php
@@ -36,6 +36,7 @@
{{ $slot }}
+
@stack('modals')
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 05d48af..ce310ed 100644
--- a/laravel_app/resources/views/livewire/projects/download-manager.blade.php
+++ b/laravel_app/resources/views/livewire/projects/download-manager.blade.php
@@ -4,8 +4,8 @@
@endif
>
-
-
+
+
Downloads
@if ($project->hasPendingDownload())
@@ -13,9 +13,10 @@
@endif
-
+
+
+ class="rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
{{ __('Create Download') }}
diff --git a/laravel_app/resources/views/livewire/projects/mailing-manager.blade.php b/laravel_app/resources/views/livewire/projects/mailing-manager.blade.php
index fb98c19..66a02c4 100644
--- a/laravel_app/resources/views/livewire/projects/mailing-manager.blade.php
+++ b/laravel_app/resources/views/livewire/projects/mailing-manager.blade.php
@@ -24,7 +24,7 @@ class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachm
- @foreach($project->mailings as $mail)
+ @foreach($mailings as $mail)
| {{ $mail->id }} |
{{ $mail->subject }} |
@@ -43,6 +43,13 @@ class="text-indigo-600 hover:text-indigo-900">Show
+
+
+ Results: {{ \Illuminate\Support\Number::format($mailings->total()) }}
+
+
+ {{ $mailings->links('livewire.pagination') }}
+
diff --git a/laravel_app/tests/Unit/Models/ProjectReportTest.php b/laravel_app/tests/Unit/Models/ProjectReportTest.php
index 5616434..fb7b7f2 100644
--- a/laravel_app/tests/Unit/Models/ProjectReportTest.php
+++ b/laravel_app/tests/Unit/Models/ProjectReportTest.php
@@ -2,11 +2,13 @@
namespace Tests\Unit\Models;
+use App\Jobs\ProjectDownloadTiffJob;
use App\Models\Project;
use App\Models\ProjectReport;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
+use Illuminate\Support\Collection;
use Mockery;
use Tests\TestCase;
@@ -86,16 +88,37 @@ public function it_can_return_the_reportDate($expected, $mail_day, $week, $year)
public static function reportDateProvider()
{
return [
- 'monday' => ['2023-12-10' , 'monday', 50, 2023],
- 'tuesday' => ['2023-12-11' , 'tuesday', 50, 2023],
- 'wednesday' => ['2023-12-12' , 'wednesday', 50, 2023],
- 'thursday' => ['2023-12-13' , 'thursday', 50, 2023],
- 'friday' => ['2023-12-14' , 'friday', 50, 2023],
- 'saturday' => ['2023-12-15' , 'saturday', 50, 2023],
- 'sunday' => ['2023-12-16' , 'sunday', 50, 2023],
+ 'monday' => ['2023-12-10', 'monday', 50, 2023],
+ 'tuesday' => ['2023-12-11', 'tuesday', 50, 2023],
+ 'wednesday' => ['2023-12-12', 'wednesday', 50, 2023],
+ 'thursday' => ['2023-12-13', 'thursday', 50, 2023],
+ 'friday' => ['2023-12-14', 'friday', 50, 2023],
+ 'saturday' => ['2023-12-15', 'saturday', 50, 2023],
+ 'sunday' => ['2023-12-16', 'sunday', 50, 2023],
];
}
+ /** @test */
+ public function it_can_calculate_mosaic_dependencies()
+ {
+ $project = Project::create([
+ 'name' => 'project_name',
+ 'download_path' => 'project_download_path',
+ ]);
+ $projectReport = $project->reports()->create([
+ 'name' => 'name',
+ 'year' => 2021,
+ 'week' => 25,
+ 'path' => 'path/doc.pdf',
+ ]);
+
+ Bus::fake();
+ $projectReport->schedule();
+
+
+
+
+ }
}
diff --git a/r_app/Rplots.pdf b/r_app/Rplots.pdf
index e65a449..7b37390 100644
Binary files a/r_app/Rplots.pdf and b/r_app/Rplots.pdf differ