Class: Ace::Task::CLI::Commands::Status

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/task/cli/commands/status.rb

Overview

ace-support-cli Command class for ace-task status

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ace/task/cli/commands/status.rb', line 28

def call(**options)
  manager = Ace::Task::Organisms::TaskManager.new
  all_tasks = manager.list(in_folder: "all")

  config = Ace::Task::Molecules::TaskConfigLoader.load
  limits = resolve_limits(config, options)

  score_fn = ->(task) do
    ssc = Ace::Support::Items::Atoms::SortScoreCalculator
    weight = ssc.priority_weight(task.priority)
    age = task.created_at ? [(Time.now - task.created_at) / 86_400.0, 0].max : 0
    ssc.compute(priority_weight: weight, age_days: age, status: task.status)
  end

  smart_sorter = ->(items) do
    Ace::Support::Items::Molecules::SmartSorter.sort(
      items,
      score_fn: score_fn,
      pin_accessor: ->(t) { t.&.dig("position") }
    )
  end

  categorized = Ace::Support::Items::Molecules::StatusCategorizer.categorize(
    all_tasks,
    up_next_limit: limits[:up_next],
    recently_done_limit: limits[:recently_done],
    pending_statuses: %w[pending],
    done_statuses: %w[done],
    up_next_sorter: smart_sorter
  )

  puts Ace::Task::Molecules::TaskDisplayFormatter.format_status(
    categorized, all_tasks: all_tasks
  )
end