recurring_active_job 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36f2c85439a8469566f302b776423f565eeea7236f9080ecc9752b0d455f348c
4
- data.tar.gz: 0a1f94b3e362be64fdf0d6c620bab6269a0f89b0628c2b6429181f76b669f4ae
3
+ metadata.gz: d7496f9b7922dc8bb3beb7847d28df78d5d4e810a3a4ef27abcbe9fd92578994
4
+ data.tar.gz: e6f4de1ab487c438d149a8002a2bfb4fe8d5540efbbe95d11674aa04b615ea2c
5
5
  SHA512:
6
- metadata.gz: 17735a6bd0879e1c78e3d1ab981c9eeb49c22018123f84fcbd3b4ada6c8d915e9bcb264d899d882c49f47f969ca81295efe5397f55e4609f561e074f415e4597
7
- data.tar.gz: 79719bfed0a60cd35ee6ccbd7b6ef01c46e1727b184a35e343bdfcff971a19d14374c5d9d33ec2a363325e455f3605020cb5407e240c10a4a85713e389d643b6
6
+ metadata.gz: b7a26539de51596e643612a685a580ae460cc84821f5bff4d35853cc4d7f04942f747abd25e455c054c242f0aebef90411fe450f0d77eec6227822acbfa292f8
7
+ data.tar.gz: 00763c972f25777295694d3ead555acb2cac83fe7b347b1f83c170dd96d3303596a28ce0c0e631929e40e52be01a9e056972a97fb125295b19ea2e4f0afc6ed1
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  #### Adapter agnostic ActiveJob scheduler based on time spent between executions.
4
4
 
5
5
  <!--- Version informartion -->
6
- *You are viewing the README of the development version. There are no releases yet.*
6
+ *You are viewing the README of version [v0.2.0](https://github.com/thisismydesign/recurring_active_job/releases/tag/v0.2.0). You can find other releases [here](https://github.com/thisismydesign/recurring_active_job/releases).*
7
7
  <!--- Version informartion end -->
8
8
 
9
9
  | Branch | Status |
@@ -61,6 +61,8 @@ def change
61
61
  t.boolean :active, default: true, null: false
62
62
  t.integer :frequency_seconds, default: 600, null: false
63
63
  t.boolean :auto_delete, default: true, null: false
64
+ t.string :last_error
65
+ t.text :last_error_details
64
66
 
65
67
  t.timestamps
66
68
  end
@@ -6,6 +6,8 @@ class CreateRecurringActiveJob < ActiveRecord::Migration[5.1]
6
6
  t.boolean :active, default: true, null: false
7
7
  t.integer :frequency_seconds, default: 600, null: false
8
8
  t.boolean :auto_delete, default: true, null: false
9
+ t.string :last_error
10
+ t.text :last_error_details
9
11
 
10
12
  t.timestamps
11
13
  end
data/config/schema.rb CHANGED
@@ -1,27 +1,29 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(version: 2018_06_27_123939) do
14
-
15
- create_table "recurring_active_jobs", force: :cascade do |t|
16
- t.string "job_id"
17
- t.string "provider_job_id"
18
- t.boolean "active", default: true, null: false
19
- t.integer "frequency_seconds", default: 600, null: false
20
- t.boolean "auto_delete", default: true, null: false
21
- t.datetime "created_at", null: false
22
- t.datetime "updated_at", null: false
23
- t.index ["job_id"], name: "index_recurring_active_jobs_on_job_id", unique: true
24
- t.index ["provider_job_id"], name: "index_recurring_active_jobs_on_provider_job_id", unique: true
25
- end
26
-
27
- end
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 2018_06_27_123939) do
14
+
15
+ create_table "recurring_active_jobs", force: :cascade do |t|
16
+ t.string "job_id"
17
+ t.string "provider_job_id"
18
+ t.boolean "active", default: true, null: false
19
+ t.integer "frequency_seconds", default: 600, null: false
20
+ t.boolean "auto_delete", default: true, null: false
21
+ t.string "last_error"
22
+ t.text "last_error_details"
23
+ t.datetime "created_at", null: false
24
+ t.datetime "updated_at", null: false
25
+ t.index ["job_id"], name: "index_recurring_active_jobs_on_job_id", unique: true
26
+ t.index ["provider_job_id"], name: "index_recurring_active_jobs_on_provider_job_id", unique: true
27
+ end
28
+
29
+ end
@@ -6,6 +6,12 @@ module RecurringActiveJob
6
6
  attr_accessor :logger
7
7
  end
8
8
 
9
+ retry_on(StandardError, attempts: 0) do |job, e|
10
+ recurring_active_job = RecurringActiveJob::Model.find(job.arguments.first&.dig(:recurring_active_job_id))
11
+ recurring_active_job.update!(last_error: "#{e.class}: #{e.message}", last_error_details: ruby_style_error(e))
12
+ raise e
13
+ end
14
+
9
15
  before_enqueue do |job|
10
16
  raise "Missing `recurring_active_job_id` argument" unless job.arguments.first&.dig(:recurring_active_job_id)
11
17
  load_recurring_active_job(job.arguments.first&.dig(:recurring_active_job_id))
@@ -65,5 +71,10 @@ module RecurringActiveJob
65
71
  def logger
66
72
  self.class.logger
67
73
  end
74
+
75
+ def self.ruby_style_error(e)
76
+ e.backtrace.join("\n\t")
77
+ .sub("\n\t", ": #{e}#{e.class ? " (#{e.class})" : ''}\n\t")
78
+ end
68
79
  end
69
80
  end
@@ -1,3 +1,3 @@
1
1
  module RecurringActiveJob
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurring_active_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thisismydesign