fix: [user:periodic_notification] Show the correct start date of the report

pull/8590/head
Sami Mokaddem 2022-09-15 09:27:53 +02:00
parent 19cc836070
commit 9f0b72576c
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 4 additions and 3 deletions

View File

@ -1800,7 +1800,7 @@ class User extends AppModel
$aggregated_context = $this->__renderAggregatedContext($finalContext);
$rollingWindows = 2;
$trendAnalysis = $this->Event->getTrendsForTagsFromEvents($events, $this->__periodToDays($period), $rollingWindows, $periodicSettings['trending_for_tags']);
$trendAnalysis = $this->Event->getTrendsForTagsFromEvents($events, $this->periodToDays($period), $rollingWindows, $periodicSettings['trending_for_tags']);
$tagFilterPrefixes = $periodicSettings['trending_for_tags'] ?: array_keys($trendAnalysis['all_tags']);
$trendData = [
'trendAnalysis' => $trendAnalysis,
@ -1812,6 +1812,7 @@ class User extends AppModel
$emailTemplate->set('events', $events);
$emailTemplate->set('filters', $filters);
$emailTemplate->set('periodicSettings', $periodicSettings);
$emailTemplate->set('period_days', $this->periodToDays($period));
$emailTemplate->set('period', $period);
$emailTemplate->set('aggregated_context', $aggregated_context);
$emailTemplate->set('trending_summary', $trending_summary);
@ -1883,7 +1884,7 @@ class User extends AppModel
return $timerange;
}
private function __periodToDays(string $period='daily'): int
public function periodToDays(string $period='daily'): int
{
return ($period == 'daily' ? 1 : (
$period == 'weekly' ? 7 : 31)

View File

@ -29,7 +29,7 @@ $default_vars = [
$vars = array_merge($default_vars, $this->__vars);
$now = new DateTime();
$start_date = new DateTime('7 days ago');
$start_date = new DateTime($period_days . ' days ago');
$event_number = count($events);
$attribute_number = 0;
$object_number = 0;