Skip to content

Commit

Permalink
Adjust window of events to calendar sync
Browse files Browse the repository at this point in the history
- In order to avoid very large request sets to the calendar provider, the window here is reduced to 3 months in the past until Dec 31 of the next year.
  • Loading branch information
dmtrek14 committed Dec 18, 2023
1 parent 6003351 commit 50a28ac
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions model/facade/action/SyncCalendarAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected function doExecute()

$client->setCalendar($arrayOfCalendars[ConfigurationParametersManager::getParameter('CALENDAR_ID')]);

$lastYear = date("Y") - 1;
$nextYear = date("Y") + 1;
$start = gmdate("Ymd\THis\Z", strtotime($lastYear . "-01-01"));

$start = gmdate("Ymd\THis\Z", date(strtotime("-3 months")));
$end = gmdate("Ymd\THis\Z", strtotime($nextYear . "-12-31"));
$currentEvents = $client->getEvents($start, $end);
foreach ($currentEvents as $event) {
Expand All @@ -69,8 +69,7 @@ protected function doExecute()
}

foreach ($this->datesRanges as $range) {
if (!is_array($range) || !isset($range['start'])) continue;

if (!is_array($range) || !isset($range['start']) || $range['start'] < $start) continue;
$start = str_replace("-", "", $range['start']);
$end = str_replace("-", "", $range['end']);
$userEmail = $this->user->getLogin() . "@" . $companyDomain;
Expand Down

0 comments on commit 50a28ac

Please sign in to comment.