ops_backups 0.1.9 → 0.1.11

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: 9c5630e25e938e9e3ff8df947ec38c0135b12a2d94b3a46e9c6d55d3b70f5a0c
4
- data.tar.gz: 8bb0cab72c776e01cda428050591c97658de1401cf3420b7bde758ace3b44c06
3
+ metadata.gz: b2fef2adc42b4749261dd1a0eb29142b0e55c84dd0465a519bdfdea0e3b86314
4
+ data.tar.gz: 4bf5d15d8584abfb624fc8071da8cb5afa578830e1bc4b8754b8e716692e67d6
5
5
  SHA512:
6
- metadata.gz: 9c06a9d87783b4950fac61f6e60f75d67288cff322d47bf953a1ffd33c7cbf71972b1b24cff28bd5310e0f9d92e4ebd1fa5280ab97a4ff8f37f43ffbf99f2d00
7
- data.tar.gz: 357728c90e376f3101b07f948d2a28b379f453ddc8cd8aa7d0e29009e83506a4a8bc7c2ae0d3aeb47038f18fa31d305398b4cf4291ac1d6698c49c0178286b03
6
+ metadata.gz: 7e70cc33d5f7d23e4f9cff8b22b0a6bcaa32d0830d4ea232c5d3e41db2f9adaca62ad484423c96ffbc9ec85d38fb2202094f3ff55c28b5a24c29c320a4a4caf3
7
+ data.tar.gz: 277e00a4449260ff40a4558df7bf7cd624e20a73ca72fe696d7bebd257529bbf2b175e813351401e0756d6f135ad2646b1139bdc0f35e68cf2e49a747247d55d
@@ -10,14 +10,6 @@ module OpsBackups
10
10
  [ "created_at", "id", "name", "new_id", "tag", "updated_at" ]
11
11
  end
12
12
 
13
- def self.test
14
- "self.test"
15
- end
16
-
17
- def hoho
18
- "hihi"
19
- end
20
-
21
13
  def db_pg_backup(tag: nil, exclude_tables: [])
22
14
  db_url = ENV["DATABASE_URL"]
23
15
  tag ||= exclude_tables.empty? ? "db_pg_full" : "db_pg_partial" # if tag.empty?
@@ -48,36 +40,36 @@ module OpsBackups
48
40
  end
49
41
  end
50
42
  end
51
- end
52
43
 
53
- # Keep all the backups of the last day
54
- # Keep the last backup of each day in the last week (except the last day)
55
- # Keep the last backup of each week in the last month (except the last week)
56
- # Keep the last backup of each month before the last month
57
- def self.retain_tiered_cleanup_policy(tag: "")
58
- week = where(created_at: 1.week.ago..1.day.ago)
59
- .group_by { |b| b.created_at.to_date }
60
- month = where(created_at: 1.month.ago..1.week.ago)
61
- .group_by { |b| b.created_at.beginning_of_week }
62
- older = where(created_at: 1.year.ago..1.month.ago)
63
- .group_by { |b| b.created_at.beginning_of_month }
44
+ # Keep all the backups of the last day
45
+ # Keep the last backup of each day in the last week (except the last day)
46
+ # Keep the last backup of each week in the last month (except the last week)
47
+ # Keep the last backup of each month before the last month
48
+ def self.retain_tiered_cleanup_policy(tag: "")
49
+ week = where(created_at: 1.week.ago..1.day.ago)
50
+ .group_by { |b| b.created_at.to_date }
51
+ month = where(created_at: 1.month.ago..1.week.ago)
52
+ .group_by { |b| b.created_at.beginning_of_week }
53
+ older = where(created_at: 1.year.ago..1.month.ago)
54
+ .group_by { |b| b.created_at.beginning_of_month }
64
55
 
65
- backups = week.merge(month).merge(older)
56
+ backups = week.merge(month).merge(older)
66
57
 
67
- ids = backups.flat_map do |_, group|
68
- group.sort_by(&:created_at).reverse.drop(1).pluck(:id)
69
- end
58
+ ids = backups.flat_map do |_, group|
59
+ group.sort_by(&:created_at).reverse.drop(1).pluck(:id)
60
+ end
70
61
 
71
- records = where(id: ids)
72
- records = records.where(tag: tag) if tag.present?
73
- records.destroy_all
74
- end
62
+ records = where(id: ids)
63
+ records = records.where(tag: tag) if tag.present?
64
+ records.destroy_all
65
+ end
75
66
 
76
- # Keep the last 14 backups
77
- def self.retain_last_limit_cleanup_policy(limit: 14, tag: "")
78
- records = all
79
- records = records.where(tag: tag) if tag.present?
80
- records = records.order(updated_at: :desc).offset(limit)
81
- records.destroy_all
67
+ # Keep the last 14 backups
68
+ def self.retain_last_limit_cleanup_policy(limit: 14, tag: "")
69
+ records = all
70
+ records = records.where(tag: tag) if tag.present?
71
+ records = records.order(updated_at: :desc).offset(limit)
72
+ records.destroy_all
73
+ end
82
74
  end
83
75
  end
@@ -1,3 +1,3 @@
1
1
  module OpsBackups
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_backups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Handekyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-24 00:00:00.000000000 Z
11
+ date: 2024-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails