lato_storage 3.1.1 → 3.1.3

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: 0f60e0848acdfd5b0de5f20980534819168517e704d057f733b7545de563ddf8
4
- data.tar.gz: 58d3cd2919869438494d2eb985cfde1639a3495870cdbf64caee275cadf60f19
3
+ metadata.gz: 68d3ea583748a22788534d655f215020a2e4f77aa2a2de7ee17324dfa4d6613e
4
+ data.tar.gz: 6437297304971083309daaa39535a0f03c65cef445708b9a53b4924fbafc32d3
5
5
  SHA512:
6
- metadata.gz: 4213b787cc1f1d84ebceeeef5f9cb5f8ed540ad67bba1883fd5cbd7c657d024bc5004f29ffb72a7f04666eed126d574d8f738f7caf1169cb5e3fb32773cbd942
7
- data.tar.gz: 011650c33d774e48efcb857c4947dbbefd99ef52bdecf4bb4874fa108777ff99f794542ef5528696e9e55255c14c9fe5bd275df6db26292120019a808dbf8c65
6
+ metadata.gz: 2b8c97308770e9a9ba9685dc876399ca692fb1988f00c9086f5c97a6357ce835c74eeb2defa84aa7f2631049e1cf88cce56eb2e77eaac317f87ef82ebe20622d
7
+ data.tar.gz: 266fe35e267ca803dc9e85a68da009fd18632b4cae0afa446cb5baf9b6001506b3a090e64da1cca95c94933ecbf8fe637af7fd688ccbac425f77e6493af6d1ff
data/README.md CHANGED
@@ -4,6 +4,8 @@ Manage application storage (ActiveStorage data) on Lato projects.
4
4
  NOTE: This gem is using [Active Storage Dashboard](https://github.com/giovapanasiti/active_storage_dashboard) as reference for the interface and the functionality. The idea is to provide a similar interface inside Lato.
5
5
 
6
6
  ## Installation
7
+
8
+ Requires Rails 8.1.3.1 or newer in the 8.1 series and Lato 3.25.0 or newer. Existing applications must install the new Lato session migration before deployment; previous sessions are invalidated.
7
9
  Add required dependencies to your application's Gemfile:
8
10
 
9
11
  ```ruby
data/Rakefile CHANGED
@@ -3,6 +3,4 @@ require "bundler/setup"
3
3
  APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
4
  load "rails/tasks/engine.rake"
5
5
 
6
- load "rails/tasks/statistics.rake"
7
-
8
6
  require "bundler/gem_tasks"
@@ -100,6 +100,10 @@ module LatoStorage
100
100
  else
101
101
  ActiveStorage::Blob.count
102
102
  end
103
+ rescue StandardError => e
104
+ Rails.logger.error "Error estimating blobs count: #{e.message}"
105
+ Rails.logger.error e.backtrace.join("\n")
106
+ 0
103
107
  end
104
108
 
105
109
  def attachments_count_loader
@@ -112,6 +116,10 @@ module LatoStorage
112
116
  else
113
117
  ActiveStorage::Attachment.count
114
118
  end
119
+ rescue StandardError => e
120
+ Rails.logger.error "Error estimating attachments count: #{e.message}"
121
+ Rails.logger.error e.backtrace.join("\n")
122
+ 0
115
123
  end
116
124
 
117
125
  def variant_records_count_loader
@@ -126,6 +134,10 @@ module LatoStorage
126
134
  else
127
135
  ActiveStorage::VariantRecord.count
128
136
  end
137
+ rescue StandardError => e
138
+ Rails.logger.error "Error estimating variant records count: #{e.message}"
139
+ Rails.logger.error e.backtrace.join("\n")
140
+ 0
129
141
  end
130
142
 
131
143
  def deletable_blobs_count_loader
@@ -134,15 +146,19 @@ module LatoStorage
134
146
  count += 1
135
147
  end
136
148
  count
149
+ rescue StandardError => e
150
+ Rails.logger.error "Error estimating deletable blobs count: #{e.message}"
151
+ Rails.logger.error e.backtrace.join("\n")
152
+ 0
137
153
  end
138
154
 
139
155
  # Estimate the total storage by multiplying average size of a group sample by total blobs count
140
156
  def total_storage_loader(blobs_count)
141
- sample_size = 1000
157
+ sample_size = 5000
142
158
  total_size = 0
143
159
  sampled_count = 0
144
160
 
145
- ActiveStorage::Blob.order('RANDOM()').limit(sample_size).each do |blob|
161
+ ActiveStorage::Blob.order(id: :desc).limit(sample_size).each do |blob|
146
162
  total_size += blob.byte_size
147
163
  sampled_count += 1
148
164
  end
@@ -151,6 +167,10 @@ module LatoStorage
151
167
 
152
168
  average_size = total_size / sampled_count
153
169
  average_size * blobs_count
170
+ rescue StandardError => e
171
+ Rails.logger.error "Error estimating total storage: #{e.message}"
172
+ Rails.logger.error e.backtrace.join("\n")
173
+ 0
154
174
  end
155
175
 
156
176
  # Estimate content types by sampling blobs
@@ -159,7 +179,7 @@ module LatoStorage
159
179
  sample_size = 5000
160
180
  sampled_count = 0
161
181
 
162
- ActiveStorage::Blob.order('RANDOM()').limit(sample_size).each do |blob|
182
+ ActiveStorage::Blob.order(id: :desc).limit(sample_size).each do |blob|
163
183
  content_type_counts[blob.content_type] += 1
164
184
  sampled_count += 1
165
185
  end
@@ -169,6 +189,10 @@ module LatoStorage
169
189
  # Scale counts to estimated total blobs count
170
190
  content_type_counts.transform_values! { |count| (count.to_f / sampled_count) * blobs_count_loader }
171
191
  content_type_counts.sort_by { |_, count| -count }.first(5)
192
+ rescue StandardError => e
193
+ Rails.logger.error "Error estimating content types: #{e.message}"
194
+ Rails.logger.error e.backtrace.join("\n")
195
+ []
172
196
  end
173
197
  end
174
198
  end
@@ -1,3 +1,3 @@
1
1
  module LatoStorage
2
- VERSION = "3.1.1"
2
+ VERSION = "3.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-11-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -16,28 +15,34 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 7.1.1
18
+ version: 8.1.3.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '8.2'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: 7.1.1
28
+ version: 8.1.3.1
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '8.2'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: lato
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - ">="
32
37
  - !ruby/object:Gem::Version
33
- version: '0'
38
+ version: 3.25.0
34
39
  type: :runtime
35
40
  prerelease: false
36
41
  version_requirements: !ruby/object:Gem::Requirement
37
42
  requirements:
38
43
  - - ">="
39
44
  - !ruby/object:Gem::Version
40
- version: '0'
45
+ version: 3.25.0
41
46
  description: A Rails engine to manage application storage on Lato projects!
42
47
  email:
43
48
  - me@gregoriogalante.com
@@ -79,7 +84,6 @@ licenses:
79
84
  metadata:
80
85
  homepage_uri: https://github.com/Lato-org/lato_storage
81
86
  source_code_uri: https://github.com/Lato-org/lato_storage
82
- post_install_message:
83
87
  rdoc_options: []
84
88
  require_paths:
85
89
  - lib
@@ -94,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
98
  - !ruby/object:Gem::Version
95
99
  version: '0'
96
100
  requirements: []
97
- rubygems_version: 3.4.1
98
- signing_key:
101
+ rubygems_version: 4.0.9
99
102
  specification_version: 4
100
103
  summary: Another engine for Lato projects
101
104
  test_files: []