Class: PlanMyStuff::RemindersSweepJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/plan_my_stuff/reminders_sweep_job.rb

Overview

Daily-cadence sweep job for reminder dispatch + inactivity auto-close. Consuming apps enqueue it once; the job self-requeues after each perform so the schedule persists without requiring a cron/whenever setup. Queue-adapter-agnostic: runs through ActiveJob’s set(wait_until:).perform_later so any backend works.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_runTime

Next sweep time. Default: 6:30am Eastern tomorrow (today if the current time is before 6:30am ET). Apps wanting a different cadence override this on a subclass.

Returns:

  • (Time)

    UTC



29
30
31
32
33
34
# File 'app/jobs/plan_my_stuff/reminders_sweep_job.rb', line 29

def next_run
  now = Time.current.in_time_zone('Eastern Time (US & Canada)')
  target = now.change(hour: 6, min: 30, sec: 0)
  target += 1.day if target <= now
  target.utc
end

.requeue(repo) ⇒ ActiveJob::Base

Schedules a sweep for next_run. Used by the after-perform self-requeue and the plan_my_stuff:reminders:sweep rake task so both kick off runs on the same cadence (instead of “now”).

Parameters:

  • repo (Symbol, String)

Returns:

  • (ActiveJob::Base)


44
45
46
# File 'app/jobs/plan_my_stuff/reminders_sweep_job.rb', line 44

def requeue(repo)
  set(wait_until: next_run).perform_later(repo)
end

Instance Method Details

#perform(repo) ⇒ void

This method returns an undefined value.

Parameters:

  • repo (Symbol, String)


53
54
55
56
57
# File 'app/jobs/plan_my_stuff/reminders_sweep_job.rb', line 53

def perform(repo)
  @repo_arg = repo
  PlanMyStuff::Reminders::Sweep.new(repo: repo).call
  PlanMyStuff::Archive::Sweep.new(repo: repo).call
end