resque-job_history 0.0.4 → 0.0.5

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: 70bba4f7ca792423394d8f8a694329a721238bbe
4
- data.tar.gz: 3c3532c52a3e99789ee259d057b42533185040c9
3
+ metadata.gz: b694b3138b29678d77992c3bd60b5a2dfeeac281
4
+ data.tar.gz: 6052e79345a6d3893268547f67226498381489b7
5
5
  SHA512:
6
- metadata.gz: c86f488cc5e8485d45648b8f285fef4ed3ebee4b2e4846b9cb6920feab48fe2cb28f9def1a7f3e6154f51976d2089f2c9ad05c87a8f526eb1c545a5500761864
7
- data.tar.gz: b52328b3f04d64f71101ed6903d0828dd470226512f15e6cb6ed50072b2a7fe62deff11b19d6bfba6a47e155965134b049a13a6aa91bea24c51737e5fb3a84ab
6
+ metadata.gz: ede3b231cae7051dff2d3b0194a664acc49ceac54f031a6f968f21ebe90fc991778363075a375d38e18506cc909ac44143fc52dcc94bbe6b6dd3eb3723ff53c1
7
+ data.tar.gz: a485d45ac90bec11610da58dd6f7b862690665bcaab7f06dd0746d5ec70d24e0c79ddc1d6af0d087678f0ed6501deea81fadaf039adc06e37167496ef2e64d28
@@ -52,7 +52,8 @@ module Resque
52
52
  @sort_by = params[:sort] || "class_name"
53
53
  @sort_order = params[:order] || "asc"
54
54
  @page_num = (params[:page_num] || 1).to_i
55
- @page_size = (params[:page_size] || Resque::Plugins::JobHistory::PAGE_SIZE).to_i
55
+ @page_size = (params[:page_size] ||
56
+ Resque::Plugins::JobHistory::HistoryDetails.class_list_page_size).to_i
56
57
  end
57
58
  end
58
59
  end
@@ -85,7 +86,8 @@ module Resque
85
86
  base.class_eval do
86
87
  def set_running_page_params
87
88
  @running_page_num = (params[:running_page_num] || 1).to_i
88
- @running_page_size = params[:running_page_size]
89
+ @running_page_size = (params[:running_page_size] ||
90
+ Resque::Plugins::JobHistory::HistoryDetails.new(@job_class_name).page_size).to_i
89
91
  end
90
92
  end
91
93
  end
@@ -94,7 +96,8 @@ module Resque
94
96
  base.class_eval do
95
97
  def set_finished_page_params
96
98
  @finished_page_num = (params[:finished_page_num] || 1).to_i
97
- @finished_page_size = params[:finished_page_size]
99
+ @finished_page_size = (params[:finished_page_size] ||
100
+ Resque::Plugins::JobHistory::HistoryDetails.new(@job_class_name).page_size).to_i
98
101
  end
99
102
  end
100
103
  end
@@ -13,6 +13,14 @@ module Resque
13
13
  def job_history_key
14
14
  "job_history"
15
15
  end
16
+
17
+ def class_list_page_size=(value)
18
+ @class_list_page_size = value
19
+ end
20
+
21
+ def class_list_page_size
22
+ @class_list_page_size ||= Resque::Plugins::JobHistory::PAGE_SIZE
23
+ end
16
24
  end
17
25
 
18
26
  def initialize(class_name)
@@ -60,6 +68,10 @@ module Resque
60
68
  end
61
69
  end
62
70
 
71
+ def page_size
72
+ class_page_size
73
+ end
74
+
63
75
  private
64
76
 
65
77
  def described_class
@@ -26,14 +26,14 @@ module Resque
26
26
  redis.lrem(job_list_key, 0, job_id)
27
27
  end
28
28
 
29
- def paged_jobs(page_num = 1, page_size = nil)
30
- page_size ||= class_page_size
31
- page_size = page_size.to_i
32
- page_size = Resque::Plugins::JobHistory::PAGE_SIZE if page_size < 1
33
- start = (page_num - 1) * page_size
34
- start = 0 if start >= num_jobs || start.negative?
35
-
36
- jobs(start, start + page_size - 1)
29
+ def paged_jobs(page_num = 1, job_page_size = nil)
30
+ job_page_size ||= page_size
31
+ job_page_size = job_page_size.to_i
32
+ job_page_size = Resque::Plugins::JobHistory::PAGE_SIZE if job_page_size < 1
33
+ start = (page_num - 1) * job_page_size
34
+ start = 0 if start >= num_jobs || start.negative?
35
+
36
+ jobs(start, start + job_page_size - 1)
37
37
  end
38
38
 
39
39
  def jobs(start = 0, stop = -1)
@@ -24,13 +24,13 @@ module Resque
24
24
  def job_summaries(sort_key = :class_name,
25
25
  sort_order = "asc",
26
26
  page_num = 1,
27
- page_size = Resque::Plugins::JobHistory::PAGE_SIZE)
27
+ summary_page_size = Resque::Plugins::JobHistory::PAGE_SIZE)
28
28
  jobs = sorted_job_summaries(sort_key)
29
29
 
30
- page_start = (page_num - 1) * page_size
30
+ page_start = (page_num - 1) * summary_page_size
31
31
  page_start = 0 if page_start > jobs.length
32
32
 
33
- (sort_order == "desc" ? jobs.reverse : jobs)[page_start..page_start + page_size - 1]
33
+ (sort_order == "desc" ? jobs.reverse : jobs)[page_start..page_start + summary_page_size - 1]
34
34
  end
35
35
 
36
36
  def job_classes
@@ -3,7 +3,7 @@
3
3
  module Resque
4
4
  module Plugins
5
5
  module JobHistory
6
- VERSION = "0.0.4"
6
+ VERSION = "0.0.5"
7
7
  end
8
8
  end
9
9
  end
@@ -27,3 +27,8 @@
27
27
  .job_history_last_page {
28
28
  margin-left: 5px;
29
29
  }
30
+
31
+ .table_container {
32
+ width: 100%;
33
+ overflow-x: scroll;
34
+ }
@@ -12,36 +12,38 @@
12
12
  secondary_page_num: secondary_page_num,
13
13
  secondary_page_size: secondary_page_size }) %>
14
14
 
15
- <table>
16
- <tr>
17
- <th>Started</th>
18
- <th>Duration</th>
19
- <th>Parameters</th>
20
- <th>Error</th>
21
- </tr>
22
- <% jobs.each do |job_details| %>
15
+ <div class="table_container">
16
+ <table>
23
17
  <tr>
24
- <td>
25
- <a href="job_details?class_name=<%= job_details.class_name %>&job_id=<%= job_details.job_id %>">
26
- <%= time_ago_in_words(job_details.start_time) %> ago
27
- (<%= job_details.start_time %>)
28
- </a>
29
- </td>
30
- <td>
31
- <%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
32
- <% if job_details.finished? %>
33
- (<%= job_details.end_time %>)
34
- <% end %>
35
- </td>
36
- <td>
37
- <pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
38
- </td>
39
- <td>
40
- <%= job_details.error %>
41
- </td>
18
+ <th>Started</th>
19
+ <th>Duration</th>
20
+ <th>Parameters</th>
21
+ <th>Error</th>
42
22
  </tr>
43
- <% end %>
44
- </table>
23
+ <% jobs.each do |job_details| %>
24
+ <tr>
25
+ <td>
26
+ <a href="job_details?class_name=<%= job_details.class_name %>&job_id=<%= job_details.job_id %>">
27
+ <%= time_ago_in_words(job_details.start_time) %> ago
28
+ (<%= job_details.start_time %>)
29
+ </a>
30
+ </td>
31
+ <td>
32
+ <%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
33
+ <% if job_details.finished? %>
34
+ (<%= job_details.end_time %>)
35
+ <% end %>
36
+ </td>
37
+ <td>
38
+ <pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
39
+ </td>
40
+ <td>
41
+ <%= job_details.error %>
42
+ </td>
43
+ </tr>
44
+ <% end %>
45
+ </table>
46
+ </div>
45
47
 
46
48
  <%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_pagination.erb")),
47
49
  locals: { history_list: history_list,
@@ -10,56 +10,58 @@
10
10
  Job History
11
11
  </a>
12
12
 
13
- <table>
14
- <tr>
15
- <td>
16
- Running jobs
17
- </td>
18
- <td>
19
- <%= class_info[:running_jobs].to_i %>
20
- </td>
21
- </tr>
22
- <tr>
23
- <td>
24
- Total jobs run
25
- </td>
26
- <td>
27
- <%= class_info[:total_run_jobs].to_i %>
28
- </td>
29
- </tr>
30
- <tr>
31
- <td>
32
- Total jobs finished
33
- </td>
34
- <td>
35
- <%= class_info[:total_finished_jobs].to_i %>
36
- </td>
37
- </tr>
38
- <tr>
39
- <td>
40
- Total jobs in history
41
- </td>
42
- <td>
43
- <%= class_info[:finished_jobs].to_i %>
44
- </td>
45
- </tr>
46
- <tr>
47
- <td>
48
- Maximum number of consecutive jobs seen
49
- </td>
50
- <td>
51
- <%= class_info[:max_running_jobs].to_i %>
52
- </td>
53
- </tr>
54
- <tr>
55
- <td>
56
- Is still valid job
57
- </td>
58
- <td>
59
- <%= class_info[:class_name_valid] %>
60
- </td>
61
- </tr>
62
- </table>
13
+ <div class="table_container">
14
+ <table>
15
+ <tr>
16
+ <td>
17
+ Running jobs
18
+ </td>
19
+ <td>
20
+ <%= class_info[:running_jobs].to_i %>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td>
25
+ Total jobs run
26
+ </td>
27
+ <td>
28
+ <%= class_info[:total_run_jobs].to_i %>
29
+ </td>
30
+ </tr>
31
+ <tr>
32
+ <td>
33
+ Total jobs finished
34
+ </td>
35
+ <td>
36
+ <%= class_info[:total_finished_jobs].to_i %>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <td>
41
+ Total jobs in history
42
+ </td>
43
+ <td>
44
+ <%= class_info[:finished_jobs].to_i %>
45
+ </td>
46
+ </tr>
47
+ <tr>
48
+ <td>
49
+ Maximum number of consecutive jobs seen
50
+ </td>
51
+ <td>
52
+ <%= class_info[:max_running_jobs].to_i %>
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ Is still valid job
58
+ </td>
59
+ <td>
60
+ <%= class_info[:class_name_valid] %>
61
+ </td>
62
+ </tr>
63
+ </table>
64
+ </div>
63
65
 
64
66
  <%=
65
67
  erb(
@@ -14,46 +14,48 @@
14
14
  <%= @job_class_name %>
15
15
  </a>
16
16
 
17
- <table>
18
- <tr>
19
- <td>
20
- Started
21
- </td>
22
- <td>
23
- <%= time_ago_in_words(job_details.start_time) %> ago
24
- (<%= job_details.start_time %>)
25
- </td>
26
- </tr>
27
- <tr>
28
- <td>
29
- Duration
30
- </td>
31
- <td>
32
- <%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
33
- <% if job_details.finished? %>
34
- (<%= job_details.end_time %>)
35
- <% end %>
36
- </td>
37
- </tr>
38
- <tr>
39
- <td>
40
- Params
41
- </td>
42
- <td>
43
- <pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
44
- </td>
45
- </tr>
46
- <% unless job_details.succeeded? %>
17
+ <div class="table_container">
18
+ <table>
47
19
  <tr>
48
20
  <td>
49
- Error
21
+ Started
50
22
  </td>
51
23
  <td>
52
- <%= job_details.error %>
24
+ <%= time_ago_in_words(job_details.start_time) %> ago
25
+ (<%= job_details.start_time %>)
53
26
  </td>
54
27
  </tr>
55
- <% end %>
56
- </table>
28
+ <tr>
29
+ <td>
30
+ Duration
31
+ </td>
32
+ <td>
33
+ <%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
34
+ <% if job_details.finished? %>
35
+ (<%= job_details.end_time %>)
36
+ <% end %>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <td>
41
+ Params
42
+ </td>
43
+ <td>
44
+ <pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
45
+ </td>
46
+ </tr>
47
+ <% unless job_details.succeeded? %>
48
+ <tr>
49
+ <td>
50
+ Error
51
+ </td>
52
+ <td>
53
+ <%= job_details.error %>
54
+ </td>
55
+ </tr>
56
+ <% end %>
57
+ </table>
58
+ </div>
57
59
 
58
60
  <br/>
59
61
 
@@ -6,101 +6,103 @@
6
6
  <%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_class_pagination.erb")),
7
7
  locals: { job_list: job_list, page_num: @page_num, page_size: @page_size }) %>
8
8
 
9
- <table>
10
- <tr>
11
- <th><a href="job%20history?<%= { sort: "class_name",
12
- page_size: @page_size,
13
- page_num: @page_num,
14
- order: job_list.
15
- order_param("class_name", @sort_by, @sort_order) }.to_param %>">
16
- Class name
17
- </a></th>
18
- <th><a href="job%20history?<%= { sort: "running_jobs",
19
- page_size: @page_size,
20
- page_num: @page_num,
21
- order: job_list.
22
- order_param("running_jobs", @sort_by, @sort_order) }.to_param %>">
23
- Running
24
- </a></th>
25
- <th><a href="job%20history?<%= { sort: "total_finished_jobs",
26
- page_size: @page_size,
27
- page_num: @page_num,
28
- order: job_list.
29
- order_param("total_finished_jobs", @sort_by, @sort_order) }.to_param %>">
30
- Finished
31
- </a></th>
32
- <th><a href="job%20history?<%= { sort: "max_running_jobs",
33
- page_size: @page_size,
34
- page_num: @page_num,
35
- order: job_list.
36
- order_param("max_running_jobs", @sort_by, @sort_order) }.to_param %>">
37
- Max Running
38
- </a></th>
39
- <th><a href="job%20history?<%= { sort: "start_time",
40
- page_size: @page_size,
41
- page_num: @page_num,
42
- order: job_list.
43
- order_param("start_time", @sort_by, @sort_order) }.to_param %>">
44
- Last Run Start
45
- </a></th>
46
- <th><a href="job%20history?<%= { sort: "duration",
47
- page_size: @page_size,
48
- page_num: @page_num,
49
- order: job_list.
50
- order_param("duration", @sort_by, @sort_order) }.to_param %>">
51
- Last Run Duration
52
- </a></th>
53
- <th><a href="job%20history?<%= { sort: "success",
54
- page_size: @page_size,
55
- page_num: @page_num,
56
- order: job_list.
57
- order_param("success", @sort_by, @sort_order) }.to_param %>">
58
- Last Run successful
59
- </a></th>
60
- </tr>
61
-
62
- <% job_list.job_summaries(@sort_by, @sort_order, @page_num, @page_size).each do |class_info| %>
9
+ <div class="table_container">
10
+ <table>
63
11
  <tr>
64
- <td>
65
- <a href="job%20history/job_class_details?class_name=<%= class_info[:class_name] %>">
66
- <%= class_info[:class_name] %>
67
- </a>
68
- </td>
69
- <td>
70
- <%= class_info[:running_jobs].to_i %>
71
- </td>
72
- <td>
73
- <%= class_info[:total_finished_jobs].to_i %>
74
- </td>
75
- <td>
76
- <%= class_info[:max_running_jobs].to_i %>
77
- </td>
78
- <td>
79
- <% if class_info[:last_run] && class_info[:last_run].start_time %>
80
- <%= time_ago_in_words(class_info[:last_run].start_time) %> ago
81
- (<%= class_info[:last_run].start_time %>)
82
- <% end %>
83
- </td>
84
- <td>
85
- <% if class_info[:last_run] %>
86
- <% if class_info[:last_run].finished? %>
87
- <%= distance_of_time_in_words(class_info[:last_run].start_time, class_info[:last_run].end_time) %>
88
- (<%= class_info[:last_run].end_time %>)
12
+ <th><a href="job%20history?<%= { sort: "class_name",
13
+ page_size: @page_size,
14
+ page_num: @page_num,
15
+ order: job_list.
16
+ order_param("class_name", @sort_by, @sort_order) }.to_param %>">
17
+ Class name
18
+ </a></th>
19
+ <th><a href="job%20history?<%= { sort: "running_jobs",
20
+ page_size: @page_size,
21
+ page_num: @page_num,
22
+ order: job_list.
23
+ order_param("running_jobs", @sort_by, @sort_order) }.to_param %>">
24
+ Running
25
+ </a></th>
26
+ <th><a href="job%20history?<%= { sort: "total_finished_jobs",
27
+ page_size: @page_size,
28
+ page_num: @page_num,
29
+ order: job_list.
30
+ order_param("total_finished_jobs", @sort_by, @sort_order) }.to_param %>">
31
+ Finished
32
+ </a></th>
33
+ <th><a href="job%20history?<%= { sort: "max_running_jobs",
34
+ page_size: @page_size,
35
+ page_num: @page_num,
36
+ order: job_list.
37
+ order_param("max_running_jobs", @sort_by, @sort_order) }.to_param %>">
38
+ Max Running
39
+ </a></th>
40
+ <th><a href="job%20history?<%= { sort: "start_time",
41
+ page_size: @page_size,
42
+ page_num: @page_num,
43
+ order: job_list.
44
+ order_param("start_time", @sort_by, @sort_order) }.to_param %>">
45
+ Last Run Start
46
+ </a></th>
47
+ <th><a href="job%20history?<%= { sort: "duration",
48
+ page_size: @page_size,
49
+ page_num: @page_num,
50
+ order: job_list.
51
+ order_param("duration", @sort_by, @sort_order) }.to_param %>">
52
+ Last Run Duration
53
+ </a></th>
54
+ <th><a href="job%20history?<%= { sort: "success",
55
+ page_size: @page_size,
56
+ page_num: @page_num,
57
+ order: job_list.
58
+ order_param("success", @sort_by, @sort_order) }.to_param %>">
59
+ Last Run successful
60
+ </a></th>
61
+ </tr>
62
+
63
+ <% job_list.job_summaries(@sort_by, @sort_order, @page_num, @page_size).each do |class_info| %>
64
+ <tr>
65
+ <td>
66
+ <a href="job%20history/job_class_details?class_name=<%= class_info[:class_name] %>">
67
+ <%= class_info[:class_name] %>
68
+ </a>
69
+ </td>
70
+ <td>
71
+ <%= class_info[:running_jobs].to_i %>
72
+ </td>
73
+ <td>
74
+ <%= class_info[:total_finished_jobs].to_i %>
75
+ </td>
76
+ <td>
77
+ <%= class_info[:max_running_jobs].to_i %>
78
+ </td>
79
+ <td>
80
+ <% if class_info[:last_run] && class_info[:last_run].start_time %>
81
+ <%= time_ago_in_words(class_info[:last_run].start_time) %> ago
82
+ (<%= class_info[:last_run].start_time %>)
83
+ <% end %>
84
+ </td>
85
+ <td>
86
+ <% if class_info[:last_run] %>
87
+ <% if class_info[:last_run].finished? %>
88
+ <%= distance_of_time_in_words(class_info[:last_run].start_time, class_info[:last_run].end_time) %>
89
+ (<%= class_info[:last_run].end_time %>)
90
+ <% else %>
91
+ Still running...
92
+ <% end %>
93
+ <% end %>
94
+ </td>
95
+ <td>
96
+ <% if class_info[:last_run] && class_info[:last_run].error %>
97
+ No
89
98
  <% else %>
90
- Still running...
99
+ Yes
91
100
  <% end %>
92
- <% end %>
93
- </td>
94
- <td>
95
- <% if class_info[:last_run] && class_info[:last_run].error %>
96
- No
97
- <% else %>
98
- Yes
99
- <% end %>
100
- </td>
101
- </tr>
102
- <% end %>
103
- </table>
101
+ </td>
102
+ </tr>
103
+ <% end %>
104
+ </table>
105
+ </div>
104
106
 
105
107
  <%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_class_pagination.erb")),
106
108
  locals: { job_list: job_list, page_num: @page_num, page_size: @page_size }) %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-job_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-12 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque