resque-job_history 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resque/job_history_server.rb +49 -10
- data/lib/resque/plugins/job_history/job.rb +4 -0
- data/lib/resque/plugins/job_history/job_search.rb +238 -0
- data/lib/resque/plugins/version.rb +1 -1
- data/lib/resque/server/public/job_history.css +18 -0
- data/lib/resque/server/views/_job_list_table.erb +50 -0
- data/lib/resque/server/views/_job_summary_rows.erb +44 -0
- data/lib/resque/server/views/_jobs_list.erb +2 -39
- data/lib/resque/server/views/_search_form.erb +14 -0
- data/lib/resque/server/views/job_class_details.erb +20 -7
- data/lib/resque/server/views/job_details.erb +1 -0
- data/lib/resque/server/views/job_history.erb +16 -49
- data/lib/resque/server/views/linear_history.erb +16 -46
- data/lib/resque/server/views/search_results.erb +68 -0
- data/lib/resque-job_history.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12b7b70a26083af7bc43e79071c56a7b1a9b1c7a
|
4
|
+
data.tar.gz: f34d0ea2e6a27e9aa272051c53b1c40b01550e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8418efa6f85eafbd533c0a4592ff671d7c462c926a4071ee292cc6be468fcdd027ab6f1b2f85e790ef5dced7ee97ab54f56b94030bf414e977bcb4bb20f727d
|
7
|
+
data.tar.gz: cdcc689db81b7131d7c27e09b8890d39cee88f57e6be6330fae1234bfedf4d7f66d68f85d2731ef50fffa0cd9d548fbba6c6b78b86dd1cbf6f32f40626534532
|
@@ -41,7 +41,7 @@ module Resque
|
|
41
41
|
job_history_params(base)
|
42
42
|
|
43
43
|
base.class_eval do
|
44
|
-
get "/job
|
44
|
+
get "/job%20history" do
|
45
45
|
set_job_history_params
|
46
46
|
|
47
47
|
erb File.read(Resque::JobHistoryServer.erb_path("job_history.erb"))
|
@@ -67,7 +67,7 @@ module Resque
|
|
67
67
|
finished_page_params(base)
|
68
68
|
|
69
69
|
base.class_eval do
|
70
|
-
get "/job
|
70
|
+
get "/job%20history/job_class_details" do
|
71
71
|
set_class_details_params
|
72
72
|
|
73
73
|
erb File.read(Resque::JobHistoryServer.erb_path("job_class_details.erb"))
|
@@ -107,7 +107,7 @@ module Resque
|
|
107
107
|
|
108
108
|
def job_details(base)
|
109
109
|
base.class_eval do
|
110
|
-
get "/job
|
110
|
+
get "/job%20history/job_details" do
|
111
111
|
@job_class_name = params[:class_name]
|
112
112
|
@job_id = params[:job_id]
|
113
113
|
|
@@ -118,7 +118,7 @@ module Resque
|
|
118
118
|
|
119
119
|
def linear_list(base)
|
120
120
|
base.class_eval do
|
121
|
-
get "/job
|
121
|
+
get "/job%20history/linear_history" do
|
122
122
|
@page_num = (params[:page_num] || 1).to_i
|
123
123
|
@page_size = (params[:page_size] ||
|
124
124
|
Resque::Plugins::JobHistory::HistoryDetails.linear_page_size).to_i
|
@@ -143,11 +143,14 @@ module Resque
|
|
143
143
|
retry_job(base)
|
144
144
|
delete_job(base)
|
145
145
|
cancel_job(base)
|
146
|
+
search_all(base)
|
147
|
+
search_job(base)
|
148
|
+
search_linear_history(base)
|
146
149
|
end
|
147
150
|
|
148
151
|
def cancel_job(base)
|
149
152
|
base.class_eval do
|
150
|
-
post "/job
|
153
|
+
post "/job%20history/cancel_job" do
|
151
154
|
Resque::Plugins::JobHistory::Job.new(params[:class_name], params[:job_id]).cancel
|
152
155
|
|
153
156
|
redirect u("job history/job_details?#{{ class_name: params[:class_name],
|
@@ -158,7 +161,7 @@ module Resque
|
|
158
161
|
|
159
162
|
def delete_job(base)
|
160
163
|
base.class_eval do
|
161
|
-
post "/job
|
164
|
+
post "/job%20history/delete_job" do
|
162
165
|
Resque::Plugins::JobHistory::Job.new(params[:class_name], params[:job_id]).purge
|
163
166
|
|
164
167
|
redirect u("job history/job_class_details?#{{ class_name: params[:class_name] }.to_param}")
|
@@ -168,7 +171,7 @@ module Resque
|
|
168
171
|
|
169
172
|
def retry_job(base)
|
170
173
|
base.class_eval do
|
171
|
-
post "/job
|
174
|
+
post "/job%20history/retry_job" do
|
172
175
|
Resque::Plugins::JobHistory::Job.new(params[:class_name], params[:job_id]).retry
|
173
176
|
|
174
177
|
redirect u("job history/job_class_details?#{{ class_name: params[:class_name] }.to_param}")
|
@@ -178,7 +181,7 @@ module Resque
|
|
178
181
|
|
179
182
|
def purge_class(base)
|
180
183
|
base.class_eval do
|
181
|
-
post "/job
|
184
|
+
post "/job%20history/purge_class" do
|
182
185
|
Resque::Plugins::JobHistory::Cleaner.purge_class(params[:class_name])
|
183
186
|
|
184
187
|
redirect u("job history")
|
@@ -188,7 +191,7 @@ module Resque
|
|
188
191
|
|
189
192
|
def purge_all(base)
|
190
193
|
base.class_eval do
|
191
|
-
post "/job
|
194
|
+
post "/job%20history/purge_all" do
|
192
195
|
Resque::Plugins::JobHistory::Cleaner.purge_all_jobs
|
193
196
|
|
194
197
|
redirect u("job history")
|
@@ -198,13 +201,49 @@ module Resque
|
|
198
201
|
|
199
202
|
def purge_linear_history(base)
|
200
203
|
base.class_eval do
|
201
|
-
post "/job
|
204
|
+
post "/job%20history/purge_linear_history" do
|
202
205
|
Resque::Plugins::JobHistory::Cleaner.purge_linear_history
|
203
206
|
|
204
207
|
redirect u("job history")
|
205
208
|
end
|
206
209
|
end
|
207
210
|
end
|
211
|
+
|
212
|
+
def search_all(base)
|
213
|
+
base.class_eval do
|
214
|
+
post "/job%20history/search_all" do
|
215
|
+
@job_search = Resque::Plugins::JobHistory::JobSearch.new(params)
|
216
|
+
|
217
|
+
@job_search.search
|
218
|
+
|
219
|
+
erb File.read(Resque::JobHistoryServer.erb_path("search_results.erb"))
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def search_job(base)
|
225
|
+
base.class_eval do
|
226
|
+
post "/job%20history/search_job" do
|
227
|
+
@job_search = Resque::Plugins::JobHistory::JobSearch.new(params)
|
228
|
+
|
229
|
+
@job_search.search
|
230
|
+
|
231
|
+
erb File.read(Resque::JobHistoryServer.erb_path("search_results.erb"))
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def search_linear_history(base)
|
237
|
+
base.class_eval do
|
238
|
+
post "/job%20history/search_linear_history" do
|
239
|
+
@job_search = Resque::Plugins::JobHistory::JobSearch.new(params)
|
240
|
+
|
241
|
+
@job_search.search
|
242
|
+
|
243
|
+
erb File.read(Resque::JobHistoryServer.erb_path("search_results.erb"))
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
208
247
|
end
|
209
248
|
|
210
249
|
Resque::Server.tabs << "Job History"
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rubocop:disable ClassLength
|
3
|
+
|
4
|
+
module Resque
|
5
|
+
module Plugins
|
6
|
+
module JobHistory
|
7
|
+
# This class searches through jobs looking for one which matches the passed in criteria.
|
8
|
+
class JobSearch
|
9
|
+
ALL_ATTRIBUTES = [:search_type,
|
10
|
+
:job_class_name,
|
11
|
+
:search_for,
|
12
|
+
:regex_search,
|
13
|
+
:case_insensitive,
|
14
|
+
:last_class_name,
|
15
|
+
:last_job_id,
|
16
|
+
:last_job_group].freeze
|
17
|
+
|
18
|
+
SEARCH_TYPES = %w(search_all search_job search_linear_history).freeze
|
19
|
+
|
20
|
+
DEFAULT_SEARCH_TIMEOUT = 10.seconds
|
21
|
+
|
22
|
+
attr_reader(*ALL_ATTRIBUTES)
|
23
|
+
|
24
|
+
def initialize(params)
|
25
|
+
params = params.with_indifferent_access
|
26
|
+
ALL_ATTRIBUTES.each do |attribute|
|
27
|
+
instance_variable_set("@#{attribute}", params[attribute]) if params.key?(attribute)
|
28
|
+
end
|
29
|
+
|
30
|
+
raise ArgumentError, "invalid search_type" unless SEARCH_TYPES.include?(search_type)
|
31
|
+
end
|
32
|
+
|
33
|
+
def retry_search_settings(all_settings)
|
34
|
+
settings = search_settings(all_settings)
|
35
|
+
|
36
|
+
[:last_class_name,
|
37
|
+
:last_job_id,
|
38
|
+
:last_job_group].each do |continue_setting|
|
39
|
+
settings.delete(continue_setting)
|
40
|
+
end
|
41
|
+
|
42
|
+
settings
|
43
|
+
end
|
44
|
+
|
45
|
+
def search_settings(all_settings)
|
46
|
+
settings = ALL_ATTRIBUTES.dup
|
47
|
+
|
48
|
+
unless all_settings
|
49
|
+
settings.delete :search_for
|
50
|
+
settings.delete :regex_search
|
51
|
+
settings.delete :case_insensitive
|
52
|
+
end
|
53
|
+
|
54
|
+
settings.each_with_object({}) do |setting, hash|
|
55
|
+
hash[setting] = send(setting)
|
56
|
+
|
57
|
+
hash.delete(setting) if hash[setting].blank?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def search
|
62
|
+
end_search?
|
63
|
+
|
64
|
+
send search_type
|
65
|
+
end
|
66
|
+
|
67
|
+
def class_results
|
68
|
+
@class_results ||= []
|
69
|
+
end
|
70
|
+
|
71
|
+
def run_results
|
72
|
+
@run_results ||= []
|
73
|
+
end
|
74
|
+
|
75
|
+
def more_records?
|
76
|
+
last_class_name || last_job_id
|
77
|
+
end
|
78
|
+
|
79
|
+
def search_timeout
|
80
|
+
DEFAULT_SEARCH_TIMEOUT
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def search_end_time
|
86
|
+
@search_end_time ||= search_timeout.from_now
|
87
|
+
end
|
88
|
+
|
89
|
+
def end_search?
|
90
|
+
Time.now > search_end_time
|
91
|
+
end
|
92
|
+
|
93
|
+
def search_all
|
94
|
+
job_list = Resque::Plugins::JobHistory::JobList.new
|
95
|
+
search_jobs = job_list.job_classes.sort.map { |class_name| job_list.job_details(class_name) }
|
96
|
+
|
97
|
+
search_class_names(search_jobs) unless last_class_name && last_job_id
|
98
|
+
|
99
|
+
return if end_search? && last_class_name.present? && !last_job_id
|
100
|
+
|
101
|
+
search_all_class_jobs(search_jobs)
|
102
|
+
end
|
103
|
+
|
104
|
+
def search_all_class_jobs(search_jobs)
|
105
|
+
search_jobs = remove_searched_job_classes(search_jobs)
|
106
|
+
|
107
|
+
search_jobs.each do |job_class|
|
108
|
+
search_job_class job_class
|
109
|
+
|
110
|
+
@last_class_name = job_class.class_name
|
111
|
+
|
112
|
+
break if end_search? && last_job_id.present?
|
113
|
+
end
|
114
|
+
|
115
|
+
@last_class_name = nil if search_jobs.blank? || !end_search? || last_job_id.blank?
|
116
|
+
end
|
117
|
+
|
118
|
+
def search_job
|
119
|
+
job_class = Resque::Plugins::JobHistory::HistoryDetails.new(job_class_name)
|
120
|
+
|
121
|
+
search_job_class(job_class)
|
122
|
+
end
|
123
|
+
|
124
|
+
def search_linear_history
|
125
|
+
job_class = Resque::Plugins::JobHistory::JobList.new
|
126
|
+
|
127
|
+
search_class_jobs(job_class.linear_jobs.jobs, :linear_jobs)
|
128
|
+
end
|
129
|
+
|
130
|
+
def search_regex
|
131
|
+
@search_regex = if search_for.blank?
|
132
|
+
search_for
|
133
|
+
elsif regex_search
|
134
|
+
Regexp.new(search_for, case_insensitive)
|
135
|
+
elsif case_insensitive
|
136
|
+
search_for.downcase
|
137
|
+
else
|
138
|
+
search_for
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def validate_string(value)
|
143
|
+
if search_regex.blank?
|
144
|
+
value == "[]"
|
145
|
+
elsif regex_search
|
146
|
+
value.match(search_regex)
|
147
|
+
elsif case_insensitive
|
148
|
+
value.downcase.include?(search_regex)
|
149
|
+
else
|
150
|
+
value.include?(search_regex)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def search_class_names(search_jobs)
|
155
|
+
search_jobs = remove_searched_job_classes(search_jobs)
|
156
|
+
|
157
|
+
search_jobs.each do |job_class|
|
158
|
+
class_results << job_class if validate_string(job_class.class_name)
|
159
|
+
@last_class_name = job_class.class_name
|
160
|
+
|
161
|
+
break if end_search?
|
162
|
+
end
|
163
|
+
|
164
|
+
@last_class_name = nil if search_jobs.blank? || !end_search?
|
165
|
+
end
|
166
|
+
|
167
|
+
def remove_searched_job_classes(search_jobs)
|
168
|
+
last_index = if last_class_name.present?
|
169
|
+
job_index = search_jobs.
|
170
|
+
index { |job_class| job_class.class_name == last_class_name } ||
|
171
|
+
search_jobs.length
|
172
|
+
|
173
|
+
job_index += 1 if last_job_id.blank?
|
174
|
+
|
175
|
+
job_index
|
176
|
+
else
|
177
|
+
0
|
178
|
+
end
|
179
|
+
|
180
|
+
if last_index.positive?
|
181
|
+
Array.wrap(search_jobs[last_index..-1])
|
182
|
+
else
|
183
|
+
search_jobs
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def search_job_class(job_class)
|
188
|
+
if last_job_group.blank? || last_job_group == :running_jobs
|
189
|
+
search_class_jobs(job_class.running_jobs.jobs, :running_jobs)
|
190
|
+
|
191
|
+
return unless !end_search? || last_job_id.blank?
|
192
|
+
end
|
193
|
+
|
194
|
+
search_class_jobs(job_class.finished_jobs.jobs, :finished_jobs)
|
195
|
+
end
|
196
|
+
|
197
|
+
def search_class_jobs(job_list, job_group)
|
198
|
+
return if last_job_group.present? && last_job_group.to_s != job_group.to_s
|
199
|
+
|
200
|
+
job_list = remove_searched_jobs(job_list, job_group)
|
201
|
+
|
202
|
+
@last_job_group = job_group
|
203
|
+
|
204
|
+
add_class_job_results(job_list)
|
205
|
+
|
206
|
+
return if job_list.present? && end_search?
|
207
|
+
|
208
|
+
@last_job_id = nil
|
209
|
+
@last_job_group = nil
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_class_job_results(job_list)
|
213
|
+
job_list.each do |job|
|
214
|
+
run_results << job if validate_string(Resque.encode(job.args))
|
215
|
+
@last_job_id = job.job_id
|
216
|
+
|
217
|
+
break if end_search?
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def remove_searched_jobs(job_list, job_group)
|
222
|
+
last_index = if last_job_id.present? && job_group == last_job_group
|
223
|
+
(job_list.index { |job_run| job_run.job_id == last_job_id } ||
|
224
|
+
job_list.length) + 1
|
225
|
+
else
|
226
|
+
0
|
227
|
+
end
|
228
|
+
|
229
|
+
if last_index.positive?
|
230
|
+
Array.wrap(job_list[last_index..-1])
|
231
|
+
else
|
232
|
+
job_list
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -36,3 +36,21 @@
|
|
36
36
|
.job_history_error {
|
37
37
|
background-color: lightcoral;
|
38
38
|
}
|
39
|
+
|
40
|
+
.job_history_linear_history_div {
|
41
|
+
margin-top: 5px;
|
42
|
+
float: left;
|
43
|
+
}
|
44
|
+
|
45
|
+
#job_history_search_div {
|
46
|
+
float: right;
|
47
|
+
margin-bottom: 10px;
|
48
|
+
}
|
49
|
+
|
50
|
+
#job_history_search_div form {
|
51
|
+
margin-top: 0px;
|
52
|
+
}
|
53
|
+
|
54
|
+
.job_history_reset {
|
55
|
+
clear: both;
|
56
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<div class="table_container">
|
2
|
+
<table>
|
3
|
+
<tr>
|
4
|
+
<% if show_class %>
|
5
|
+
<th>Class</th>
|
6
|
+
<% end %>
|
7
|
+
<th>Started</th>
|
8
|
+
<th>Duration</th>
|
9
|
+
<th>Parameters</th>
|
10
|
+
<th>Error</th>
|
11
|
+
</tr>
|
12
|
+
<% jobs.each do |job_details| %>
|
13
|
+
<tr<%= job_details.succeeded? ? "" : " class=\"job_history_error\"" %>>
|
14
|
+
<% if show_class %>
|
15
|
+
<td>
|
16
|
+
<a href="<%= u("job history/job_class_details") %>?<%=
|
17
|
+
{ class_name: job_details.class_name }.to_param %>">
|
18
|
+
<%= job_details.class_name %>
|
19
|
+
</a>
|
20
|
+
</td>
|
21
|
+
<% end %>
|
22
|
+
<td>
|
23
|
+
<a href="<%= u("job history/job_details") %>?class_name=<%=
|
24
|
+
job_details.class_name %>&job_id=<%= job_details.job_id %>">
|
25
|
+
<% if job_details.start_time %>
|
26
|
+
<%= time_ago_in_words(job_details.start_time) %> ago
|
27
|
+
(<%= job_details.start_time %>)
|
28
|
+
<% else %>
|
29
|
+
Error - missing start time
|
30
|
+
<% end %>
|
31
|
+
</a>
|
32
|
+
</td>
|
33
|
+
<td>
|
34
|
+
<% if job_details.start_time %>
|
35
|
+
<%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
|
36
|
+
<% if job_details.finished? %>
|
37
|
+
(<%= job_details.end_time %>)
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</td>
|
41
|
+
<td>
|
42
|
+
<pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
|
43
|
+
</td>
|
44
|
+
<td>
|
45
|
+
<%= job_details.error %>
|
46
|
+
</td>
|
47
|
+
</tr>
|
48
|
+
<% end %>
|
49
|
+
</table>
|
50
|
+
</div>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<% summary_rows.each do |class_info| %>
|
2
|
+
<tr<%= class_info.last_run && !class_info.last_run.succeeded? ? " class=\"job_history_error\"" : "" %>>
|
3
|
+
<td>
|
4
|
+
<a href="<%= u("job history") %>/job_class_details?class_name=<%= class_info.class_name %>">
|
5
|
+
<%= class_info.class_name %>
|
6
|
+
</a>
|
7
|
+
</td>
|
8
|
+
<td>
|
9
|
+
<%= class_info.num_running_jobs.to_i %>
|
10
|
+
</td>
|
11
|
+
<td>
|
12
|
+
<%= class_info.total_run_jobs.to_i %>
|
13
|
+
</td>
|
14
|
+
<td>
|
15
|
+
<%= class_info.total_finished_jobs.to_i %>
|
16
|
+
</td>
|
17
|
+
<td>
|
18
|
+
<%= class_info.total_failed_jobs.to_i %>
|
19
|
+
</td>
|
20
|
+
<td>
|
21
|
+
<% if class_info.last_run && class_info.last_run.start_time %>
|
22
|
+
<%= time_ago_in_words(class_info.last_run.start_time) %> ago
|
23
|
+
(<%= class_info.last_run.start_time %>)
|
24
|
+
<% end %>
|
25
|
+
</td>
|
26
|
+
<td>
|
27
|
+
<% if class_info.last_run %>
|
28
|
+
<% if class_info.last_run.finished? %>
|
29
|
+
<%= distance_of_time_in_words(class_info.last_run.start_time, class_info.last_run.end_time) %>
|
30
|
+
(<%= class_info.last_run.end_time %>)
|
31
|
+
<% else %>
|
32
|
+
Still running...
|
33
|
+
<% end %>
|
34
|
+
<% end %>
|
35
|
+
</td>
|
36
|
+
<td>
|
37
|
+
<% if class_info.last_run && !class_info.last_run.succeeded? %>
|
38
|
+
No
|
39
|
+
<% else %>
|
40
|
+
Yes
|
41
|
+
<% end %>
|
42
|
+
</td>
|
43
|
+
</tr>
|
44
|
+
<% end %>
|
@@ -12,45 +12,8 @@
|
|
12
12
|
secondary_page_num: secondary_page_num,
|
13
13
|
secondary_page_size: secondary_page_size }) %>
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
<tr>
|
18
|
-
<th>Started</th>
|
19
|
-
<th>Duration</th>
|
20
|
-
<th>Parameters</th>
|
21
|
-
<th>Error</th>
|
22
|
-
</tr>
|
23
|
-
<% jobs.each do |job_details| %>
|
24
|
-
<tr<%= job_details.succeeded? ? "" : " class=\"job_history_error\"" %>>
|
25
|
-
<td>
|
26
|
-
<a href="<%= u("job history/job_details") %>?class_name=<%=
|
27
|
-
job_details.class_name %>&job_id=<%= job_details.job_id %>">
|
28
|
-
<% if job_details.start_time %>
|
29
|
-
<%= time_ago_in_words(job_details.start_time) %> ago
|
30
|
-
(<%= job_details.start_time %>)
|
31
|
-
<% else %>
|
32
|
-
Error - missing start time
|
33
|
-
<% end %>
|
34
|
-
</a>
|
35
|
-
</td>
|
36
|
-
<td>
|
37
|
-
<% if job_details.start_time %>
|
38
|
-
<%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
|
39
|
-
<% if job_details.finished? %>
|
40
|
-
(<%= job_details.end_time %>)
|
41
|
-
<% end %>
|
42
|
-
<% end %>
|
43
|
-
</td>
|
44
|
-
<td>
|
45
|
-
<pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
|
46
|
-
</td>
|
47
|
-
<td>
|
48
|
-
<%= job_details.error %>
|
49
|
-
</td>
|
50
|
-
</tr>
|
51
|
-
<% end %>
|
52
|
-
</table>
|
53
|
-
</div>
|
15
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_list_table.erb")),
|
16
|
+
locals: { jobs: jobs, show_class: false }) %>
|
54
17
|
|
55
18
|
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_pagination.erb")),
|
56
19
|
locals: { history_list: history_list,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div id="job_history_search_div">
|
2
|
+
<form method="POST" action="<%= u("job history/#{job_search.search_type}") %>">
|
3
|
+
<% job_search.retry_search_settings(false).each do |setting_name, setting_value| %>
|
4
|
+
<input type="hidden" name="<%= setting_name %>" value="<%= setting_value %>"/>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<input type="checkbox" name="regex_search" <%= job_search.regex_search ? "checked" : "" %> value="true"/>
|
8
|
+
Regex
|
9
|
+
<input type="checkbox" name="case_insensitive" <%= job_search.case_insensitive ? "checked" : "" %> value="true"/>
|
10
|
+
Case Insensitive
|
11
|
+
<input type="text" size="50" name="search_for" value="<%= job_search.search_for %>"/>
|
12
|
+
<input type="submit" value="Search"/>
|
13
|
+
</form>
|
14
|
+
</div>
|
@@ -6,11 +6,19 @@
|
|
6
6
|
<% history = Resque::Plugins::JobHistory::HistoryDetails.new(@job_class_name) %>
|
7
7
|
<% class_info = job_list.job_details(@job_class_name) %>
|
8
8
|
|
9
|
-
<
|
10
|
-
<
|
11
|
-
|
12
|
-
|
13
|
-
</
|
9
|
+
<div>
|
10
|
+
<div class="job_history_linear_history_div">
|
11
|
+
<a href="<%= u("job history") %>">
|
12
|
+
Job History
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<% job_search = Resque::Plugins::JobHistory::JobSearch.
|
17
|
+
new(search_type: "search_job", job_class_name: @job_class_name) %>
|
18
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_search_form.erb")),
|
19
|
+
locals: { job_search: job_search }) %>
|
20
|
+
</div>
|
21
|
+
<div class="job_history_reset"/>
|
14
22
|
|
15
23
|
<div class="table_container">
|
16
24
|
<table>
|
@@ -106,10 +114,15 @@
|
|
106
114
|
<br/>
|
107
115
|
|
108
116
|
<% if Resque::Plugins::JobHistory::Cleaner.similar_name?(@job_class_name) %>
|
109
|
-
|
110
|
-
|
117
|
+
<div>
|
118
|
+
<p>
|
119
|
+
This class cannot be purged because of another class with a similar name. The other class must
|
120
|
+
be purged before this one can be safely purged.
|
121
|
+
</p>
|
122
|
+
</div>
|
111
123
|
<% else %>
|
112
124
|
<form method="POST" action="<%= u("job history/purge_class") %>?<%= { class_name: @job_class_name }.to_param %>">
|
113
125
|
<input type="submit" name="" value="Purge all histories for <%= @job_class_name %>"/>
|
114
126
|
</form>
|
115
127
|
<% end %>
|
128
|
+
<div class="job_history_reset"/>
|
@@ -4,11 +4,19 @@
|
|
4
4
|
|
5
5
|
<% job_list = Resque::Plugins::JobHistory::JobList.new %>
|
6
6
|
|
7
|
-
<
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
</
|
7
|
+
<div>
|
8
|
+
<div class="job_history_linear_history_div">
|
9
|
+
<a href="<%= u("job history/linear_history") %>">
|
10
|
+
Linear History
|
11
|
+
</a>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<% job_search = Resque::Plugins::JobHistory::JobSearch.
|
15
|
+
new(search_type: "search_all") %>
|
16
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_search_form.erb")),
|
17
|
+
locals: { job_search: job_search }) %>
|
18
|
+
</div>
|
19
|
+
<div class="job_history_reset" />
|
12
20
|
|
13
21
|
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_class_pagination.erb")),
|
14
22
|
locals: { job_list: job_list, page_num: @page_num, page_size: @page_size }) %>
|
@@ -82,50 +90,8 @@
|
|
82
90
|
</a></th>
|
83
91
|
</tr>
|
84
92
|
|
85
|
-
|
86
|
-
|
87
|
-
<td>
|
88
|
-
<a href="<%= u("job history") %>/job_class_details?class_name=<%= class_info.class_name %>">
|
89
|
-
<%= class_info.class_name %>
|
90
|
-
</a>
|
91
|
-
</td>
|
92
|
-
<td>
|
93
|
-
<%= class_info.num_running_jobs.to_i %>
|
94
|
-
</td>
|
95
|
-
<td>
|
96
|
-
<%= class_info.total_run_jobs.to_i %>
|
97
|
-
</td>
|
98
|
-
<td>
|
99
|
-
<%= class_info.total_finished_jobs.to_i %>
|
100
|
-
</td>
|
101
|
-
<td>
|
102
|
-
<%= class_info.total_failed_jobs.to_i %>
|
103
|
-
</td>
|
104
|
-
<td>
|
105
|
-
<% if class_info.last_run && class_info.last_run.start_time %>
|
106
|
-
<%= time_ago_in_words(class_info.last_run.start_time) %> ago
|
107
|
-
(<%= class_info.last_run.start_time %>)
|
108
|
-
<% end %>
|
109
|
-
</td>
|
110
|
-
<td>
|
111
|
-
<% if class_info.last_run %>
|
112
|
-
<% if class_info.last_run.finished? %>
|
113
|
-
<%= distance_of_time_in_words(class_info.last_run.start_time, class_info.last_run.end_time) %>
|
114
|
-
(<%= class_info.last_run.end_time %>)
|
115
|
-
<% else %>
|
116
|
-
Still running...
|
117
|
-
<% end %>
|
118
|
-
<% end %>
|
119
|
-
</td>
|
120
|
-
<td>
|
121
|
-
<% if class_info.last_run && !class_info.last_run.succeeded? %>
|
122
|
-
No
|
123
|
-
<% else %>
|
124
|
-
Yes
|
125
|
-
<% end %>
|
126
|
-
</td>
|
127
|
-
</tr>
|
128
|
-
<% end %>
|
93
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_summary_rows.erb")),
|
94
|
+
locals: { summary_rows: job_list.job_summaries(@sort_by, @sort_order, @page_num, @page_size) }) %>
|
129
95
|
</table>
|
130
96
|
</div>
|
131
97
|
|
@@ -139,3 +105,4 @@
|
|
139
105
|
<input type="submit" name="" value="Purge all histories"/>
|
140
106
|
</form>
|
141
107
|
</div>
|
108
|
+
<div class="job_history_reset"/>
|
@@ -2,11 +2,19 @@
|
|
2
2
|
|
3
3
|
<h1>Linear History</h1>
|
4
4
|
|
5
|
-
<
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
</
|
5
|
+
<div>
|
6
|
+
<div class="job_history_linear_history_div">
|
7
|
+
<a href="<%= u("job history") %>">
|
8
|
+
Job History
|
9
|
+
</a>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<% job_search = Resque::Plugins::JobHistory::JobSearch.
|
13
|
+
new(search_type: "search_linear_history") %>
|
14
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_search_form.erb")),
|
15
|
+
locals: { job_search: job_search }) %>
|
16
|
+
</div>
|
17
|
+
<div class="job_history_reset" />
|
10
18
|
|
11
19
|
<% linear_history = Resque::Plugins::JobHistory::JobList.new.linear_jobs %>
|
12
20
|
|
@@ -17,47 +25,8 @@
|
|
17
25
|
page_num: @page_num,
|
18
26
|
page_size: @page_size }) %>
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
<tr>
|
23
|
-
<th>Class</th>
|
24
|
-
<th>Started</th>
|
25
|
-
<th>Duration</th>
|
26
|
-
<th>Parameters</th>
|
27
|
-
<th>Error</th>
|
28
|
-
</tr>
|
29
|
-
<% jobs.each do |job_details| %>
|
30
|
-
<tr<%= job_details.succeeded? ? "" : " class=\"job_history_error\"" %>>
|
31
|
-
<td>
|
32
|
-
<a href="<%= u("job history/job_details") %>?<%=
|
33
|
-
{ class_name: job_details.class_name, job_id: job_details.job_id }.to_param %>">
|
34
|
-
<%= job_details.class_name %>
|
35
|
-
</a>
|
36
|
-
</td>
|
37
|
-
<td>
|
38
|
-
<% if job_details.start_time %>
|
39
|
-
<%= time_ago_in_words(job_details.start_time) %> ago
|
40
|
-
(<%= job_details.start_time %>)
|
41
|
-
<% else %>
|
42
|
-
Error - missing start time
|
43
|
-
<% end %>
|
44
|
-
</td>
|
45
|
-
<td>
|
46
|
-
<%= distance_of_time_in_words(job_details.start_time, (job_details.end_time || Time.now)) %>
|
47
|
-
<% if job_details.finished? %>
|
48
|
-
(<%= job_details.end_time %>)
|
49
|
-
<% end %>
|
50
|
-
</td>
|
51
|
-
<td>
|
52
|
-
<pre><code><%= "".html_safe + job_details.args.to_yaml %></code></pre>
|
53
|
-
</td>
|
54
|
-
<td>
|
55
|
-
<%= job_details.error %>
|
56
|
-
</td>
|
57
|
-
</tr>
|
58
|
-
<% end %>
|
59
|
-
</table>
|
60
|
-
</div>
|
28
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_list_table.erb")),
|
29
|
+
locals: { jobs: jobs, show_class: true }) %>
|
61
30
|
|
62
31
|
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_linear_pagination.erb")),
|
63
32
|
locals: { linear_history: linear_history,
|
@@ -72,3 +41,4 @@
|
|
72
41
|
<input type="submit" name="" value="Purge linear histories"/>
|
73
42
|
</form>
|
74
43
|
</div>
|
44
|
+
<div class="job_history_reset"/>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<link href="<%= u("job_history/public/job_history.css") %>" media="screen" rel="stylesheet" type="text/css">
|
2
|
+
|
3
|
+
<h1>Search Results</h1>
|
4
|
+
|
5
|
+
<div>
|
6
|
+
<div class="job_history_linear_history_div">
|
7
|
+
<a href="<%= u("job history") %>">
|
8
|
+
Job History
|
9
|
+
</a>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_search_form.erb")),
|
13
|
+
locals: { job_search: @job_search }) %>
|
14
|
+
</div>
|
15
|
+
<div class="job_history_reset"/>
|
16
|
+
|
17
|
+
<% if @job_search.more_records? %>
|
18
|
+
<div>
|
19
|
+
<p>
|
20
|
+
The search took too long and was stopped. You can continue the search from the point it was
|
21
|
+
stopped at <a href="#continue_search">below</a>.
|
22
|
+
</p>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% if @job_search.class_results.blank? && @job_search.run_results.blank? %>
|
27
|
+
<div>
|
28
|
+
<p>
|
29
|
+
No results were found.
|
30
|
+
</p>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% if @job_search.class_results.present? %>
|
35
|
+
<div class="table_container">
|
36
|
+
<table>
|
37
|
+
<tr>
|
38
|
+
<th>Class name</th>
|
39
|
+
<th>Running</th>
|
40
|
+
<th>Total Run</th>
|
41
|
+
<th>Finished</th>
|
42
|
+
<th>Failed</th>
|
43
|
+
<th>Last Run Start</th>
|
44
|
+
<th>Last Run Duration</th>
|
45
|
+
<th>Last Run successful</th>
|
46
|
+
</tr>
|
47
|
+
|
48
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_summary_rows.erb")),
|
49
|
+
locals: { summary_rows: @job_search.class_results }) %>
|
50
|
+
</table>
|
51
|
+
</div>
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<% if @job_search.run_results.present? %>
|
55
|
+
<%= erb(File.read(Resque::JobHistoryServer.erb_path("_job_list_table.erb")),
|
56
|
+
locals: { jobs: @job_search.run_results, show_class: true }) %>
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<% if @job_search.more_records? %>
|
60
|
+
<form id="continue_search" method="POST" action="<%= u("job history/#{@job_search.search_type}") %>">
|
61
|
+
<% @job_search.search_settings(true).each do |setting_name, setting_value| %>
|
62
|
+
<input type="hidden" name="<%= setting_name %>" value="<%= setting_value %>"/>
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
<input type="submit" value="Continue Search"/>
|
66
|
+
</form>
|
67
|
+
<% end %>
|
68
|
+
<div class="job_history_reset"/>
|
data/lib/resque-job_history.rb
CHANGED
@@ -7,4 +7,5 @@ require File.expand_path(File.join("resque", "plugins", "job_history", "history_
|
|
7
7
|
require File.expand_path(File.join("resque", "plugins", "job_history", "job_list"), File.dirname(__FILE__))
|
8
8
|
require File.expand_path(File.join("resque", "plugins", "job_history", "job"), File.dirname(__FILE__))
|
9
9
|
require File.expand_path(File.join("resque", "plugins", "job_history", "cleaner"), File.dirname(__FILE__))
|
10
|
+
require File.expand_path(File.join("resque", "plugins", "job_history", "job_search"), File.dirname(__FILE__))
|
10
11
|
require File.expand_path(File.join("resque", "plugins", "job_history"), File.dirname(__FILE__))
|
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
|
+
version: 0.0.11
|
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
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resque
|
@@ -195,16 +195,21 @@ files:
|
|
195
195
|
- lib/resque/plugins/job_history/history_list.rb
|
196
196
|
- lib/resque/plugins/job_history/job.rb
|
197
197
|
- lib/resque/plugins/job_history/job_list.rb
|
198
|
+
- lib/resque/plugins/job_history/job_search.rb
|
198
199
|
- lib/resque/plugins/version.rb
|
199
200
|
- lib/resque/server/public/job_history.css
|
200
201
|
- lib/resque/server/views/_job_class_pagination.erb
|
202
|
+
- lib/resque/server/views/_job_list_table.erb
|
201
203
|
- lib/resque/server/views/_job_pagination.erb
|
204
|
+
- lib/resque/server/views/_job_summary_rows.erb
|
202
205
|
- lib/resque/server/views/_jobs_list.erb
|
203
206
|
- lib/resque/server/views/_linear_pagination.erb
|
207
|
+
- lib/resque/server/views/_search_form.erb
|
204
208
|
- lib/resque/server/views/job_class_details.erb
|
205
209
|
- lib/resque/server/views/job_details.erb
|
206
210
|
- lib/resque/server/views/job_history.erb
|
207
211
|
- lib/resque/server/views/linear_history.erb
|
212
|
+
- lib/resque/server/views/search_results.erb
|
208
213
|
- lib/tasks/resque-job_history_tasks.rake
|
209
214
|
homepage: https://github.com/RealNobody
|
210
215
|
licenses:
|