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

Track updates to relationships #376

Merged
merged 9 commits into from
Feb 19, 2024

Conversation

Track updates to relationships in all related tables by adding a new field `relationship_updated_at` to all principal tables (see below) that is updated with the current date anytime a change happens to a relationship (create/update/delete)

Specifically the principal tables are (with join tables nested)

- [x] measures
  - [x] measure_categories
  - [x] measure_indicators
- [x] indicators
  - [x] measure_indicators
- [x] users
  - [x] user_roles
  - [x] user_categories
@parndt parndt requested a review from tmfrnz January 30, 2024 09:17
Copy link
Member

@tmfrnz tmfrnz left a comment

Choose a reason for hiding this comment

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

only thing missing was adding those fields to the serializer

@@ -12,6 +12,10 @@ class Measure < VersionedRecord
has_many :due_dates, through: :indicators
has_many :progress_reports, through: :indicators

belongs_to :parent, class_name: "Measure", required: false
Copy link
Member

Choose a reason for hiding this comment

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

I don't think measures have parent measures here

add_column :indicators, :relationship_updated_at, :datetime, precision: 6, null: true
add_column :measures, :relationship_updated_at, :datetime, precision: 6, null: true
add_column :users, :relationship_updated_at, :datetime, precision: 6, null: true
end
Copy link
Member

Choose a reason for hiding this comment

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

we also want to track relationship updates to the recommendations table

Copy link
Member

Choose a reason for hiding this comment

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

specifically recommendation_categories, recommendation_indicators, recommendation_measures and recommendation_recommendations

Copy link
Member

Choose a reason for hiding this comment

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

no need to track changes to sdgtargets btw - in fact as we no longer use they could/should also be dropped

Copy link
Member

Choose a reason for hiding this comment

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

finally, we should also consider tracking category relationship updates, including

  • to its parent category (parent_id) and also the inverse (the parent if assigned a child)
  • to its manager (manager_id) and also the inverse (the user if assigned a category)

but let's leave this for later

@tmfrnz tmfrnz merged commit 19d5be9 into nz-justice-development Feb 19, 2024
2 checks passed
@tmfrnz tmfrnz deleted the 362-track-updates-to-relationships branch February 19, 2024 07:12
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