lato_storage 3.0.4 → 3.0.5
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 +4 -4
- data/app/controllers/lato_storage/application_controller.rb +37 -3
- data/app/views/lato_storage/attachments/index.html.erb +1 -1
- data/app/views/lato_storage/blobs/index.html.erb +1 -1
- data/app/views/lato_storage/variant_records/index.html.erb +1 -1
- data/lib/lato_storage/config.rb +9 -1
- data/lib/lato_storage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e3025eada87329a0eb5a53da4eabcb1e3876c09c5730fdcec324904ec420604
|
4
|
+
data.tar.gz: d17b7f2355f1118aa280b0c59df2a323666313f5db0b755e3ad137c5d18998b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6ad7617bcda1e29b62374f1e5c947a16a0c06b67f0b692ba41c45968773d354b307dbae0a387349a7988a5ed0db8425ba567815ff482c5f1e4b209a04dbdb6
|
7
|
+
data.tar.gz: cdd52bbe6f56d9990cb2edd821500c248addaa841ce72353081e70528953a5ba752423425a2cf48489a66b5f786e4b273183883fc0d1f9247433b9f31e139355
|
@@ -6,9 +6,9 @@ module LatoStorage
|
|
6
6
|
before_action { active_sidebar(:lato_storage); active_navbar(:lato_storage) }
|
7
7
|
|
8
8
|
def index
|
9
|
-
@blobs_count =
|
10
|
-
@attachments_count =
|
11
|
-
@variant_records_count =
|
9
|
+
@blobs_count = blobs_count
|
10
|
+
@attachments_count = attachments_count
|
11
|
+
@variant_records_count = variant_records_count
|
12
12
|
@deletable_blobs_count = ActiveStorage::Blob.unattached.where('active_storage_blobs.created_at < ?', 12.hours.ago).count
|
13
13
|
|
14
14
|
@total_storage = ActiveStorage::Blob.sum(:byte_size)
|
@@ -40,5 +40,39 @@ module LatoStorage
|
|
40
40
|
|
41
41
|
redirect_to lato.root_path, alert: 'You have not access to this section.'
|
42
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def blobs_count
|
47
|
+
return ActiveStorage::Blob.count unless LatoStorage.config.optimize_performances
|
48
|
+
|
49
|
+
if ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
|
50
|
+
ActiveRecord::Base.connection.execute("SELECT reltuples::bigint AS estimate FROM pg_class WHERE relname = 'active_storage_blobs';").first["estimate"]
|
51
|
+
else
|
52
|
+
ActiveStorage::Blob.count
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def attachments_count
|
57
|
+
return ActiveStorage::Attachment.count unless LatoStorage.config.optimize_performances
|
58
|
+
|
59
|
+
if ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
|
60
|
+
ActiveRecord::Base.connection.execute("SELECT reltuples::bigint AS estimate FROM pg_class WHERE relname = 'active_storage_attachments';").first["estimate"]
|
61
|
+
else
|
62
|
+
ActiveStorage::Attachment.count
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def variant_records_count
|
67
|
+
return 0 unless defined?(ActiveStorage::VariantRecord)
|
68
|
+
return ActiveStorage::VariantRecord.count unless LatoStorage.config.optimize_performances
|
69
|
+
|
70
|
+
if defined?(ActiveStorage::VariantRecord) && ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
|
71
|
+
ActiveRecord::Base.connection.execute("SELECT reltuples::bigint AS estimate FROM pg_class WHERE relname = 'active_storage_variant_records';").first["estimate"]
|
72
|
+
else
|
73
|
+
ActiveStorage::VariantRecord.count
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
43
77
|
end
|
44
78
|
end
|
data/lib/lato_storage/config.rb
CHANGED
@@ -3,8 +3,16 @@ module LatoStorage
|
|
3
3
|
# This class contains the default configuration of the engine.
|
4
4
|
##
|
5
5
|
class Config
|
6
|
-
|
6
|
+
|
7
|
+
# This option allows to optimize performances by skipping count queries.
|
8
|
+
# If set to true, it will not perform count queries for collections and use other methods instead.
|
9
|
+
# This can significantly speed up operations but may lead to inaccuracies in counts.
|
10
|
+
# This is really useful for large datasets where performance is critical.
|
11
|
+
# Default is false.
|
12
|
+
attr_accessor :optimize_performances
|
13
|
+
|
7
14
|
def initialize
|
15
|
+
@optimize_performances = false
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
data/lib/lato_storage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lato_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregorio Galante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|