changed
hex_metadata.config
|
@@ -687,9 687,9 @@
|
687
687
|
<<"priv/ember/bower_components/bootswatch-scss/yeti">>,
|
688
688
|
<<"priv/ember/bower_components/bootswatch-scss/yeti/_variables.scss">>,
|
689
689
|
<<"priv/ember/bower_components/bootswatch-scss/yeti/_bootswatch.scss">>,
|
690
|
- <<"priv/ember/.tool-versions">>,<<"priv/ember/tests">>,
|
691
|
- <<"priv/ember/tests/unit">>,<<"priv/ember/tests/unit/.gitkeep">>,
|
692
|
- <<"priv/ember/tests/index.html">>,<<"priv/ember/tests/integration">>,
|
690
|
<<"priv/ember/tests">>,<<"priv/ember/tests/unit">>,
|
691
|
<<"priv/ember/tests/unit/.gitkeep">>,<<"priv/ember/tests/index.html">>,
|
692
|
<<"priv/ember/tests/integration">>,
|
693
693
|
<<"priv/ember/tests/integration/.gitkeep">>,
|
694
694
|
<<"priv/ember/tests/test-helper.js">>,<<"priv/ember/tests/.eslintrc.js">>,
|
695
695
|
<<"priv/ember/tests/helpers">>,
|
|
@@ -734,4 734,4 @@
|
734
734
|
{<<"optional">>,false},
|
735
735
|
{<<"repository">>,<<"hexpm">>},
|
736
736
|
{<<"requirement">>,<<"~> 2.4">>}]]}.
|
737
|
- {<<"version">>,<<"0.12.0">>}.
|
737
|
{<<"version">>,<<"0.12.1">>}.
|
changed
mix.exs
|
@@ -3,7 3,7 @@ defmodule ExqUi.Mixfile do
|
3
3
|
|
4
4
|
def project do
|
5
5
|
[ app: :gh_exq_ui,
|
6
|
- version: "0.12.0",
|
6
|
version: "0.12.1",
|
7
7
|
elixir: "~> 1.3",
|
8
8
|
elixirc_paths: ["lib", "web"],
|
9
9
|
package: [
|
removed
priv/ember/.tool-versions
|
@@ -1 0,0 @@
|
1
|
- nodejs 11.12.0
|
unknown
priv/ember/dist/assets/vendor.js
CANNOT RENDER FILES LARGER THAN 1MB
unknown
priv/ember/dist/assets/vendor.map
CANNOT RENDER FILES LARGER THAN 1MB
unknown
priv/static/assets/vendor.js
CANNOT RENDER FILES LARGER THAN 1MB
unknown
priv/static/assets/vendor.map
CANNOT RENDER FILES LARGER THAN 1MB
changed
web/router.ex
|
@@ -10,6 10,7 @@ defmodule ExqUi.RouterPlug do
|
10
10
|
else
|
11
11
|
[name: Exq.Api.Server.server_name(ExqUi)]
|
12
12
|
end
|
13
|
|
13
14
|
Keyword.put(options, :exq_opts, enq_opts)
|
14
15
|
end
|
15
16
|
|
|
@@ -17,9 18,11 @@ defmodule ExqUi.RouterPlug do
|
17
18
|
namespace_opt = opts[:namespace] || "exq"
|
18
19
|
conn = Plug.Conn.assign(conn, :namespace, namespace_opt)
|
19
20
|
conn = Plug.Conn.assign(conn, :exq_name, opts[:exq_opts][:name])
|
21
|
|
20
22
|
case namespace_opt do
|
21
23
|
"" ->
|
22
24
|
Router.call(conn, Router.init(opts))
|
25
|
|
23
26
|
_ ->
|
24
27
|
namespace(conn, opts, namespace_opt)
|
25
28
|
end
|
|
@@ -35,11 38,11 @@ defmodule ExqUi.RouterPlug do
|
35
38
|
import Plug.Conn
|
36
39
|
use Plug.Router
|
37
40
|
|
38
|
- plug Plug.Static, at: "/", from: :gh_exq_ui
|
39
|
- plug ExqUi.JsonApi, on: "api"
|
41
|
plug(Plug.Static, at: "/", from: :gh_exq_ui)
|
42
|
plug(ExqUi.JsonApi, on: "api")
|
40
43
|
|
41
|
- plug :match
|
42
|
- plug :dispatch
|
44
|
plug(:match)
|
45
|
plug(:dispatch)
|
43
46
|
|
44
47
|
get "/api/stats/all" do
|
45
48
|
{:ok, processed} = Exq.Api.stats(conn.assigns[:exq_name], "processed")
|
|
@@ -51,26 54,43 @@ defmodule ExqUi.RouterPlug do
|
51
54
|
|
52
55
|
{:ok, queues} = Exq.Api.queue_size(conn.assigns[:exq_name])
|
53
56
|
|
54
|
- queue_sizes = for {_q, size} <- queues do
|
55
|
- size
|
56
|
- end
|
57
|
queue_sizes =
|
58
|
for {_q, size} <- queues do
|
59
|
size
|
60
|
end
|
61
|
|
57
62
|
qtotal = "#{Enum.sum(queue_sizes)}"
|
58
63
|
|
59
|
- {:ok, json} = Poison.encode(%{stat: %{id: "all", processed: processed || 0, failed: failed || 0,
|
60
|
- busy: busy || 0, scheduled: scheduled || 0, dead: dead || 0, retrying: retrying || 0, enqueued: qtotal}})
|
64
|
{:ok, json} =
|
65
|
Poison.encode(%{
|
66
|
stat: %{
|
67
|
id: "all",
|
68
|
processed: processed || 0,
|
69
|
failed: failed || 0,
|
70
|
busy: busy || 0,
|
71
|
scheduled: scheduled || 0,
|
72
|
dead: dead || 0,
|
73
|
retrying: retrying || 0,
|
74
|
enqueued: qtotal
|
75
|
}
|
76
|
})
|
77
|
|
61
78
|
conn |> send_resp(200, json) |> halt
|
62
79
|
end
|
63
80
|
|
64
81
|
get "/api/realtimes" do
|
65
82
|
{:ok, failures, successes} = Exq.Api.realtime_stats(conn.assigns[:exq_name])
|
66
83
|
|
67
|
- f = for {date, count} <- failures do
|
68
|
- %{id: "f#{date}", timestamp: date, count: count}
|
69
|
- end
|
84
|
f =
|
85
|
for {date, count} <- failures do
|
86
|
%{id: "f#{date}", timestamp: date, count: count}
|
87
|
end
|
88
|
|
89
|
s =
|
90
|
for {date, count} <- successes do
|
91
|
%{id: "s#{date}", timestamp: date, count: count}
|
92
|
end
|
70
93
|
|
71
|
- s = for {date, count} <- successes do
|
72
|
- %{id: "s#{date}", timestamp: date, count: count}
|
73
|
- end
|
74
94
|
all = %{realtimes: f s}
|
75
95
|
|
76
96
|
{:ok, json} = Poison.encode(all)
|
|
@@ -79,7 99,7 @@ defmodule ExqUi.RouterPlug do
|
79
99
|
|
80
100
|
get "/api/scheduled" do
|
81
101
|
{:ok, jobs} = Exq.Api.scheduled_with_scores(conn.assigns[:exq_name])
|
82
|
- {:ok, json} = Poison.encode(%{scheduled: map_score_to_jobs(jobs) })
|
102
|
{:ok, json} = Poison.encode(%{scheduled: map_score_to_jobs(jobs)})
|
83
103
|
conn |> send_resp(200, json) |> halt
|
84
104
|
end
|
85
105
|
|
|
@@ -180,8 200,14 @@ defmodule ExqUi.RouterPlug do
|
180
200
|
get "/api/queues/:id" do
|
181
201
|
{:ok, jobs} = Exq.Api.jobs(conn.assigns[:exq_name], id)
|
182
202
|
jobs_structs = map_jid_to_id(jobs)
|
183
|
- job_ids = for j <- jobs_structs, do: j[:id]
|
184
|
- {:ok, json} = Poison.encode(%{queue: %{id: id, job_ids: job_ids, partial: false}, jobs: map_jid_to_id(jobs)})
|
203
|
job_ids = for j <- jobs_structs, do: Map.get(j, :id)
|
204
|
|
205
|
{:ok, json} =
|
206
|
Poison.encode(%{
|
207
|
queue: %{id: id, job_ids: job_ids, partial: false},
|
208
|
jobs: map_jid_to_id(jobs)
|
209
|
})
|
210
|
|
185
211
|
conn |> send_resp(200, json) |> halt
|
186
212
|
end
|
187
213
|
|
|
@@ -197,18 223,19 @@ defmodule ExqUi.RouterPlug do
|
197
223
|
|
198
224
|
# precompile index.html into render_index/1 function
|
199
225
|
index_path = Path.join([Application.app_dir(:gh_exq_ui), "priv/static/index.html"])
|
200
|
- EEx.function_from_file :defp, :render_index, index_path, [:assigns]
|
226
|
EEx.function_from_file(:defp, :render_index, index_path, [:assigns])
|
201
227
|
|
202
228
|
match _ do
|
203
|
- base = case conn.assigns[:namespace] do
|
204
|
- "" -> ""
|
205
|
- namespace -> "#{namespace}/"
|
206
|
- end
|
229
|
base =
|
230
|
case conn.assigns[:namespace] do
|
231
|
"" -> ""
|
232
|
namespace -> "#{namespace}/"
|
233
|
end
|
207
234
|
|
208
235
|
conn
|
209
|
- |> put_resp_header("content-type", "text/html")
|
210
|
- |> send_resp(200, render_index(base: base))
|
211
|
- |> halt
|
236
|
|> put_resp_header("content-type", "text/html")
|
237
|
|> send_resp(200, render_index(base: base))
|
238
|
|> halt
|
212
239
|
end
|
213
240
|
|
214
241
|
def map_jid_to_id(jobs) when is_list(jobs) do
|
|
@@ -216,13 243,21 @@ defmodule ExqUi.RouterPlug do
|
216
243
|
map_jid_to_id(job)
|
217
244
|
end
|
218
245
|
end
|
219
|
- def map_jid_to_id(job), do: Map.put(job, :id, job.jid)
|
246
|
|
247
|
def map_jid_to_id(job) do
|
248
|
Map.merge(job, %{
|
249
|
id: job.jid,
|
250
|
args: safe_json_encode(job.args),
|
251
|
enqueued_at: safe_time_convert(job.enqueued_at)
|
252
|
})
|
253
|
end
|
220
254
|
|
221
255
|
def convert_results_to_times(jobs, score_key) when is_list(jobs) do
|
222
256
|
for job <- jobs do
|
223
257
|
convert_results_to_times(job, score_key)
|
224
258
|
end
|
225
259
|
end
|
260
|
|
226
261
|
def convert_results_to_times(job, score_key) do
|
227
262
|
Map.put(job, score_key, score_to_time(Map.get(job, score_key)))
|
228
263
|
end
|
|
@@ -230,7 265,7 @@ defmodule ExqUi.RouterPlug do
|
230
265
|
def score_to_time(score) when is_float(score) do
|
231
266
|
round(score * 1_000_000)
|
232
267
|
|> DateTime.from_unix!(:microseconds)
|
233
|
- |> DateTime.to_iso8601
|
268
|
|> DateTime.to_iso8601()
|
234
269
|
end
|
235
270
|
|
236
271
|
def score_to_time(score) do
|
|
@@ -238,8 273,8 @@ defmodule ExqUi.RouterPlug do
|
238
273
|
score_to_time(String.to_float(score))
|
239
274
|
else
|
240
275
|
String.to_integer(score)
|
241
|
- |> DateTime.from_unix!
|
242
|
- |> DateTime.to_iso8601
|
276
|
|> DateTime.from_unix!()
|
277
|
|> DateTime.to_iso8601()
|
243
278
|
end
|
244
279
|
end
|
245
280
|
|
|
@@ -261,5 296,11 @@ defmodule ExqUi.RouterPlug do
|
261
296
|
rescue
|
262
297
|
_ -> data
|
263
298
|
end
|
299
|
|
300
|
def safe_time_convert(data) do
|
301
|
data |> trunc() |> Timex.from_unix()
|
302
|
rescue
|
303
|
_ -> data
|
304
|
end
|
264
305
|
end
|
265
306
|
end
|