8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/postqueue/cli/stats.rb', line 8
def stats(_options)
require "table_print"
sql = " SELECT op,\n COUNT(*) AS count,\n failed_attempts,\n CASE\n WHEN failed_attempts >= 5 THEN 'FAILED'\n WHEN failed_attempts > 0 THEN 'RETRY'\n WHEN next_run_at < now() THEN 'READY'\n ELSE 'WAIT'\n END AS status,\n MIN(now() - created_at) AS min_age,\n MAX(now() - created_at) AS max_age,\n AVG(now() - created_at) AS avg_age\n FROM \#{Postqueue.item_class.table_name}\n GROUP BY op, failed_attempts, status\n SQL\n\n recs = Postqueue.item_class.find_by_sql(sql)\n tp recs, :status, :op, :failed_attempts, :count, :avg_age, :min_age, :max_age\nend\n"
|