joblin 0.1.5 → 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 +14 -0
- data/db/migrate/20250903184852_create_joblin_background_tasks.rb +1 -1
- data/db/migrate/20250916184852_add_results_to_joblin_background_tasks.rb +1 -1
- data/lib/joblin/misc_helper.rb +15 -0
- data/lib/joblin/version.rb +1 -1
- data/lib/joblin.rb +1 -0
- data/spec/internal/log/test.log +2771 -0
- metadata +2 -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))
         | 
| @@ -48,6 +50,10 @@ module Joblin | |
| 48 50 |  | 
| 49 51 | 
             
                    # delegate :before_perform, :around_perform, :after_perform, to: :job_executor_class
         | 
| 50 52 | 
             
                    # delegate :before_enqueue, :around_enqueue, :after_enqueue, to: :job_executor_class
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    def current
         | 
| 55 | 
            +
                      Thread.current[BACKGROUND_TASK_THREAD_KEY] || BackgroundTask.find(Batch.current_context[:background_task_id])
         | 
| 56 | 
            +
                    end
         | 
| 51 57 | 
             
                  end
         | 
| 52 58 |  | 
| 53 59 | 
             
                  included do
         | 
| @@ -61,6 +67,14 @@ module Joblin | |
| 61 67 | 
             
                  end
         | 
| 62 68 |  | 
| 63 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 | 
            +
             | 
| 64 78 | 
             
                    def perform
         | 
| 65 79 | 
             
                      the_task.update(workflow_state: "started") if the_task.workflow_state == "scheduled"
         | 
| 66 80 | 
             
                      the_task.perform
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            class AddResultsToJoblinBackgroundTasks <  | 
| 1 | 
            +
            class AddResultsToJoblinBackgroundTasks < Joblin::MiscHelper::MigrationClass
         | 
| 2 2 | 
             
              def change
         | 
| 3 3 | 
             
                add_column :joblin_background_tasks, :results, :jsonb
         | 
| 4 4 | 
             
                add_column :joblin_background_tasks, :error_message, :text
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require 'active_record'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Joblin
         | 
| 4 | 
            +
              module MiscHelper
         | 
| 5 | 
            +
                MigrationClass = Rails.version < '5.0' ? ActiveRecord::Migration : ActiveRecord::Migration[5.2]
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def self.to_boolean(v)
         | 
| 8 | 
            +
                  if Rails.version < '5.0'
         | 
| 9 | 
            +
                    ActiveRecord::Type::Boolean.new.type_cast_from_user(v)
         | 
| 10 | 
            +
                  else
         | 
| 11 | 
            +
                    ActiveRecord::Type::Boolean.new.deserialize(v)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        data/lib/joblin/version.rb
    CHANGED