canvas_sync 0.5.3 → 0.5.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
  SHA256:
3
- metadata.gz: 6f87da8705444b3e03423c2a54955af9b716b7b24b895e9f90c0ff8172ebe2c2
4
- data.tar.gz: f2ce4110f41ec088b08cb0bab4ad90f2abc1e4559e3e5a120f6d8b8d9d5b8b99
3
+ metadata.gz: d468a322b8cc5edf0f4ead573a98f9919f3b7158add284a65e7286be41f9bcf1
4
+ data.tar.gz: 773ebf5c8fa9bb84d60031879ccf4a706344d1c19fcca582eaccf3158334cd37
5
5
  SHA512:
6
- metadata.gz: 3e564a94d2f9bcaeb2b5a9a8a38702281ac0f1f768ca7d7a1059b194b07e8009650c51c4985fef472ac1697823cf0069f185eace2b706722de8b76312ee59cba
7
- data.tar.gz: 8b6bc602f1b40f6599f1327f8ec17119f6debbcf0f6aa82627db4a603267a2935a5538e23a5bacbbfe4b56e0631dc5b9597814d595bacad29c0dd08b02070428
6
+ metadata.gz: ac310fcd40284364f21ce10df7115ed04dbab603c5d1d773c1809da5db1b29d72f34e06c3645f6b33b3ac7db9648adeb677059033d10c0d9314c69e234a2129e
7
+ data.tar.gz: 400fbc6c753365b2900802d8b5b6466ccf62a5c9bf96a5857887567361eebda835bf4489f88c66b3db287514752963d914509c8160eff2e97e49fca913e7b80f
data/README.md CHANGED
@@ -219,6 +219,16 @@ If you want your own jobs to also log to the table all you have to do is have yo
219
219
  @job_log.save!
220
220
  ```
221
221
 
222
+ If you want to be able to utilize the `CanvasSync::JobLog` without `ActiveJob` (so you can get access to `Sidekiq` features that `ActiveJob` doesn't support), then add the following to an initializer in your Rails app:
223
+
224
+ ```
225
+ Sidekiq.configure_server do |config|
226
+ config.server_middleware do |chain|
227
+ chain.add CanvasSync::Sidekiq::Middleware
228
+ end
229
+ end
230
+ ```
231
+
222
232
  ## Upgrading
223
233
 
224
234
  Re-running the generator when there's been a gem change will give you several choices if it detects conflicts between your local files and the updated generators. You can either view a diff or allow the generator to overwrite your local file. In most cases you may just want to add the code from the diff yourself so as not to break any of your customizations.
@@ -2,6 +2,7 @@ require "bearcat"
2
2
  require "canvas_sync/version"
3
3
  require "canvas_sync/engine"
4
4
  require "canvas_sync/job"
5
+ require "canvas_sync/sidekiq_job"
5
6
  require "canvas_sync/jobs/report_starter"
6
7
  require "canvas_sync/jobs/report_checker"
7
8
  require "canvas_sync/jobs/report_processor_job"
@@ -0,0 +1,32 @@
1
+ module CanvasSync
2
+ module Sidekiq
3
+ class Middleware
4
+ def call(worker, job, queue)
5
+ begin
6
+ job_log = CanvasSync::JobLog.create(
7
+ job_class: worker.class.to_s,
8
+ job_arguments: job["args"],
9
+ job_id: job["jid"],
10
+ status: JobLog::RUNNING_STATUS,
11
+ started_at: Time.now
12
+ )
13
+
14
+ yield
15
+ job_log.status = JobLog::SUCCESS_STATUS
16
+ rescue => e
17
+ job_log.exception = "#{e.class}: #{e.message}"
18
+ job_log.backtrace = e.backtrace
19
+ job_log.status = JobLog::ERROR_STATUS
20
+ raise e
21
+ ensure
22
+ if job_log.job_class == "CanvasSync::Jobs::ReportChecker" && job_log.status != JobLog::ERROR_STATUS
23
+ job_log.destroy
24
+ else
25
+ job_log.completed_at = Time.now
26
+ job_log.save!
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.5.3".freeze
2
+ VERSION = "0.5.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -401,6 +401,7 @@ files:
401
401
  - lib/canvas_sync/processors/provisioning_report_processor.rb
402
402
  - lib/canvas_sync/processors/report_processor.rb
403
403
  - lib/canvas_sync/processors/submissions_processor.rb
404
+ - lib/canvas_sync/sidekiq_job.rb
404
405
  - lib/canvas_sync/version.rb
405
406
  - spec/canvas_sync/canvas_sync_spec.rb
406
407
  - spec/canvas_sync/jobs/job_spec.rb