Fix for scheduled reports

This commit is contained in:
Hillel Coren 2018-03-21 17:55:10 +02:00
parent d268b29a61
commit f01cf35a92
2 changed files with 5 additions and 9 deletions

View File

@ -172,6 +172,9 @@ class SendReminders extends Command
$config = (array) json_decode($scheduledReport->config); $config = (array) json_decode($scheduledReport->config);
$reportType = $config['report_type']; $reportType = $config['report_type'];
// send email as user
auth()->onceUsingId($user->id);
$report = dispatch(new RunReport($scheduledReport->user, $reportType, $config, true)); $report = dispatch(new RunReport($scheduledReport->user, $reportType, $config, true));
$file = dispatch(new ExportReportResults($scheduledReport->user, $config['export_format'], $reportType, $report->exportParams)); $file = dispatch(new ExportReportResults($scheduledReport->user, $config['export_format'], $reportType, $report->exportParams));
@ -180,6 +183,8 @@ class SendReminders extends Command
} }
$scheduledReport->updateSendDate(); $scheduledReport->updateSendDate();
auth()->logout();
} }
} }

View File

@ -61,11 +61,6 @@ class RunReport extends Job
$endDate = $config['end_date']; $endDate = $config['end_date'];
} }
// send email as user
if (App::runningInConsole() && $this->user) {
auth()->onceUsingId($this->user->id);
}
$report = new $reportClass($startDate, $endDate, $isExport, $config); $report = new $reportClass($startDate, $endDate, $isExport, $config);
$report->run(); $report->run();
@ -77,10 +72,6 @@ class RunReport extends Job
$report->exportParams = array_merge($params, $report->results()); $report->exportParams = array_merge($params, $report->results());
if (App::runningInConsole() && $this->user) {
auth()->logout();
}
return $report; return $report;
} }
} }