tartarus-rb 0.6.0 → 0.7.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: d964cd9b85733405512f08d58cea33e9f12f5b6d3fa05d8fb2d1c979463ffead
4
- data.tar.gz: 955301decdf77128432413afb6dd40612bb5c279e2cb65129f740cf1c81c1373
3
+ metadata.gz: 0a770f6674e54fb7d322129972137b230dad98be24c90700ffc0e8ebaa203cb1
4
+ data.tar.gz: d77e6531054e907e5ad9f6bc4193e794cf83b06a3ee1748e4b0c51ea2751217d
5
5
  SHA512:
6
- metadata.gz: d455a12a6503b078c1b49e3902d840a017bfa50f99c6eee2ff17367d3398eb62b376503f84b260a90663e9c3f465ac59ba4509a1b3f9767835548853a24f3469
7
- data.tar.gz: 2b4502ce62eb6bd831413d237e9b69535fbbe113c09e25e35f0ee680c902599bd0c52a210c0eb365ccde044c6a200da32c4b12798a6137e996a228f1192d8b10
6
+ metadata.gz: a7e8c811a106818486ef19b3b62321695a2b0c4a1aa831d4a4ae0ef58a5eb0edcc6558ec77a01c1e16bb0a1f8f434edf640ee929f7ca251448d63dcc3ab0070b
7
+ data.tar.gz: c3caebab36e9922761c2107c17262dc9b773fb443327f0bfc3e418c6c747b741e8c2f9c2337339f1c5e7cd442dcd1e4aad4707015ee8587088355b844e20df70
data/Changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## 0.7.0
6
+
7
+ - Remove explicit ordering from `Tartarus::ArchivableCollectionRepository#items_older_than`, it increased the cost of queries significantly on large tables
8
+
5
9
  ## 0.6.0
6
10
 
7
11
  - Optimize query from `Tartarus::ArchivableCollectionRepository#items_older_than` by adding explicit ordering
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tartarus-rb (0.6.0)
4
+ tartarus-rb (0.7.0)
5
5
  sidekiq (>= 5)
6
6
  sidekiq-cron (~> 1)
7
7
 
@@ -32,7 +32,7 @@ GEM
32
32
  minitest (>= 5.1)
33
33
  tzinfo (~> 2.0)
34
34
  zeitwerk (~> 2.3)
35
- addressable (2.7.0)
35
+ addressable (2.8.0)
36
36
  public_suffix (>= 2.0.2, < 5.0)
37
37
  aws-eventstream (1.1.0)
38
38
  aws-partitions (1.424.0)
@@ -55,39 +55,41 @@ GEM
55
55
  diff-lcs (1.4.4)
56
56
  dotenv (2.7.6)
57
57
  erubi (1.10.0)
58
- et-orbi (1.2.4)
58
+ et-orbi (1.2.7)
59
59
  tzinfo
60
- fugit (1.4.5)
61
- et-orbi (~> 1.1, >= 1.1.8)
60
+ fugit (1.8.1)
61
+ et-orbi (~> 1, >= 1.2.7)
62
62
  raabro (~> 1.4)
63
+ globalid (1.1.0)
64
+ activesupport (>= 5.0)
63
65
  hashdiff (1.0.0)
64
66
  i18n (1.8.5)
65
67
  concurrent-ruby (~> 1.0)
66
- jmespath (1.4.0)
67
- loofah (2.9.0)
68
+ jmespath (1.6.1)
69
+ loofah (2.18.0)
68
70
  crass (~> 1.0.2)
69
71
  nokogiri (>= 1.5.9)
70
72
  method_source (1.0.0)
71
- mini_portile2 (2.5.0)
72
- minitest (5.14.2)
73
- nokogiri (1.11.1)
74
- mini_portile2 (~> 2.5.0)
73
+ mini_portile2 (2.8.4)
74
+ minitest (5.20.0)
75
+ nokogiri (1.15.4)
76
+ mini_portile2 (~> 2.8.2)
75
77
  racc (~> 1.4)
76
- pg (1.2.3)
78
+ pg (1.5.4)
77
79
  postgres-copy (1.5.0)
78
80
  activerecord (>= 5.1)
79
81
  pg (>= 0.17)
80
82
  responders
81
- public_suffix (4.0.4)
83
+ public_suffix (4.0.7)
82
84
  raabro (1.4.0)
83
- racc (1.5.2)
84
- rack (2.2.3)
85
+ racc (1.7.1)
86
+ rack (2.2.3.1)
85
87
  rack-test (1.1.0)
86
88
  rack (>= 1.0, < 3)
87
89
  rails-dom-testing (2.0.3)
88
90
  activesupport (>= 4.2.0)
89
91
  nokogiri (>= 1.6)
90
- rails-html-sanitizer (1.3.0)
92
+ rails-html-sanitizer (1.4.3)
91
93
  loofah (~> 2.3)
92
94
  railties (6.1.0.rc1)
93
95
  actionpack (= 6.1.0.rc1)
@@ -121,9 +123,10 @@ GEM
121
123
  connection_pool (>= 2.2.2)
122
124
  rack (~> 2.0)
123
125
  redis (>= 4.2.0)
124
- sidekiq-cron (1.2.0)
125
- fugit (~> 1.1)
126
- sidekiq (>= 4.2.1)
126
+ sidekiq-cron (1.10.1)
127
+ fugit (~> 1.8)
128
+ globalid (>= 1.0.1)
129
+ sidekiq (>= 6)
127
130
  thor (1.1.0)
128
131
  timecop (0.9.2)
129
132
  tzinfo (2.0.2)
data/README.md CHANGED
@@ -27,59 +27,62 @@ Here are some examples how to use it
27
27
  Put it in the initializer, e.g. in `config/initializers/sidekiq.rb` right after loading schedule for `sidekiq-cron`:
28
28
 
29
29
  ``` rb
30
- schedule_file = "config/schedule.yml"
31
-
32
- if File.exist?(schedule_file) && Sidekiq.server?
33
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
34
-
35
- tartarus = Tartarus.new
36
-
37
- tartarus.register do |item|
38
- item.model = ModelThatYouWantToArchive
39
- item.cron = "5 4 * * *"
40
- item.queue = "default"
41
- item.tenants_range = -> { Account.active }
42
- item.tenant_value_source = :uuid
43
- item.tenant_id_field = :account_uuid
44
- item.archive_items_older_than = -> { 30.days.ago }
45
- item.timestamp_field = :created_at
46
- item.archive_with = :destroy_all
47
- end
48
-
49
- tartarus.register do |item|
50
- item.model = OtherModelThatYouWantToArchive
51
- item.cron = "5 5 * * *"
52
- item.queue = "default"
53
- item.tenants_range = -> { ["Account", "User"] }
54
- item.tenant_id_field = :model_type
55
- item.archive_items_older_than = -> { 30.days.ago }
56
- item.timestamp_field = :created_at
57
- end
58
-
59
- glacier_configuration = Tartarus::RemoteStorage::Glacier::Configuration.build(
60
- aws_key: ENV.fetch("AWS_KEY"),
61
- aws_secret: ENV.fetch("AWS_SECRET"),
62
- aws_region: ENV.fetch("AWS_REGION"),
63
- vault_name: ENV.fetch("GLACIER_VAULT_NAME"),
64
- root_path: Rails.root.to_s,
65
- archive_registry_factory: ArchiveRegistry,
66
- )
67
- # don't forget about installing `aws-sdk-glacier` gem
68
-
69
- tartarus.register do |item|
70
- item.model = YetAnotherModel
71
- item.cron = "5 6 * * *"
72
- item.queue = "default"
73
- item.timestamp_field = :created_at
74
- item.archive_items_older_than = -> { 1.week.ago }
75
- item.remote_storage = Tartarus::RemoteStorage::Glacier.new(glacier_configuration)
30
+ Sidekiq.configure_server do |config|
31
+ config.on(:startup) do
32
+ schedule_file = "config/schedule.yml"
33
+
34
+ if File.exist?(schedule_file) && Sidekiq.server?
35
+ Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
36
+
37
+ tartarus = Tartarus.new
38
+
39
+ tartarus.register do |item|
40
+ item.model = ModelThatYouWantToArchive
41
+ item.cron = "5 4 * * *"
42
+ item.queue = "default"
43
+ item.tenants_range = -> { Account.active }
44
+ item.tenant_value_source = :uuid
45
+ item.tenant_id_field = :account_uuid
46
+ item.archive_items_older_than = -> { 30.days.ago }
47
+ item.timestamp_field = :created_at
48
+ item.archive_with = :destroy_all
49
+ end
50
+
51
+ tartarus.register do |item|
52
+ item.model = OtherModelThatYouWantToArchive
53
+ item.cron = "5 5 * * *"
54
+ item.queue = "default"
55
+ item.tenants_range = -> { ["Account", "User"] }
56
+ item.tenant_id_field = :model_type
57
+ item.archive_items_older_than = -> { 30.days.ago }
58
+ item.timestamp_field = :created_at
59
+ end
60
+
61
+ glacier_configuration = Tartarus::RemoteStorage::Glacier::Configuration.build(
62
+ aws_key: ENV.fetch("AWS_KEY"),
63
+ aws_secret: ENV.fetch("AWS_SECRET"),
64
+ aws_region: ENV.fetch("AWS_REGION"),
65
+ vault_name: ENV.fetch("GLACIER_VAULT_NAME"),
66
+ root_path: Rails.root.to_s,
67
+ archive_registry_factory: ArchiveRegistry,
68
+ )
69
+ # don't forget about installing `aws-sdk-glacier` gem
70
+
71
+ tartarus.register do |item|
72
+ item.model = YetAnotherModel
73
+ item.cron = "5 6 * * *"
74
+ item.queue = "default"
75
+ item.timestamp_field = :created_at
76
+ item.archive_items_older_than = -> { 1.week.ago }
77
+ item.remote_storage = Tartarus::RemoteStorage::Glacier.new(glacier_configuration)
78
+ end
79
+
80
+ tartarus.schedule # this method must be called to create jobs for sidekiq-cron!
81
+ end
76
82
  end
77
-
78
- tartarus.schedule # this method must be called to create jobs for sidekiq-cron!
79
83
  end
80
84
  ```
81
85
 
82
-
83
86
  You can use the following config params:
84
87
  - `model` - a name of the ActiveReord model you want to archive, required
85
88
  - `name` - name of your strategy, optional. It fallbacks `model.to_s`. It's important to set in in cases when you have several strategies for the same model:
@@ -13,7 +13,6 @@ class Tartarus
13
13
  ensure_column_exists(collection, model_name, tenant_id_field)
14
14
 
15
15
  collection.where("#{timestamp_field} < ?", timestamp).where(tenant_id_field => tenant_id)
16
- .order(tenant_id_field, timestamp_field)
17
16
  end
18
17
 
19
18
  def items_older_than(model_name, timestamp_field, timestamp)
@@ -1,5 +1,5 @@
1
1
  class Tartarus
2
2
  module Rb
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tartarus-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2023-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  - !ruby/object:Gem::Version
265
265
  version: '0'
266
266
  requirements: []
267
- rubygems_version: 3.1.4
267
+ rubygems_version: 3.4.10
268
268
  signing_key:
269
269
  specification_version: 4
270
270
  summary: A gem for archving (deleting) old records you no longer need. Send them straight