Skip to content

Commit

Permalink
reset batch, correlation ids and set to max 19 for batch push
Browse files Browse the repository at this point in the history
  • Loading branch information
frets1700 committed Jan 11, 2024
1 parent 464157a commit 8abf961
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class Calendar implements CalendarInterface
use RequestConfigurationTrait;

// Maximum events allowed for graph batch api
public const BATCH_BY = 20;
public const BATCH_BY = 19;

protected ?LoggerInterface $logger = null;

Expand Down Expand Up @@ -83,7 +83,7 @@ public function __get(string $property): mixed
* Set prefer headers like odata.maxpagesize and timezone to control the data received
* Calls saveEventLocal/deleteEventLocal methods
* @param array<string, mixed> $args
* @throws ReadError
* @throws ReadError|\Throwable
*/
public function pull(CalendarViewParamsInterface $params, ?Closure $deltaLinkStore = null, array $args = []): void
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public function pull(CalendarViewParamsInterface $params, ?Closure $deltaLinkSto
/**
* Get Event by event id (extract extension as well)
* @param array<string, mixed> $args
* @throws ReadError
* @throws ReadError|\Throwable
*/
public function getEventBy(string $id, ?EventItemRequestBuilderGetQueryParameters $params = null, ?Closure $beforeReturn = null, array $args = []): ?ReaderEntityInterface
{
Expand Down Expand Up @@ -178,7 +178,7 @@ public function getEventBy(string $id, ?EventItemRequestBuilderGetQueryParameter

/**
* @param array<string, mixed> $args
* @throws ReadError
* @throws ReadError|\Throwable
*/
public function getEventInstances(string $id, ?InstancesRequestBuilderGetQueryParameters $params = null, array $args = []): void
{
Expand Down Expand Up @@ -229,7 +229,7 @@ public function getEventInstances(string $id, ?InstancesRequestBuilderGetQueryPa
* @param array<string, string> $params
* @param array<string, mixed> $args
* @throws \JsonException
* @throws \Exception
* @throws \Exception|\Throwable
*/
public function push(array $params = [], array $args = []): void
{
Expand All @@ -245,10 +245,11 @@ public function push(array $params = [], array $args = []): void

$eventsToWrite = $this->getLocalEvents();
$chunks = array_chunk($eventsToWrite, static::BATCH_BY);
$batch = [];
$batchCorrelationIds = [];

foreach ($chunks as $chunk) {
$batch = [];
$batchCorrelationIds = [];

/** @var Event $event */
foreach ($chunk as $event) {
if ($event instanceof Event) {
Expand Down Expand Up @@ -285,7 +286,7 @@ public function push(array $params = [], array $args = []): void

/**
* @param array<string, mixed> $args
* @throws \Exception
* @throws \Exception|\Throwable
*/
public function upsert(Event $event, array $args = []): ?GraphEvent
{
Expand All @@ -304,7 +305,7 @@ public function upsert(Event $event, array $args = []): ?GraphEvent

/**
* @param array<string, mixed> $args
* @throws \Exception
* @throws \Exception|\Throwable
*/
public function delete(string $id, array $args = []): void
{
Expand Down

0 comments on commit 8abf961

Please sign in to comment.