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

Checksum ordered by update #102

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Checksum ordered by update #102

merged 3 commits into from
Dec 19, 2023

Conversation

ericaporter
Copy link
Contributor

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.

@ericaporter ericaporter requested a review from asatwal December 18, 2023 09:22
Copy link
Collaborator

@asatwal asatwal left a 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

Copy link
Collaborator

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

Copy link
Contributor Author

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!

@ericaporter ericaporter force-pushed the checksum-ordered-by-update branch from 4990c5c to b6eb3c0 Compare December 18, 2023 21:07
Copy link
Collaborator

@asatwal asatwal left a 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.

@ericaporter
Copy link
Contributor Author

ericaporter commented Dec 19, 2023

👍 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?

@ericaporter ericaporter merged commit 91d0bd0 into main Dec 19, 2023
7 checks passed
@ericaporter ericaporter deleted the checksum-ordered-by-update branch December 19, 2023 11:15
This was referenced Dec 19, 2023
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