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

Feat: Data "reset" button #1913

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Feat: Data "reset" button #1913

merged 3 commits into from
Feb 28, 2025

Conversation

tonyvince
Copy link
Contributor

@tonyvince tonyvince commented Feb 27, 2025

feat: Allow admins to delete family data
feat: Allow self-hosting users to delete cached data

Close #1901

@tonyvince
Copy link
Contributor Author

Screenshot 2025-02-27 at 13 35 47 Screenshot 2025-02-27 at 13 36 05 Screenshot 2025-02-27 at 13 36 20 Screenshot 2025-02-27 at 13 36 30 Screenshot 2025-02-27 at 13 36 43

Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

Nice work here! Just added a few suggestions, but overall this works great.

Family.update_all(last_synced_at: nil)
Family.find_each(&:broadcast_refresh)
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even though we'll be deleting records across families and a self hosted instance will typically just be one family, I still think we should pass in perform(family) here and call family.sync_later at the end of this:

ExchangeRate.delete_all
Security::Price.delete_all

family.accounts.each do |account|
  account.balances.delete_all
  account.holdings.delete_all
end

# We can replace the Family.update_all and Family.find_each(&:broadcast_refresh) with this:
family.sync_later

}}
%>
</div>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a Current.user.admin? guard for this too?


assert_current_path settings_hosting_path
assert_text I18n.t("settings.hostings.clear_cache.cache_cleared")
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we remove these system tests and keep all our testing for this feature in controller/job tests?

We're trying to keep the system test suite as minimal and stable as possible for CI speed and reliability, and I think we're adding in a lot of dependence on the UI structure here, which may change in the future. The most important tests I think we need for this feature is to validate that:

  • Jobs actually delete the intended data
  • Admins can't trigger these jobs ever, regardless of what the UI looks like (the UI guards should be purely visual aids)


# Reset last_synced_at and broadcast refresh
family.update!(last_synced_at: nil)
family.broadcast_refresh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to above, I'd just replace these with a family.sync_later

Copy link
Collaborator

@zachgoll zachgoll left a comment

Choose a reason for hiding this comment

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

Looks great, nice work!

@zachgoll zachgoll merged commit 8208722 into maybe-finance:main Feb 28, 2025
5 checks passed
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.

Feature: Data "reset" button
2 participants