-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IDP-1183, partial] Add cron-based sync of groups_external
data from Google Sheet
#360
Conversation
Quality Gate passedIssues Measures |
for ($i = 1; $i <= self::MAX_SYNC_SETS; $i++) { | ||
$appPrefixKey = sprintf('set%uAppPrefix', $i); | ||
$googleSheetIdKey = sprintf('set%uGoogleSheetId', $i); | ||
|
||
if (! array_key_exists($appPrefixKey, $syncSetsParams)) { | ||
Yii::warning(sprintf( | ||
'Finished syncing external groups after %s sync set(s).', | ||
($i - 1) | ||
)); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be my preference, just because it's more consistent with typical for loops. Leave the 1-based numbering for user-focused text. (Note: there's one more $i
further down.)
for ($i = 1; $i <= self::MAX_SYNC_SETS; $i++) { | |
$appPrefixKey = sprintf('set%uAppPrefix', $i); | |
$googleSheetIdKey = sprintf('set%uGoogleSheetId', $i); | |
if (! array_key_exists($appPrefixKey, $syncSetsParams)) { | |
Yii::warning(sprintf( | |
'Finished syncing external groups after %s sync set(s).', | |
($i - 1) | |
)); | |
break; | |
} | |
for ($i = 0; $i < self::MAX_SYNC_SETS; $i++) { | |
$appPrefixKey = sprintf('set%uAppPrefix', $i+1); | |
$googleSheetIdKey = sprintf('set%uGoogleSheetId', $i+1); | |
if (! array_key_exists($appPrefixKey, $syncSetsParams)) { | |
Yii::warning(sprintf( | |
'Finished syncing external groups after %s sync set(s).', | |
$i | |
)); | |
break; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but since this is also used for the names of the environment variables, starting with 1 seems more intuitive than starting with 0 in this case. I agree that it's more intuitive/expected that code-only for-loops start with 0, though.
Yii::error(sprintf( | ||
'Errors that occurred while syncing %s external groups: %s', | ||
$appPrefix, | ||
join(" / ", $errors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's theoretically possible to accumulate thousands of errors, would it be good to limit the length of this log message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I hadn't thought of that. Yes, I can limit that error message length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do that in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDP-1183 Sync prefixed-groups from Google Sheet to ID Broker's
groups_external
fieldAdded
groups_external
data from Google SheetFixed
$user->updateExternalGroups()
Feature PR Checklist
make composershow
make psr2