-
Notifications
You must be signed in to change notification settings - Fork 7
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
Checksum ordered by update #102
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.
In the perform
method in the entities loop we should have something like:
next unless id_column_exists_for_entity?(entity)
Then we should save the order_column
within the loop and pass this to build_event_for
, so that we can save the order_column
in the entity_check event.
@@ -61,38 +61,51 @@ def fetch_current_timestamp_in_time_zone | |||
end | |||
|
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 think we should make a method for checking existence of id
column and call this from the perform method loop.
def id_column_exists_for_entity?(entity)
return true if ActiveRecord::Base.connection.column_exists?(entity, :id)
Rails.logger.info("DfE::Analytics: Entity checksum: ID column missing in #{entity} - Skipping checks")
false
end
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.
Good plan, updates made. Ready for another review - so much complexity in this job now!
4990c5c
to
b6eb3c0
Compare
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 goods.
I know it's a pain, but at some point we should have tests for tables without updated_at
, without created_at
also and without timestamps and id
. OK for now though to get this moving.
@asatwal Yeah that would be sensible. I'll work on that whilst it is still fresh (today) but maybe get this one deployed so that we can test it on Apply if that sounds reasonable? |
Not all entity tables have updated_at columns.
It is necessary to have fallback columns to order by. This PR allows the checksum lookup to be ordered by updated_at then created_at and finally the ID if the other two don't exist.