tartarus-rb 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +8 -0
- data/Gemfile.lock +22 -19
- data/README.md +52 -49
- data/lib/tartarus/archivable_collection_repository.rb +1 -2
- data/lib/tartarus/rb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fbf0d84c0c5a7221c340303d65c7649d883dae985003803b571b2a41b28081b
|
4
|
+
data.tar.gz: 0a63951eac2535c59a63968ee260ec2980b0c904cbde4bba0d83beb1c04d46a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7ffe596efe58ddc1c83f2d680516b54795a0ebd240ef2231dbed873bcf71ff36c52b0c06636de1de703f6a26320122ff1747bbdb98bbf2602e4547e083656e
|
7
|
+
data.tar.gz: 037ec5b6c6220b18e67641eead3d177df8413b1f711148a9098957e5718b4ee18754812550062d9c5f8cfdcfa8d0f16ce8a63cb0996fd2882567bb5b67bd3356
|
data/Changelog.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 0.8.0
|
6
|
+
|
7
|
+
- Remove explicit ordering from both `Tartarus::ArchivableCollectionRepository#items_older_than` and `Tartarus::ArchivableCollectionRepository#items_older_than_for_tenant`
|
8
|
+
|
9
|
+
## 0.7.0
|
10
|
+
|
11
|
+
- Remove explicit ordering from `Tartarus::ArchivableCollectionRepository#items_older_than`, it increased the cost of queries significantly on large tables
|
12
|
+
|
5
13
|
## 0.6.0
|
6
14
|
|
7
15
|
- 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.
|
4
|
+
tartarus-rb (0.8.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.
|
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.
|
58
|
+
et-orbi (1.2.7)
|
59
59
|
tzinfo
|
60
|
-
fugit (1.
|
61
|
-
et-orbi (~> 1
|
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.
|
67
|
-
loofah (2.
|
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.
|
72
|
-
minitest (5.
|
73
|
-
nokogiri (1.
|
74
|
-
mini_portile2 (~> 2.
|
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.
|
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.
|
83
|
+
public_suffix (4.0.7)
|
82
84
|
raabro (1.4.0)
|
83
|
-
racc (1.
|
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
|
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.
|
125
|
-
fugit (~> 1.
|
126
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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,14 +13,13 @@ 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)
|
20
19
|
collection = collection_for(model_name)
|
21
20
|
ensure_column_exists(collection, model_name, timestamp_field)
|
22
21
|
|
23
|
-
collection.where("#{timestamp_field} < ?", timestamp)
|
22
|
+
collection.where("#{timestamp_field} < ?", timestamp)
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
data/lib/tartarus/rb/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.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:
|
11
|
+
date: 2023-09-20 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.
|
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
|