resque-job_history 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 478ee17e82e8a2fcd742c17c56bda6b5586065d9
4
- data.tar.gz: 259443101165e95cd9bf685159ae03ce8c266311
3
+ metadata.gz: 70bba4f7ca792423394d8f8a694329a721238bbe
4
+ data.tar.gz: 3c3532c52a3e99789ee259d057b42533185040c9
5
5
  SHA512:
6
- metadata.gz: b546a34fa89692e2794f15d2801fa89faad6771a7015d4c778565b1c0241c52a2f5e928aee9a8fc2d6d856c07854d94a334b5355522efd27ec624841c9a932ab
7
- data.tar.gz: 883a626bd6d5b813378164c4e8ab2ec397993218e07545cdd88245d5fc7e485af7e2e7696371eb18986cd16c14219a44497e2388c9146e336254fa4a758ed43f
6
+ metadata.gz: c86f488cc5e8485d45648b8f285fef4ed3ebee4b2e4846b9cb6920feab48fe2cb28f9def1a7f3e6154f51976d2089f2c9ad05c87a8f526eb1c545a5500761864
7
+ data.tar.gz: b52328b3f04d64f71101ed6903d0828dd470226512f15e6cb6ed50072b2a7fe62deff11b19d6bfba6a47e155965134b049a13a6aa91bea24c51737e5fb3a84ab
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require "bundler/setup"
3
5
  rescue LoadError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "resque"
2
4
  require "resque/server"
3
5
  require "resque-job_history"
@@ -50,7 +52,7 @@ module Resque
50
52
  @sort_by = params[:sort] || "class_name"
51
53
  @sort_order = params[:order] || "asc"
52
54
  @page_num = (params[:page_num] || 1).to_i
53
- @page_size = (params[:page_size] || Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE).to_i
55
+ @page_size = (params[:page_size] || Resque::Plugins::JobHistory::PAGE_SIZE).to_i
54
56
  end
55
57
  end
56
58
  end
@@ -83,8 +85,7 @@ module Resque
83
85
  base.class_eval do
84
86
  def set_running_page_params
85
87
  @running_page_num = (params[:running_page_num] || 1).to_i
86
- @running_page_size = (params[:running_page_size] ||
87
- Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE).to_i
88
+ @running_page_size = params[:running_page_size]
88
89
  end
89
90
  end
90
91
  end
@@ -93,8 +94,7 @@ module Resque
93
94
  base.class_eval do
94
95
  def set_finished_page_params
95
96
  @finished_page_num = (params[:finished_page_num] || 1).to_i
96
- @finished_page_size = (params[:finished_page_size] ||
97
- Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE).to_i
97
+ @finished_page_size = params[:finished_page_size]
98
98
  end
99
99
  end
100
100
  end
@@ -182,8 +182,6 @@ module Resque
182
182
  end
183
183
  end
184
184
 
185
- Resque.extend Resque::JobHistoryServer
186
-
187
185
  Resque::Server.class_eval do
188
186
  include Resque::JobHistoryServer
189
187
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module JobHistory
@@ -6,7 +8,7 @@ module Resque
6
8
  class << self
7
9
  def clean_all_old_running_jobs
8
10
  job_classes.each do |class_name|
9
- Resque::Plugins::JobHistory::Job.new(class_name, "").clean_old_running_jobs
11
+ Resque::Plugins::JobHistory::HistoryDetails.new(class_name).clean_old_running_jobs
10
12
  end
11
13
  end
12
14
 
@@ -22,6 +24,7 @@ module Resque
22
24
  keys -= Resque::Plugins::JobHistory::HistoryList.new(class_name, "finished").job_ids
23
25
 
24
26
  keys.each do |stranded_key|
27
+ Resque::Plugins::JobHistory::Job.new(class_name, stranded_key).purge
25
28
  del_key(stranded_key, "Stranded job key deleted")
26
29
  end
27
30
  end
@@ -31,54 +34,64 @@ module Resque
31
34
  purge_class class_name
32
35
  end
33
36
 
34
- del_key(Resque::Plugins::JobHistory::HistoryBase.new("").job_history_key,
35
- "Purging job_history_key")
37
+ del_key(Resque::Plugins::JobHistory::HistoryDetails.job_history_key, "Purging job_history_key")
38
+
39
+ redis.keys("*").each do |key|
40
+ del_key(key, "Purging unknown key")
41
+ end
36
42
  end
37
43
 
38
44
  def purge_invalid_jobs
39
- viewer_klass.job_classes.each do |class_name|
40
- next if Resque::Plugins::JobHistory::HistoryBase.new(class_name).class_name_valid?
45
+ job_classes.each do |class_name|
46
+ next if Resque::Plugins::JobHistory::HistoryDetails.new(class_name).class_name_valid?
41
47
 
42
48
  purge_class(class_name)
43
49
  end
44
50
  end
45
51
 
46
52
  def purge_class(class_name)
47
- job_keys(class_name).each do |job_key|
53
+ return if similar_name?(class_name)
54
+
55
+ class_keys(class_name).each do |job_key|
48
56
  del_key(job_key, "Purging job key")
49
57
  end
58
+ end
50
59
 
51
- job_support_keys(class_name).each do |support_key|
52
- del_key(support_key, "Purging #{support_key}")
60
+ def similar_name?(class_name)
61
+ job_classes.any? do |job_name|
62
+ job_name != class_name && job_name[0..class_name.length - 1] == class_name
53
63
  end
54
64
  end
55
65
 
56
66
  private
57
67
 
58
68
  def job_classes
59
- Resque::Plugins::JobHistory::JobList.new.job_classes
69
+ Resque::Plugins::JobHistory::JobList.new.job_classes.sort.reverse
70
+ end
71
+
72
+ def class_keys(class_name)
73
+ history_base = Resque::Plugins::JobHistory::HistoryDetails.new(class_name)
74
+
75
+ history_base.redis.keys("#{history_base.job_history_base_key}*")
60
76
  end
61
77
 
62
78
  def job_keys(class_name)
63
- history_base = Resque::Plugins::JobHistory::HistoryBase.new(class_name)
79
+ history_base = Resque::Plugins::JobHistory::HistoryDetails.new(class_name)
64
80
 
65
81
  history_base.redis.keys("#{history_base.job_history_base_key}.*") - job_support_keys(history_base)
66
82
  end
67
83
 
68
84
  def job_support_keys(history_base)
69
- if history_base.is_a?(String)
70
- history_base = Resque::Plugins::JobHistory::HistoryBase.new(history_base)
71
- end
72
-
73
85
  ["#{history_base.job_history_base_key}.running_jobs",
74
86
  "#{history_base.job_history_base_key}.total_running_jobs",
75
87
  "#{history_base.job_history_base_key}.finished_jobs",
76
88
  "#{history_base.job_history_base_key}.total_finished_jobs",
77
- "#{history_base.job_history_base_key}.max_jobs"]
89
+ "#{history_base.job_history_base_key}.max_jobs",
90
+ "#{history_base.job_history_base_key}.total_failed"]
78
91
  end
79
92
 
80
93
  def redis
81
- @redis ||= Resque::Plugins::JobHistory::HistoryBase.new("").redis
94
+ @redis ||= Resque::Plugins::JobHistory::HistoryDetails.new("").redis
82
95
  end
83
96
 
84
97
  def del_key(key, message)
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Resque
4
+ module Plugins
5
+ module JobHistory
6
+ # A base class for job history classes which provides a base key and a few common functions.
7
+ class HistoryDetails
8
+ attr_accessor :class_name
9
+
10
+ NAME_SPACE = "Resque::Plugins::ResqueJobHistory"
11
+
12
+ class << self
13
+ def job_history_key
14
+ "job_history"
15
+ end
16
+ end
17
+
18
+ def initialize(class_name)
19
+ @class_name = class_name
20
+ end
21
+
22
+ def redis
23
+ @redis ||= Redis::Namespace.new(NAME_SPACE, redis: Resque.redis)
24
+ end
25
+
26
+ def job_history_base_key
27
+ "#{Resque::Plugins::JobHistory::HistoryDetails.job_history_key}.#{class_name}"
28
+ end
29
+
30
+ def running_jobs
31
+ @running_list ||= HistoryList.new(class_name, "running")
32
+ end
33
+
34
+ def finished_jobs
35
+ @finished_list ||= HistoryList.new(class_name, "finished")
36
+ end
37
+
38
+ def max_concurrent_jobs
39
+ redis.get(max_running_key).to_i
40
+ end
41
+
42
+ def total_failed_jobs
43
+ redis.get(total_failed_key).to_i
44
+ end
45
+
46
+ def class_name_valid?
47
+ described_class.present?
48
+ end
49
+
50
+ def clean_old_running_jobs
51
+ too_old_time = class_purge_age.ago
52
+
53
+ running_jobs.jobs.each do |job|
54
+ job_start = job.start_time
55
+
56
+ if job_start.blank? || job_start.to_time < too_old_time
57
+ job.start(*job.args) if job_start.blank?
58
+ job.cancel
59
+ end
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def described_class
66
+ class_name.constantize
67
+ rescue StandardError
68
+ nil
69
+ end
70
+
71
+ def class_purge_age
72
+ described_class.try(:purge_age) || 24.hours
73
+ end
74
+
75
+ def class_history_len
76
+ described_class.try(:job_history_len) || MAX_JOB_HISTORY
77
+ end
78
+
79
+ def class_page_size
80
+ described_class.try(:page_size) || Resque::Plugins::JobHistory::PAGE_SIZE
81
+ end
82
+
83
+ def total_failed_key
84
+ "#{job_history_base_key}.total_failed"
85
+ end
86
+
87
+ def max_running_key
88
+ "#{job_history_base_key}.max_jobs"
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module JobHistory
4
6
  # JobHistory cleanup functions to allow the user to cleanup Redis for histories.
5
- class HistoryList < HistoryBase
7
+ class HistoryList < HistoryDetails
6
8
  attr_accessor :list_name
7
9
 
8
10
  def initialize(class_name, list_name)
@@ -18,8 +20,6 @@ module Resque
18
20
  redis.incr(total_jobs_key)
19
21
 
20
22
  delete_old_jobs(job_count)
21
-
22
- job_count
23
23
  end
24
24
 
25
25
  def remove_job(job_id)
@@ -28,9 +28,10 @@ module Resque
28
28
 
29
29
  def paged_jobs(page_num = 1, page_size = nil)
30
30
  page_size ||= class_page_size
31
- page_size = Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE if page_size.to_i < 1
31
+ page_size = page_size.to_i
32
+ page_size = Resque::Plugins::JobHistory::PAGE_SIZE if page_size < 1
32
33
  start = (page_num - 1) * page_size
33
- start = 0 if start >= num_jobs
34
+ start = 0 if start >= num_jobs || start.negative?
34
35
 
35
36
  jobs(start, start + page_size - 1)
36
37
  end
@@ -62,7 +63,7 @@ module Resque
62
63
  private
63
64
 
64
65
  def add_to_history
65
- redis.sadd(job_history_key, class_name)
66
+ redis.sadd(Resque::Plugins::JobHistory::HistoryDetails.job_history_key, class_name)
66
67
  end
67
68
 
68
69
  def delete_old_jobs(job_count)
@@ -73,6 +74,8 @@ module Resque
73
74
 
74
75
  job_count -= 1
75
76
  end
77
+
78
+ job_count
76
79
  end
77
80
 
78
81
  def total_jobs_key
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module JobHistory
4
6
  # a class encompassing a single job.
5
- class Job < HistoryBase
7
+ class Job < HistoryDetails
6
8
  attr_accessor :job_id
7
9
 
8
10
  def initialize(class_name, job_id)
9
11
  super(class_name)
10
12
 
11
- @job_id = job_id
13
+ @stored_values = nil
14
+ @job_id = job_id
12
15
  end
13
16
 
14
17
  def job_key
@@ -24,7 +27,7 @@ module Resque
24
27
  end
25
28
 
26
29
  def succeeded?
27
- error.blank?
30
+ finished? && error.blank?
28
31
  end
29
32
 
30
33
  def duration
@@ -44,21 +47,24 @@ module Resque
44
47
  end
45
48
 
46
49
  def start(*args)
47
- num_jobs = running_list.add_job(job_id)
50
+ num_jobs = running_jobs.add_job(job_id)
48
51
 
49
- record_num_jobs(num_jobs)
50
52
  record_job_start(*args)
53
+ record_num_jobs(num_jobs)
51
54
  end
52
55
 
53
56
  def finish
54
57
  redis.hset(job_key, "end_time", Time.now.utc.to_s)
55
58
 
56
- finished_list.add_job(job_id)
57
- running_list.remove_job(job_id)
59
+ finished_jobs.add_job(job_id)
60
+ running_jobs.remove_job(job_id)
61
+
62
+ reset
58
63
  end
59
64
 
60
65
  def failed(exception)
61
66
  redis.hset(job_key, "error", exception.message)
67
+ redis.incr(total_failed_key)
62
68
 
63
69
  finish
64
70
  end
@@ -68,6 +74,7 @@ module Resque
68
74
  "error",
69
75
  "Unknown - Job failed to signal ending after the configured purge time or "\
70
76
  "was canceled manually.")
77
+ redis.incr(total_failed_key)
71
78
 
72
79
  finish
73
80
  end
@@ -79,14 +86,15 @@ module Resque
79
86
  end
80
87
 
81
88
  def purge
82
- running_list.remove_job(job_id)
83
- finished_list.remove_job(job_id)
89
+ # To keep the counts honest...
90
+ cancel unless finished?
91
+
92
+ running_jobs.remove_job(job_id)
93
+ finished_jobs.remove_job(job_id)
84
94
 
85
95
  redis.del(job_key)
86
- end
87
96
 
88
- def max_jobs
89
- redis.get(max_running_key).to_i
97
+ reset
90
98
  end
91
99
 
92
100
  private
@@ -94,6 +102,8 @@ module Resque
94
102
  def record_job_start(*args)
95
103
  redis.hset(job_key, "start_time", Time.now.utc.to_s)
96
104
  redis.hset(job_key, "args", encode_args(*args))
105
+
106
+ reset
97
107
  end
98
108
 
99
109
  def stored_values
@@ -117,26 +127,13 @@ module Resque
117
127
  redis.set(max_running_key, num_jobs)
118
128
  end
119
129
 
120
- return unless num_jobs > class_history_len
130
+ return unless num_jobs >= class_history_len
121
131
 
122
132
  clean_old_running_jobs
123
133
  end
124
134
 
125
- def max_running_key
126
- "#{job_history_base_key}.max_jobs"
127
- end
128
-
129
- def clean_old_running_jobs
130
- too_old_time = class_purge_age.ago
131
-
132
- running_list.jobs.each do |job|
133
- job_start = job.start_time
134
-
135
- if job_start.blank? || job_start.to_time < too_old_time
136
- job.start(*job.args) if job_start.blank?
137
- job.cancel
138
- end
139
- end
135
+ def reset
136
+ @stored_values = nil
140
137
  end
141
138
  end
142
139
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module JobHistory
4
6
  # A class encompassing tasks about the jobs as a whole.
5
7
  #
6
8
  # This class gets a list of the classes and can provide a summary for each.
7
- class JobList < HistoryBase
9
+ class JobList < HistoryDetails
8
10
  def initialize
9
11
  super("")
10
12
  end
@@ -22,7 +24,7 @@ module Resque
22
24
  def job_summaries(sort_key = :class_name,
23
25
  sort_order = "asc",
24
26
  page_num = 1,
25
- page_size = Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE)
27
+ page_size = Resque::Plugins::JobHistory::PAGE_SIZE)
26
28
  jobs = sorted_job_summaries(sort_key)
27
29
 
28
30
  page_start = (page_num - 1) * page_size
@@ -32,14 +34,14 @@ module Resque
32
34
  end
33
35
 
34
36
  def job_classes
35
- redis.smembers(job_history_key)
37
+ redis.smembers(Resque::Plugins::JobHistory::HistoryDetails.job_history_key)
36
38
  end
37
39
 
38
40
  def job_class_summary(class_name)
39
- history = Resque::Plugins::JobHistory::HistoryBase.new(class_name)
41
+ history = Resque::Plugins::JobHistory::HistoryDetails.new(class_name)
40
42
 
41
- running_list = history.running_list
42
- finished_list = history.finished_list
43
+ running_list = history.running_jobs
44
+ finished_list = history.finished_jobs
43
45
 
44
46
  class_summary_hash(class_name, finished_list, running_list)
45
47
  end
@@ -67,10 +69,10 @@ module Resque
67
69
  job_summary[sort_key.to_sym]
68
70
  when :start_time
69
71
  job_summary[:last_run].start_time
70
- when :durration
72
+ when :duration
71
73
  job_summary[:last_run].duration
72
74
  when :success
73
- job_summary[:last_run].succeeded?
75
+ job_summary[:last_run].succeeded? ? 1 : 0
74
76
  end
75
77
  end
76
78
 
@@ -81,7 +83,10 @@ module Resque
81
83
  finished_jobs: finished_list.num_jobs,
82
84
  total_run_jobs: running_list.total,
83
85
  total_finished_jobs: finished_list.total,
84
- max_running_jobs: Resque::Plugins::JobHistory::Job.new(class_name, "").max_jobs,
86
+ max_concurrent_jobs: Resque::Plugins::JobHistory::HistoryDetails.new(class_name).
87
+ max_concurrent_jobs,
88
+ total_failed_jobs: Resque::Plugins::JobHistory::HistoryDetails.new(class_name).
89
+ total_failed_jobs,
85
90
  last_run: latest_job(running_list, finished_list) }
86
91
  end
87
92
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/concern"
4
+ require "active_support/core_ext/numeric/time"
2
5
 
3
6
  module Resque
4
7
  module Plugins
@@ -9,7 +12,9 @@ module Resque
9
12
 
10
13
  # Redis mapp:
11
14
  # job_history - a set of all of the class names of all jobs
12
- # job_history.<class_name>.max_jobs - The maximum number of jobs that have run for this class.
15
+ # job_history.<class_name>.max_jobs - The maximum number of jobs that have run concurrently
16
+ # for this class.
17
+ # job_history.<class_name>.total_failed_jobs - The total number of jobs that have failed
13
18
  # job_history.<class_name>.total_finished_jobs - The maximum number of jobs that have run for
14
19
  # this class.
15
20
  # job_history.<class_name>.running_jobs - a list of the IDs for all running jobs in the order
@@ -22,6 +27,8 @@ module Resque
22
27
  # end_time
23
28
  # error
24
29
  MAX_JOB_HISTORY = 200
30
+ PAGE_SIZE = 25
31
+ PURGE_AGE = 24.hours
25
32
 
26
33
  # The class methods added to the job class that is being enqueued and whose history is to be
27
34
  # recorded.
@@ -47,15 +54,19 @@ module Resque
47
54
  end
48
55
 
49
56
  def job_history_len
50
- @job_history_len || MAX_JOB_HISTORY
57
+ @job_history_len ||= Resque::Plugins::JobHistory::MAX_JOB_HISTORY
51
58
  end
52
59
 
53
60
  def purge_age
54
- @purge_jobs_after || 24.hours
61
+ @purge_jobs_after ||= Resque::Plugins::JobHistory::PURGE_AGE
55
62
  end
56
63
 
57
64
  def page_size
58
- @page_size || Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE
65
+ @page_size ||= Resque::Plugins::JobHistory::PAGE_SIZE
66
+ end
67
+
68
+ def job_history
69
+ Resque::Plugins::JobHistory::HistoryDetails.new(name)
59
70
  end
60
71
  end
61
72
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module JobHistory
4
- VERSION = "0.0.3"
6
+ VERSION = "0.0.4"
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,7 @@
1
1
  <div class="job_history_pagination_block">
2
2
  <% total_pages = job_list.job_classes.length / page_size %>
3
3
  <% total_pages += 1 if job_list.job_classes.length % page_size > 0 %>
4
- <% page_num = 1 if page_num > total_pages %>
4
+ <% page_num = 1 if page_num > total_pages || page_num < 1 %>
5
5
  <% first_page = [1, page_num - 3].max %>
6
6
  <% last_page = [total_pages, page_num + 3].min %>
7
7
  <% last_page = page_num < 4 ? [total_pages, last_page + (4 - page_num)].min : last_page %>
@@ -1,6 +1,7 @@
1
1
  <div class="job_history_pagination_block">
2
2
  <% total_pages = history_list.num_jobs / page_size %>
3
3
  <% total_pages += 1 if history_list.num_jobs % page_size > 0 %>
4
+ <% page_num = 1 if page_num > total_pages || page_num < 1 %>
4
5
  <% first_page = [1, page_num - 3].max %>
5
6
  <% last_page = [total_pages, page_num + 3].min %>
6
7
  <% last_page = page_num < 4 ? [total_pages, last_page + (4 - page_num)].min : last_page %>
@@ -3,7 +3,7 @@
3
3
  <h1><%= @job_class_name %></h1>
4
4
 
5
5
  <% job_list = Resque::Plugins::JobHistory::JobList.new %>
6
- <% history = Resque::Plugins::JobHistory::HistoryBase.new(@job_class_name) %>
6
+ <% history = Resque::Plugins::JobHistory::HistoryDetails.new(@job_class_name) %>
7
7
  <% class_info = job_list.job_class_summary(@job_class_name) %>
8
8
 
9
9
  <a href="<%= u("job history") %>">
@@ -64,7 +64,7 @@
64
64
  <%=
65
65
  erb(
66
66
  File.read(Resque::JobHistoryServer.erb_path("_jobs_list.erb")),
67
- locals: { history_list: history.running_list,
67
+ locals: { history_list: history.running_jobs,
68
68
  description: "Running Jobs",
69
69
  class_name: @job_class_name,
70
70
  page_num: @running_page_num,
@@ -79,7 +79,7 @@
79
79
  <%=
80
80
  erb(
81
81
  File.read(Resque::JobHistoryServer.erb_path("_jobs_list.erb")),
82
- locals: { history_list: history.finished_list,
82
+ locals: { history_list: history.finished_jobs,
83
83
  description: "Finished Jobs",
84
84
  class_name: @job_class_name,
85
85
  page_num: @finished_page_num,
@@ -93,6 +93,11 @@
93
93
 
94
94
  <br/>
95
95
 
96
- <form method="POST" action="purge_class?<%= { class_name: @job_class_name }.to_param %>">
97
- <input type="submit" name="" value="Purge all histories for <%= @job_class_name %>"/>
98
- </form>
96
+ <% if Resque::Plugins::JobHistory::Cleaner.similar_name?(@job_class_name) %>
97
+ This class cannot be purged because of another class with a similar name. The other class must
98
+ be purged before this one can be safely purged.
99
+ <% else %>
100
+ <form method="POST" action="purge_class?<%= { class_name: @job_class_name }.to_param %>">
101
+ <input type="submit" name="" value="Purge all histories for <%= @job_class_name %>"/>
102
+ </form>
103
+ <% end %>
@@ -67,7 +67,7 @@
67
67
  <input type="submit" name="" value="Delete this run"/>
68
68
  </form>
69
69
 
70
- <% if Resque::Plugins::JobHistory::HistoryBase.new(@job_class_name).class_name_valid?() %>
70
+ <% if Resque::Plugins::JobHistory::HistoryDetails.new(@job_class_name).class_name_valid?() %>
71
71
  <form method="POST" action="retry_job?<%= { class_name: @job_class_name, job_id: @job_id }.to_param %>">
72
72
  <input type="submit" name="" value="Retry this run"/>
73
73
  </form>
@@ -43,11 +43,11 @@
43
43
  order_param("start_time", @sort_by, @sort_order) }.to_param %>">
44
44
  Last Run Start
45
45
  </a></th>
46
- <th><a href="job%20history?<%= { sort: "durration",
46
+ <th><a href="job%20history?<%= { sort: "duration",
47
47
  page_size: @page_size,
48
48
  page_num: @page_num,
49
49
  order: job_list.
50
- order_param("durration", @sort_by, @sort_order) }.to_param %>">
50
+ order_param("duration", @sort_by, @sort_order) }.to_param %>">
51
51
  Last Run Duration
52
52
  </a></th>
53
53
  <th><a href="job%20history?<%= { sort: "success",
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "resque"
2
- require File.expand_path(File.join("resque", "plugins", "job_history", "history_base"), File.dirname(__FILE__))
4
+ require File.expand_path(File.join("resque", "plugins", "job_history", "history_details"),
5
+ File.dirname(__FILE__))
3
6
  require File.expand_path(File.join("resque", "plugins", "job_history", "history_list"), File.dirname(__FILE__))
4
7
  require File.expand_path(File.join("resque", "plugins", "job_history", "job_list"), File.dirname(__FILE__))
5
8
  require File.expand_path(File.join("resque", "plugins", "job_history", "job"), File.dirname(__FILE__))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :resque do
3
5
  # # Task goes here
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-job_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - RealNobody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: resque
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '1.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '1.25'
27
27
  - !ruby/object:Gem::Dependency
28
- name: resque
28
+ name: redis-namespace
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.25'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.25'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: redis-namespace
42
+ name: redis
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,13 +53,13 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: redis
56
+ name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :runtime
62
+ type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -67,7 +67,91 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec-rails
70
+ name: gem-release
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: cornucopia
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: haml-lint
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: timecop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: faker
71
155
  requirement: !ruby/object:Gem::Requirement
72
156
  requirements:
73
157
  - - ">="
@@ -93,7 +177,7 @@ files:
93
177
  - lib/resque/job_history_server.rb
94
178
  - lib/resque/plugins/job_history.rb
95
179
  - lib/resque/plugins/job_history/cleaner.rb
96
- - lib/resque/plugins/job_history/history_base.rb
180
+ - lib/resque/plugins/job_history/history_details.rb
97
181
  - lib/resque/plugins/job_history/history_list.rb
98
182
  - lib/resque/plugins/job_history/job.rb
99
183
  - lib/resque/plugins/job_history/job_list.rb
@@ -1,61 +0,0 @@
1
- module Resque
2
- module Plugins
3
- module JobHistory
4
- # A base class for job history classes which provides a base key and a few common functions.
5
- class HistoryBase
6
- attr_accessor :class_name
7
-
8
- NAME_SPACE = "Resque::Plugins::ResqueJobHistory".freeze
9
- PAGE_SIZE = 25
10
-
11
- def initialize(class_name)
12
- @class_name = class_name
13
- end
14
-
15
- def redis
16
- @redis ||= Redis::Namespace.new(NAME_SPACE, redis: Resque.redis)
17
- end
18
-
19
- def job_history_key
20
- "job_history"
21
- end
22
-
23
- def job_history_base_key
24
- "#{job_history_key}.#{class_name}"
25
- end
26
-
27
- def running_list
28
- @running_list = HistoryList.new(class_name, "running")
29
- end
30
-
31
- def finished_list
32
- @finished_list = HistoryList.new(class_name, "finished")
33
- end
34
-
35
- def class_name_valid?
36
- described_class.present?
37
- end
38
-
39
- private
40
-
41
- def described_class
42
- class_name.constantize
43
- rescue StandardError
44
- nil
45
- end
46
-
47
- def class_purge_age
48
- described_class.try(:purge_age) || 24.hours
49
- end
50
-
51
- def class_history_len
52
- described_class.try(:job_history_len) || MAX_JOB_HISTORY
53
- end
54
-
55
- def class_page_size
56
- described_class.try(:page_size) || Resque::Plugins::JobHistory::HistoryBase::PAGE_SIZE
57
- end
58
- end
59
- end
60
- end
61
- end