web47core 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 175a0c5435c619e80dc0dcc56721c38b322f36138c330d30b22a06afbcf0770c
4
- data.tar.gz: 59ded4c87e2eaa77954f25f92507130473e79e1bb8d59bb5cef1e0b554c51fd1
3
+ metadata.gz: 6ad058425df9daebb9a66852109bec488f5f3062cb654236c4d97680757acc65
4
+ data.tar.gz: 8aae556d6fd90da4a6bea7259aeefc47fcc3f5e30c6f062cf215f227598f2b35
5
5
  SHA512:
6
- metadata.gz: 8537e959731e6ac1e666cd1312f1cbd4a9a90b46a12c8a710863fbded81dd09fdfdda7d083e84bd930fdb7a056827728d2ccdd8605a420ced698c97955cea358
7
- data.tar.gz: ec9c4a4e18bbb7d9f71830a4d5ffb53ab5b95fed4e9437a357307df8a59d59a50a7091713963e22cb7befdf818dbfade88ffc11b5ba6f3276f97f65fb0a3a8ec
6
+ metadata.gz: 4f1bdd1eacf5288ca19c548141c31b7b3393a24f12be3aa6009329f387572873e5ede3b14de35f76d11c8f7af7134f404ef0b88f9d01f58702d2a29259d91087
7
+ data.tar.gz: b64175e0a61c1ebd84ca5082b5d4d1f1721c8b2d34df4c7e5345f30f0a3d21d45f5fbf393e8c9643d9d0d61bec77c7d7a1caece939a1521304e00b7e8340aafc
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cron
4
+ #
5
+ # Clean up Audit Logs that have not been updated in 90 days
6
+ #
7
+ class TrimAuditLogs < TrimCollection
8
+ #
9
+ # Fetch each Audit Log and delete it if hasn't been updated in 90 days
10
+ #
11
+ def collection
12
+ AuditLog.all
13
+ end
14
+
15
+ #
16
+ # Check which audit logs we wanted deleted
17
+ #
18
+ # Should be older than 90 days and either not a user model audit log or the model associated with
19
+ # the UserModelAuditLog has been deleted
20
+ #
21
+ def archive?(item)
22
+ super && (!item.is_a?(UserModelAuditLog) || item.model.blank?)
23
+ end
24
+
25
+ #
26
+ # Allowed time the amount of time allowed to exists before deleting
27
+ #
28
+ def allowed_time
29
+ 90.days.ago
30
+ end
31
+ end
32
+ end
@@ -23,9 +23,17 @@ module Cron
23
23
  # Test if this should be archived
24
24
  #
25
25
  def archive?(item)
26
- item.updated_at < allowed_time
26
+ item.updated_at < allowed_time_for_item(item)
27
27
  end
28
28
 
29
+ #
30
+ # Try to get a TTL from System configuration, otherwise return the default
31
+ #
32
+ def allowed_time_for_item(item)
33
+ SystemConfiguration.send("#{item.class.to_s.underscore}_ttl").days.ago
34
+ rescue StandardError
35
+ allowed_time
36
+ end
29
37
  #
30
38
  # Allowed time the amount of time allowed to exists before deleting
31
39
  #
data/lib/web47core.rb CHANGED
@@ -32,9 +32,10 @@ require 'app/jobs/cron/server'
32
32
  require 'app/jobs/cron/trim_collection'
33
33
  require 'app/jobs/cron/switchboard_sync_configuration'
34
34
  require 'app/jobs/cron/switchboard_sync_models'
35
- require 'app/jobs/cron/trim_notifications'
35
+ require 'app/jobs/cron/trim_audit_logs'
36
36
  require 'app/jobs/cron/trim_cron_servers'
37
37
  require 'app/jobs/cron/trim_failed_delayed_jobs'
38
+ require 'app/jobs/cron/trim_notifications'
38
39
  #
39
40
  # Audit Logs
40
41
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
@@ -603,6 +603,7 @@ files:
603
603
  - lib/app/jobs/cron/switchboard_sync_configuration.rb
604
604
  - lib/app/jobs/cron/switchboard_sync_models.rb
605
605
  - lib/app/jobs/cron/tab.rb
606
+ - lib/app/jobs/cron/trim_audit_logs.rb
606
607
  - lib/app/jobs/cron/trim_collection.rb
607
608
  - lib/app/jobs/cron/trim_cron_servers.rb
608
609
  - lib/app/jobs/cron/trim_failed_delayed_jobs.rb