Changed GetFileDownloadsFor and all the functions called inside
This commit is contained in:
parent
3b98d0e364
commit
5153228758
|
|
@ -319,7 +319,7 @@ public function scheduleReport($year = null, $week = null)
|
|||
|
||||
$year = $year ?? now()->year;
|
||||
$week = $week ?? now()->weekOfYear;
|
||||
|
||||
// TODO change to period
|
||||
Bus::chain([
|
||||
Bus::batch($this->getFileDownloadsFor($year, $week)),
|
||||
Bus::batch($this->getMosaicsFor($year, $week)),
|
||||
|
|
@ -341,12 +341,10 @@ public function getReportFor($year, $week, $sendMail = false)
|
|||
return (new ProjectReportGeneratorJob($report, $sendMail));
|
||||
}
|
||||
|
||||
public function getFileDownloadsFor($year, $startWeekNumber):array
|
||||
public function getFileDownloadsFor(Carbon $endDate, $offset):array
|
||||
{
|
||||
$endOfRange = now()->setISODate($year, $startWeekNumber)->endOfWeek();
|
||||
$startOfRange = (clone $endOfRange)->subWeeks(3)->startOfWeek();
|
||||
|
||||
$dateRange = CarbonPeriod::create($startOfRange, $endOfRange);
|
||||
$startOfRange = (clone $endDate)->subdays(4*$offset-1);
|
||||
$dateRange = CarbonPeriod::create($startOfRange, $endDate);
|
||||
|
||||
return collect($dateRange)
|
||||
->map(fn($date) => ProjectDownloadTiffJob::handleForDate($this, $date))
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ public function when_getFileDownloadsFor_is_called_it_returns_a_collection_of_se
|
|||
'download_path' => 'project_download_path',
|
||||
]);
|
||||
|
||||
$downloads = $project->getFileDownloadsFor(2023, 22);
|
||||
$this->assertCount(4 * 7, $downloads);
|
||||
$downloads = $project->getFileDownloadsFor(new Carbon('2024-06-18'),20);
|
||||
$this->assertCount(60, $downloads);
|
||||
collect($downloads)->each(fn($job) => $this->assertInstanceOf(ProjectDownloadTiffJob::class, $job));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue