This repository was archived by the owner on Jul 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Feat: Data "reset" button #1913
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| class DataCacheClearJob < ApplicationJob | ||
| queue_as :default | ||
|
|
||
| def perform(family) | ||
| ActiveRecord::Base.transaction do | ||
| ExchangeRate.delete_all | ||
| Security::Price.delete_all | ||
| family.accounts.each do |account| | ||
| account.balances.delete_all | ||
| account.holdings.delete_all | ||
| end | ||
|
|
||
| family.sync_later | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| class FamilyResetJob < ApplicationJob | ||
| queue_as :default | ||
|
|
||
| def perform(family) | ||
| # Delete all family data except users | ||
| ActiveRecord::Base.transaction do | ||
| # Delete accounts and related data | ||
| family.accounts.destroy_all | ||
| family.categories.destroy_all | ||
| family.tags.destroy_all | ||
| family.merchants.destroy_all | ||
| family.plaid_items.destroy_all | ||
| family.imports.destroy_all | ||
| family.budgets.destroy_all | ||
|
|
||
| family.sync_later | ||
| end | ||
| end | ||
| end |
20 changes: 20 additions & 0 deletions
20
app/views/settings/hostings/_danger_zone_settings.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <% if Current.user.admin? %> | ||
| <div class="space-y-4"> | ||
| <div class="flex items-center justify-between"> | ||
| <div class="w-2/3"> | ||
| <h3 class="font-medium text-primary"><%= t("settings.hostings.show.clear_cache") %></h3> | ||
| <p class="text-secondary text-sm"><%= t("settings.hostings.show.clear_cache_warning") %></p> | ||
| </div> | ||
| <%= | ||
| button_to t("settings.hostings.show.clear_cache"), clear_cache_settings_hosting_path, method: :delete, | ||
| class: "bg-orange-500 text-white text-sm font-medium rounded-lg px-4 py-2", | ||
| data: { turbo_confirm: { | ||
| title: t("settings.hostings.show.confirm_clear_cache.title"), | ||
| body: t("settings.hostings.show.confirm_clear_cache.body"), | ||
| accept: t("settings.hostings.show.clear_cache"), | ||
| acceptClass: "w-full bg-orange-500 text-white rounded-xl text-center p-[10px] border mb-2" | ||
| }} | ||
| %> | ||
| </div> | ||
| </div> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 callfamily.sync_laterat the end of this: