Module: RubyTodo::Statistics

Includes:
StatisticsDisplay
Included in:
CLI
Defined in:
lib/ruby_todo/concerns/statistics.rb

Instance Method Summary collapse

Instance Method Details

#display_global_statsObject



72
73
74
75
76
77
# File 'lib/ruby_todo/concerns/statistics.rb', line 72

def display_global_stats
  total_tasks = Task.count
  return puts "No tasks found in any notebook" if total_tasks.zero?

  display_global_stats_summary
end

#display_notebook_stats(notebook) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ruby_todo/concerns/statistics.rb', line 51

def display_notebook_stats(notebook)
  total_tasks = notebook.tasks.count
  return puts "No tasks found in notebook '#{notebook.name}'" if total_tasks.zero?

  todo_count = notebook.tasks.where(status: "todo").count
  in_progress_count = notebook.tasks.where(status: "in_progress").count
  done_count = notebook.tasks.where(status: "done").count
  archived_count = notebook.tasks.where(status: "archived").count

  puts "\nStatistics for notebook '#{notebook.name}':"
  puts "Total tasks: #{total_tasks}"
  puts "Todo: #{todo_count} (#{percentage(todo_count, total_tasks)}%)"
  puts "In Progress: #{in_progress_count} (#{percentage(in_progress_count, total_tasks)}%)"
  puts "Done: #{done_count} (#{percentage(done_count, total_tasks)}%)"
  puts "Archived: #{archived_count} (#{percentage(archived_count, total_tasks)}%)"

  display_priority_distribution(notebook.tasks)
  display_tag_distribution(notebook.tasks)
  display_overdue_tasks(notebook.tasks)
end

#display_top_notebooksObject



79
80
81
82
83
# File 'lib/ruby_todo/concerns/statistics.rb', line 79

def display_top_notebooks
  puts "\nNotebook Statistics:"
  notebook_stats = collect_notebook_stats
  display_notebook_stats_table(notebook_stats)
end