added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
class TrackingDestroyer
attr_reader :user, :tracking, :date
def initialize(user, tracking, date)
@user = user
@tracking = tracking
@date = date
end
def destroy
# If a tracking for the same trackable started at the same date is found,
# then it can be destroyed because we're in the case of an unwanted action
same_tracking = user.trackings.find_by(
trackable_id: tracking.trackable_id,
trackable_type: tracking.trackable_type,
start_at: date
)
if same_tracking.present?
tracking.destroy
else
tracking.update!(end_at: Time.zone.today)
end
end
end