sidekiq-scheduler-manager 0.2.0 → 0.2.1

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: ad9cc500821a93dd288e324f4939e38588ced20e
4
- data.tar.gz: 6232caca519845c221d46961461fbcceef871a03
3
+ metadata.gz: 09ed7b7fda3248c577ed15c12385d4719ada2025
4
+ data.tar.gz: 154e509a45c26d5249b16baaed2826e7070fd362
5
5
  SHA512:
6
- metadata.gz: b40840c159f65c40a4eadcda5f09001218012a50b6a75df53b5ec088e415d1246ce71efccefc25f6d4be664c94ba673b6f55fbd669269c77d0cb1f4697082247
7
- data.tar.gz: cad9660e199ca48e3867353a6001d2b3bdae11964470ec212e5e0a5c954547c4e9c3c582412d6eeb97f58a5860f1ddbcc1801458579d858171183599b95dcfb5
6
+ metadata.gz: 4b84a9763544b9be365eb1eaa4151a0bdc540a95e12ede266cf368995350c21fd57c9a3f12bcc8918ae6ebf25c39f9f4aa4f8eb64176a7877341e50f7efae700
7
+ data.tar.gz: 1cf41c188a01439aa35ed5ed39ee18f56ec38493c9b444a6897f1df778c036e27798f7f6a29691dd536965aeed321aafe8ea39676e52a9bc0280e22f944714f3
@@ -1,3 +1,3 @@
1
1
  module SidekiqSchedulerManager
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -141,21 +141,20 @@ module SidekiqSchedulerManager
141
141
  end
142
142
 
143
143
  app.get '/schedulers/export' do
144
+ result = Array.new
144
145
  schedulers = Sidekiq.get_all_schedules
145
- hash={}
146
- schedulers.each do |key, value|
147
- hash[key] = value
146
+ schedulers.each do |scheduler|
147
+ result.push(scheduler)
148
148
  end
149
- File.open("scheduler_backup.json", "wb") { |file| file.puts JSON.pretty_generate(hash) }
150
-
151
- # send_data JSON.pretty_generate(hash), filename: "schedule.json", disposition: "attachment", :content_type => 'application/json'
152
- redirect "#{root_path}schedulers"
149
+ [200, { "Content-Type" => "application/octet-stream", "Content-Disposition" => "attachment", "filename" => "sidekiq_schedule.json" }, [JSON.pretty_generate(result)]]
153
150
  end
154
151
 
155
- app.get '/schedulers/import' do
156
- file = File.read('scheduler_backup.json')
157
- data_hash = JSON.parse(file)
152
+ app.post '/schedulers/import' do
153
+ # puts params
154
+ tmpfile = params[:file][:tempfile]
155
+ file = tmpfile.read
158
156
 
157
+ data_hash = JSON.parse(file)
159
158
  data_hash.each do |job_name, data|
160
159
  unless job_name.to_s.strip.empty?
161
160
  Sidekiq.set_schedule(job_name, data)
@@ -4,15 +4,17 @@
4
4
  <table class="table table-hover table-bordered table-striped table-white">
5
5
  <thead>
6
6
  <tr>
7
- <a class="btn btn-warn btn-xs" href="schedulers/new">
8
- <%= t('Create') %>
9
- </a>&nbsp;
10
- <a class="btn btn-warn btn-xs" href="schedulers/export">
11
- <%= t('Export') %>
12
- </a>&nbsp;
13
- <a class="btn btn-warn btn-xs" href="schedulers/import">
14
- <%= t('Import') %>
15
- </a>
7
+ <form action="<%= root_path %>schedulers/import" accept-charset="UTF-8" enctype="multipart/form-data" method="post">
8
+ <%= csrf_tag %>
9
+ <a class="btn" href="schedulers/new">
10
+ <%= t('Create') %>
11
+ </a>
12
+ <a class="btn" href="schedulers/export">
13
+ <%= t('Export') %>
14
+ </a>
15
+ <label for="file" class="btn">Import</label>
16
+ <input type="file" name="file" id="file" style="visibility:hidden;" onchange="this.form.submit()" />
17
+ </form>
16
18
  </tr>
17
19
  <tr>
18
20
  <th><%= t('name') %></th>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-scheduler-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - vudn-job
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler