-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor event sync to pass account into constructors #459
base: master
Are you sure you want to change the base?
Conversation
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.
Looks nice and clean! 👌
@@ -102,13 +95,9 @@ def _get_access_token( | |||
Returns: | |||
The token | |||
""" | |||
with session_scope(self.namespace_id) as db_session: | |||
acc = db_session.query(Account).get(self.account_id) |
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.
Is there any possible reason why reloading the account information here might've been important? Or is the freshest possible state of the account a) irrelevant, or b) already ensured through different logic somehow?
BaseSyncMonitor.__init__( | ||
self, | ||
account_id, | ||
namespace_id, | ||
email_address, | ||
account.id, | ||
account.namespace.id, | ||
account.email_address, | ||
EVENT_SYNC_FOLDER_ID, | ||
EVENT_SYNC_FOLDER_NAME, | ||
provider_name, | ||
account.verbose_provider, | ||
poll_frequency=poll_frequency, | ||
scope="calendar", | ||
) |
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 is a side note and not something that needs to happen in this PR, but I feel like this number of arguments could warrant using *
to force all of them to be passed as kwargs. That way at least it's a bit clearer what the role/expectation is for each variable. For example, I think provider_name=account.verbose_provider
is clearer than just passing account.verbose_provider
into this constructor.
if self.provider.webhook_notifications_enabled(): | ||
# Run the sync loop more frequently if push notifications are | ||
# enabled. Note that we'll only update the calendar if a | ||
# Webhook was receicved recently, or if we haven't synced for |
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.
Typo: received
namespace_id, | ||
provider_class=GoogleEventsProvider, | ||
) | ||
event_sync = EventSync(generic_account, provider_class=GoogleEventsProvider,) |
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.
Nit: Probably don't need that trailing comma.
This is a follow-up on #458,
This refactors Google and Microsoft event sync to accept
Account
objects in constructor and not in methods, as each ofEventSync/WebhookEventSync
greenlet andEventsProvider
work always on a single account.