Skip to content

Commit

Permalink
Fix migrations & docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Dec 10, 2024
1 parent 6843ff4 commit 71e938e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
11 changes: 0 additions & 11 deletions lib/Migration/Version1Date20241121160300.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/**
* This migration changes the following:
* - Adding 4 new columns for the table Source: rateLimitLimit, rateLimitRemaining, rateLimitReset & rateLimitWindow
* - Adding 1 new column for the table Synchronization: CurrentPage
*/
class Version1Date20241121160300 extends SimpleMigrationStep {

Expand Down Expand Up @@ -73,16 +72,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);
}

// Synchronizations table
$table = $schema->getTable('openconnector_synchronizations');

if ($table->hasColumn('current_page') === false) {
$table->addColumn('current_page', Types::INTEGER, [
'notnull' => false,
'default' => 1
]);
}

return $schema;
}

Expand Down
16 changes: 15 additions & 1 deletion lib/Migration/Version1Date20241210120155.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

/**
* This migration changes the following:
* - Add 1 new column for the table SynchronizationContractLogs: message
* - Adding 1 new column for the table Synchronization: currentPage
* - Adding 1 new column for the table SynchronizationContractLogs: message
*/
class Version1Date20241210120155 extends SimpleMigrationStep {

Expand All @@ -41,6 +42,19 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
*/
$schema = $schemaClosure();

// Synchronizations table
if ($schema->hasTable('openconnector_synchronizations') === true) {
$table = $schema->getTable('openconnector_synchronizations');

if ($table->hasColumn('current_page') === false) {
$table->addColumn('current_page', Types::INTEGER, [
'notnull' => false,
'default' => 1
]);
}
}

// SynchronizationContractLogs table
if ($schema->hasTable('openconnector_synchronization_contract_logs') === true) {
$table = $schema->getTable('openconnector_synchronization_contract_logs');

Expand Down
18 changes: 17 additions & 1 deletion lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,23 @@ public function getAllObjectsFromApi(Synchronization $synchronization, ?bool $is
return $objects;
}

private function getRateLimitHeaders($source): array
/**
* Retrieves rate limit information from a given source and formats it as HTTP headers.
*
* This function extracts rate limit details from the provided source object and returns them
* as an associative array of headers. The headers can be used for communicating rate limit status
* in API responses or logging purposes.
*
* @param Source $source The source object containing rate limit details, such as limits, remaining requests, and reset times.
*
* @return array An associative array of rate limit headers:
* - 'X-RateLimit-Limit' (int|null): The maximum number of allowed requests.
* - 'X-RateLimit-Remaining' (int|null): The number of requests remaining in the current window.
* - 'X-RateLimit-Reset' (int|null): The Unix timestamp when the rate limit resets.
* - 'X-RateLimit-Used' (int|null): The number of requests used so far.
* - 'X-RateLimit-Window' (int|null): The duration of the rate limit window in seconds.
*/
private function getRateLimitHeaders(Source $source): array
{
return [
'X-RateLimit-Limit' => $source->getRateLimitLimit(),
Expand Down

0 comments on commit 71e938e

Please sign in to comment.