Class: PlanMyStuff::Archive::Sweep

Inherits:
Object
  • Object
show all
Defined in:
lib/plan_my_stuff/archive/sweep.rb

Overview

Walks a single repo’s closed issues, archiving those that have aged past config.archive_closed_after_days. Excludes issues auto-closed by Reminders::Closer (metadata.closed_by_inactivity) and any that are already archived (marker timestamp or label).

Paginates Issue.list(state: :closed) until either an empty page or the hard MAX_PAGES cap. GitHub’s list_issues returns in created-desc order, so closed_at is not monotonic across pages; we can’t short-circuit on “this page is all within cutoff.” Each subsequent sweep skips already-archived issues cheaply via skip?, so the steady-state walk is bounded in practice.

Constant Summary collapse

PAGE_SIZE =
50
MAX_PAGES =
20

Instance Method Summary collapse

Constructor Details

#initialize(repo:, now: Time.now.utc) ⇒ Sweep

Returns a new instance of Sweep.

Parameters:

  • repo (Symbol, String)

    repo key or full name

  • now (Time) (defaults to: Time.now.utc)

    clock reference



23
24
25
26
# File 'lib/plan_my_stuff/archive/sweep.rb', line 23

def initialize(repo:, now: Time.now.utc)
  @repo = repo
  @now = now.utc
end

Instance Method Details

#callvoid

This method returns an undefined value.

Runs the sweep. No-op when config.archiving_enabled is false.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/plan_my_stuff/archive/sweep.rb', line 32

def call
  return unless PlanMyStuff.configuration.archiving_enabled

  (1..MAX_PAGES).each do |page|
    issues = PlanMyStuff::Issue.list(
      repo: @repo,
      state: :closed,
      page: page,
      per_page: PAGE_SIZE,
    )

    break if issues.empty?

    process(issues)
  end
end