-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Synth error handling #1502
Synth error handling #1502
Conversation
@zachgoll Not sure if I'm using the error stuff correctly. Mind taking a look? |
@Shpigford to get this working, there are a few additional steps: First, we'll need to implement the class Issue::SynthLimitExceeded < Issue
include Providable # Give this class access to our configured Synth Provider
def title
"Synth API Credit Limit Exceeded"
end
# Required so our app knows if the error is still happening after the user has taken some action to fix it
def stale?
self.class.synth_provider.usage.utilization < 1
end
end Then, we need to add a method in # app/models/concerns/issuable.rb
def observe_synth_credits_overage
observe_issue(Issue::SynthLimitExceeded.new)
end And finally, we need to call class Account
include Providable
def sync_data(start_date: nil)
update!(last_synced_at: Time.current)
resolve_stale_issues
# Observe issue if credits are over limit
if self.class.synth_provider.usage.utilization >= 1
observe_synth_credits_overage
end
Balance::Syncer.new(self, start_date: start_date).run
Holding::Syncer.new(self, start_date: start_date).run
end
end Simpler solution I think given this use case, there are probably some simplifications that could be made to the "issues" flow and the In the meantime, a simpler solution would be to add a convenience method on class Family
include Providable
def synth_overage?
self.class.synth_provider && self.class.synth_provider.usage.utilization >= 1
end
end <% if Current.family.synth_overage? %>
<div>Some alert to user!!!</div>
<% end %> |
@zachgoll I definitely prefer the simple approach. 🙂 Will get that swapped out and have you review in a bit. |
@Shpigford yeah I agree. Longer term, I think we will basically have 1 single |
This reverts commit fd6a0a1.
@zachgoll Mind taking a look at this version? |
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.
Yep, looks good
No description provided.