Refactor segment Service
mkcode opened this issue · comments
We need to change this to an after_transition
so it's only called when the transition is successful: https://github.com/raise-dev/hacktoberfest/blob/master/app/models/user.rb#L46
Then this method should moved and called from a new service that is written in a before_transition
so it updates always, in the case the transition was not successful and only in the appropriate states. This should be done a new service called UserPullRequestSegmentUpdator
. https://github.com/raise-dev/hacktoberfest/blob/master/app/services/user_state_transition_segment_service.rb#L31-L33
In short, we need to send segment updated PR counts every time a transition is attempted (before_transition) and the tracking events, only when a successful transition is made (after_transition)
I was actually just thinking about this when looking at the model, agreed and will get on it