joblin 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/joblin/background_task/executor.rb +11 -1
- data/lib/joblin/version.rb +1 -1
- data/spec/internal/log/test.log +2079 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 23c16a1c4a23f6ad9d6f254c0d0ee5aea54fa3e4501222c2e93ccf2bdf8f94b6
         | 
| 4 | 
            +
              data.tar.gz: 22785e30a3229741a3daa125c89f93ba17ab285f614d1e9546eeb491a5296ac3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: aa29ff4cb1af77eb546f1d5b0963c4b7b22145d067b991a82912bd8d071cbd8829e64b748d75c031d8c67d849ea7c36047a85b5fcd3d1e5454239b0593926f2d
         | 
| 7 | 
            +
              data.tar.gz: c08af787c49c3ecfba70c675534c26174de20e97c742952652696428aae5290b79fcbb6b63391504d02acc2ad413909e7d9aa721f05242cf571eb0f52cf93162
         | 
| @@ -3,6 +3,8 @@ module Joblin | |
| 3 3 | 
             
                module Executor
         | 
| 4 4 | 
             
                  extend ActiveSupport::Concern
         | 
| 5 5 |  | 
| 6 | 
            +
                  BACKGROUND_TASK_THREAD_KEY = :joblin_current_background_task
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
                  class_methods do
         | 
| 7 9 | 
             
                    def inherited(subclass)
         | 
| 8 10 | 
             
                      subclass.const_set(:ExecutorJob, Class.new(self::ExecutorJob))
         | 
| @@ -50,7 +52,7 @@ module Joblin | |
| 50 52 | 
             
                    # delegate :before_enqueue, :around_enqueue, :after_enqueue, to: :job_executor_class
         | 
| 51 53 |  | 
| 52 54 | 
             
                    def current
         | 
| 53 | 
            -
                      BackgroundTask.find( | 
| 55 | 
            +
                      Thread.current[BACKGROUND_TASK_THREAD_KEY] || BackgroundTask.find(Batch.current_context[:background_task_id])
         | 
| 54 56 | 
             
                    end
         | 
| 55 57 | 
             
                  end
         | 
| 56 58 |  | 
| @@ -65,6 +67,14 @@ module Joblin | |
| 65 67 | 
             
                  end
         | 
| 66 68 |  | 
| 67 69 | 
             
                  class ExecutorJob < ActiveJob::Base
         | 
| 70 | 
            +
                    around_perform do |job, block|
         | 
| 71 | 
            +
                      pretask = Thread.current[BACKGROUND_TASK_THREAD_KEY]
         | 
| 72 | 
            +
                      Thread.current[BACKGROUND_TASK_THREAD_KEY] = job.the_task
         | 
| 73 | 
            +
                      block.call
         | 
| 74 | 
            +
                    ensure
         | 
| 75 | 
            +
                      Thread.current[BACKGROUND_TASK_THREAD_KEY] = pretask
         | 
| 76 | 
            +
                    end
         | 
| 77 | 
            +
             | 
| 68 78 | 
             
                    def perform
         | 
| 69 79 | 
             
                      the_task.update(workflow_state: "started") if the_task.workflow_state == "scheduled"
         | 
| 70 80 | 
             
                      the_task.perform
         | 
    
        data/lib/joblin/version.rb
    CHANGED