Skip to content
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

Update all fields on AdvisorData upsert #155

Merged
merged 4 commits into from
Oct 2, 2024
Merged

Conversation

patricksanders
Copy link
Collaborator

In some cases, the IAM Last Accessed Info data may reflect a new LastAuthenticated timestamp before being updated with LastAuthenticatedEntity and TotalAuthenticatedEntities. If Aardvark's updater runs between those two events, subsequent updater runs will not update the database record with LastAuthenticatedEntity and TotalAuthenticatedEntities. This happens because AdvisorData.create_or_update() only updates the database record when the new LastAuthenticated is greater than the existing record (or zero, sometimes). And even when the timestamp increases, only the timestamp ends up getting updated in the database.

This PR updates the implementation so that all fields are updated in the model. SQLAlchemy will ignore any records whose values have not been modified, meaning that we shouldn't see a meaningful increase on database load with this change.

I also added some tests to validate these changes, which was the most difficult part of the whole ordeal. I was able to do so without too much noise, with the exception of needing to add support for config overrides in the create_app() function.

@patricksanders patricksanders marked this pull request as ready for review September 26, 2024 21:40
@nf-joseph nf-joseph self-requested a review October 2, 2024 22:19
Copy link

@nf-joseph nf-joseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @patricksanders !

@patricksanders patricksanders merged commit db8746b into main Oct 2, 2024
2 checks passed
@patricksanders patricksanders deleted the fix/upsert-bug branch October 2, 2024 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants