glib-web 6.9.2 → 7.0.0.beta1
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/helpers/glib/json_ui/action_builder/bottom_banners.rb +0 -1
- data/app/helpers/glib/json_ui/action_builder/components.rb +1 -16
- data/app/helpers/glib/json_ui/action_builder/logics.rb +1 -2
- data/app/helpers/glib/json_ui/action_builder/snackbars.rb +0 -16
- data/app/helpers/glib/json_ui/response_helper.rb +0 -12
- data/app/views/json_ui/garage/actions/_components.json.jbuilder +2 -2
- data/app/views/json_ui/garage/forms/bulk_edit_post.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +3 -3
- data/app/views/json_ui/garage/forms/selects.json.jbuilder +5 -5
- data/app/views/json_ui/garage/forms/update_options.json.jbuilder +1 -1
- data/app/views/json_ui/garage/panels/flow.json.jbuilder +6 -6
- data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +10 -10
- data/app/views/json_ui/garage/panels/responsive.json.jbuilder +10 -10
- data/app/views/json_ui/garage/panels/ul.json.jbuilder +2 -2
- data/app/views/json_ui/garage/panels/vertical.json.jbuilder +10 -10
- data/app/views/json_ui/garage/tables/bulk_edit.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/calendar.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/carousel.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/charts.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/column.json.jbuilder +3 -3
- data/app/views/json_ui/garage/test_page/components.json.jbuilder +7 -7
- data/app/views/json_ui/garage/test_page/custom.json.jbuilder +3 -3
- data/app/views/json_ui/garage/test_page/dialog.json.jbuilder +0 -21
- data/app/views/json_ui/garage/test_page/fields_creditCard.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/fields_date_time.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/fields_dynamicSelect.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/fields_location.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/fields_otp.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/fields_phone.json.jbuilder +9 -9
- data/app/views/json_ui/garage/test_page/fields_radio.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/fields_rating.json.jbuilder +10 -10
- data/app/views/json_ui/garage/test_page/fields_richText.json.jbuilder +10 -10
- data/app/views/json_ui/garage/test_page/fields_select.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/fields_sign.json.jbuilder +7 -7
- data/app/views/json_ui/garage/test_page/fields_stripeExternalAccount.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/fields_stripeToken.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/fields_text.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/fields_timer.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/flow.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/form.json.jbuilder +9 -9
- data/app/views/json_ui/garage/test_page/grid.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/horizontal.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/image.json.jbuilder +9 -9
- data/app/views/json_ui/garage/test_page/lifecycle.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/list.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/multimedia_docx.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/multimedia_video.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/pagination.json.jbuilder +6 -6
- data/app/views/json_ui/garage/test_page/panels_bulkEdit2.json.jbuilder +13 -13
- data/app/views/json_ui/garage/test_page/panels_bulkEdit3.json.jbuilder +1 -1
- data/app/views/json_ui/garage/test_page/progressCircle.json.jbuilder +8 -8
- data/app/views/json_ui/garage/test_page/responsive.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/scroll.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/split.json.jbuilder +1 -1
- data/app/views/json_ui/garage/test_page/table.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/timeline.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/ul.json.jbuilder +4 -4
- data/app/views/json_ui/garage/test_page/vertical.json.jbuilder +5 -5
- data/app/views/json_ui/garage/test_page/web.json.jbuilder +5 -5
- data/app/views/json_ui/garage/views/_expand_shrink_ex.json.jbuilder +4 -4
- data/app/views/json_ui/garage/views/controls.json.jbuilder +4 -4
- data/app/views/json_ui/garage/views/{components_set.json.jbuilder → logics_set.json.jbuilder} +2 -2
- data/lib/glib/engine.rb +0 -30
- data/lib/glib/json_crawler/router.rb +0 -24
- data/lib/glib/json_ui/config.rb +1 -1
- metadata +4 -31
- data/app/jobs/glib/purge_unattached_job.rb +0 -28
- data/app/models/concerns/glib/snapshot_v2.rb +0 -462
- data/app/models/glib/model.rb +0 -40
- data/app/models/glib/plain_model.rb +0 -23
- data/app/models/snapshot_blob_reference.rb +0 -20
- data/lib/generators/glib/snapshot_v2_generator.rb +0 -54
- data/lib/generators/templates/snapshot_v2/add_snapshot_v2_columns.rb +0 -18
- data/lib/generators/templates/snapshot_v2/create_snapshot_blob_references.rb +0 -10
|
@@ -112,8 +112,8 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
|
112
112
|
id: 'default',
|
|
113
113
|
onMouseEnter: ->(action) {
|
|
114
114
|
action.runMultiple childActions: ->(saction) do
|
|
115
|
-
saction.
|
|
116
|
-
saction.
|
|
115
|
+
saction.logics_set targetId: 'default', data: { displayed: false }
|
|
116
|
+
saction.logics_set targetId: 'hovered', data: { displayed: true }
|
|
117
117
|
end
|
|
118
118
|
}
|
|
119
119
|
scroll.button \
|
|
@@ -122,8 +122,8 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
|
122
122
|
displayed: false,
|
|
123
123
|
onMouseLeave: ->(action) {
|
|
124
124
|
action.runMultiple childActions: ->(saction) do
|
|
125
|
-
saction.
|
|
126
|
-
saction.
|
|
125
|
+
saction.logics_set targetId: 'default', data: { displayed: true }
|
|
126
|
+
saction.logics_set targetId: 'hovered', data: { displayed: false }
|
|
127
127
|
end
|
|
128
128
|
}, onClick: ->(action) do
|
|
129
129
|
action.dialogs_alert message: 'Perform action'
|
data/app/views/json_ui/garage/views/{components_set.json.jbuilder → logics_set.json.jbuilder}
RENAMED
|
@@ -9,7 +9,7 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
|
|
|
9
9
|
res.label id: 'label', text: 'Hello world!'
|
|
10
10
|
res.spacer height: 8
|
|
11
11
|
res.button text: 'set', onClick: ->(action) do
|
|
12
|
-
action.
|
|
12
|
+
action.logics_set targetId: 'label', data: { text: 'Hello too!' }, onSet: ->(saction) do
|
|
13
13
|
saction.snackbars_alert styleClasses: ['success'], message: 'Changed!'
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -23,7 +23,7 @@ page.body padding: glib_json_padding_body, childViews: ->(body) do
|
|
|
23
23
|
form.spacer height: 8
|
|
24
24
|
form.panels_horizontal childViews: ->(hori) do
|
|
25
25
|
hori.button text: 'set', onClick: ->(action) do
|
|
26
|
-
action.
|
|
26
|
+
action.logics_set targetId: 'ftext', data: { name: 'user[city]', value: 'Taipei', label: 'City', placeholder: 'City' }
|
|
27
27
|
end
|
|
28
28
|
hori.spacer width: 4
|
|
29
29
|
hori.fields_submit text: 'submit'
|
data/lib/glib/engine.rb
CHANGED
|
@@ -22,30 +22,6 @@ module Glib
|
|
|
22
22
|
scope :created_desc, -> { order(created_at: :desc, id: :desc) }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# Cascade-destroy blob references when a snapshot is destroyed (e.g. by max_snapshots
|
|
26
|
-
# retention in Glib::SnapshotV2#remove_old_snapshot). Without this, the FK on
|
|
27
|
-
# snapshot_blob_references would raise PG::ForeignKeyViolation.
|
|
28
|
-
#
|
|
29
|
-
# Opt-in: only consumers who run the gem's `create_snapshot_blob_references` migration
|
|
30
|
-
# have the table. The connection+table_exists? guard (wrapped in a rescue for boot
|
|
31
|
-
# sequences with no DB reachable — `rails db:create`, parallel test setup, and DB-less
|
|
32
|
-
# build containers like docker's `assets:precompile`) makes this a no-op for everyone
|
|
33
|
-
# else, so a bare `include Glib::SnapshotV2` never crashes a boot.
|
|
34
|
-
unless respond_to?(:snapshot_blob_references)
|
|
35
|
-
begin
|
|
36
|
-
if connection.table_exists?(:snapshot_blob_references)
|
|
37
|
-
has_many :snapshot_blob_references, dependent: :destroy
|
|
38
|
-
end
|
|
39
|
-
rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid,
|
|
40
|
-
ActiveRecord::ConnectionNotEstablished
|
|
41
|
-
# NoDatabaseError/StatementInvalid: the server exists but the database doesn't yet
|
|
42
|
-
# (e.g. `rails db:create`). ConnectionNotEstablished: no server reachable at all —
|
|
43
|
-
# e.g. docker build's assets:precompile, where DATABASE_HOST is unset and pg falls
|
|
44
|
-
# back to the local socket. The association gets re-registered on the next
|
|
45
|
-
# successful boot that finds the table.
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
25
|
# Parses the stored diff into a flat hash of Change structs:
|
|
50
26
|
# { 'item' => [Change, ...], 'association_name' => [Change, ...], ... }
|
|
51
27
|
# Returns an empty structure if no diff exists (e.g. the first snapshot).
|
|
@@ -117,13 +93,7 @@ module Glib
|
|
|
117
93
|
|
|
118
94
|
private
|
|
119
95
|
# Item-level change: from/to are scalar column values. Cast each to the column's real type.
|
|
120
|
-
#
|
|
121
|
-
# `index` is normalized to a Symbol so consumers compare against symbol literals
|
|
122
|
-
# (matching AR attribute keys, e.g. `change.index == :title`). Association-level
|
|
123
|
-
# changes are NOT symbolized — their index is a collection position from a path like
|
|
124
|
-
# "[0]", a positional digit, not a name.
|
|
125
96
|
def cast_item_change(change, root)
|
|
126
|
-
change.index = change.index.to_sym
|
|
127
97
|
change.from = cast_column_value(root, change.index, change.from)
|
|
128
98
|
change.to = cast_column_value(root, change.index, change.to)
|
|
129
99
|
change
|
|
@@ -3,7 +3,6 @@ require 'damerau-levenshtein'
|
|
|
3
3
|
module Glib
|
|
4
4
|
module JsonCrawler
|
|
5
5
|
class Router
|
|
6
|
-
attr_reader :read_only_actions # deprecated
|
|
7
6
|
attr_reader :logger, :last_log, :deferred_actions
|
|
8
7
|
attr_reader :http_actions
|
|
9
8
|
attr_accessor :host, :skip_similar_page
|
|
@@ -55,7 +54,6 @@ module Glib
|
|
|
55
54
|
@depth = -1
|
|
56
55
|
@logger = ''
|
|
57
56
|
@visitor = Glib::Json::Traversal::Visitor.new(crawler_test: true)
|
|
58
|
-
@read_only_actions = Set.new
|
|
59
57
|
@http_actions = Set.new
|
|
60
58
|
# default rails's development host
|
|
61
59
|
@host ||= 'localhost:3000'
|
|
@@ -94,7 +92,6 @@ module Glib
|
|
|
94
92
|
end
|
|
95
93
|
end
|
|
96
94
|
|
|
97
|
-
# @read_only_actions.replace(@read_only_actions.sort_by { |e| e[1].to_s })
|
|
98
95
|
end
|
|
99
96
|
|
|
100
97
|
def process_action(http, spec)
|
|
@@ -116,14 +113,12 @@ module Glib
|
|
|
116
113
|
# of the word, not a separator), so the normalized name missed this
|
|
117
114
|
# branch and the crawl logged the entry without ever executing it.
|
|
118
115
|
when 'initiate/navigation'
|
|
119
|
-
# @read_only_actions.add([action, params['url']])
|
|
120
116
|
http_actions.add([action, params['url']])
|
|
121
117
|
JsonCrawler::NavInitiate.new(http, params, action)
|
|
122
118
|
when 'runMultiple'
|
|
123
119
|
JsonCrawler::RunMultiple.new(http, params, action)
|
|
124
120
|
when 'windows/open', 'dialogs/open', 'windows/reload', 'windows/openWeb'
|
|
125
121
|
if allowed?(params['url'])
|
|
126
|
-
# @read_only_actions.add([action, params['url']])
|
|
127
122
|
http_actions.add([action, params['url']])
|
|
128
123
|
JsonCrawler::WindowsOpen.new(http, params, action)
|
|
129
124
|
else
|
|
@@ -168,7 +163,6 @@ module Glib
|
|
|
168
163
|
].include?(
|
|
169
164
|
action
|
|
170
165
|
)
|
|
171
|
-
# @read_only_actions.add([action, params['url']])
|
|
172
166
|
http_actions.add([action, params['url']])
|
|
173
167
|
end
|
|
174
168
|
self.log action, params['url']
|
|
@@ -181,24 +175,6 @@ module Glib
|
|
|
181
175
|
@visitor.forms.last
|
|
182
176
|
end
|
|
183
177
|
|
|
184
|
-
# deprecated
|
|
185
|
-
# def follow(http, target_routers)
|
|
186
|
-
# if !target_routers.is_a?(Array)
|
|
187
|
-
# target_routers = [target_routers]
|
|
188
|
-
# end
|
|
189
|
-
|
|
190
|
-
# target_actions = Set.new
|
|
191
|
-
# target_routers.each do |router|
|
|
192
|
-
# target_actions += router.read_only_actions
|
|
193
|
-
# end
|
|
194
|
-
|
|
195
|
-
# @depth += 1
|
|
196
|
-
# target_actions.each do |crawler_action|
|
|
197
|
-
# action, url = crawler_action
|
|
198
|
-
# http.get(url, action, {})
|
|
199
|
-
# end
|
|
200
|
-
# end
|
|
201
|
-
|
|
202
178
|
def follow_v2(http, crawler_actions)
|
|
203
179
|
@depth += 1
|
|
204
180
|
crawler_actions.each do |crawler_action|
|
data/lib/glib/json_ui/config.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Glib
|
|
|
19
19
|
|
|
20
20
|
# The shipped default. Stays '/' until the next major version, when it
|
|
21
21
|
# becomes '_'. Apps opt in early via `Config.name_separator = '_'`.
|
|
22
|
-
DEFAULT_NAME_SEPARATOR = '
|
|
22
|
+
DEFAULT_NAME_SEPARATOR = '_'
|
|
23
23
|
|
|
24
24
|
@@name_separator = DEFAULT_NAME_SEPARATOR
|
|
25
25
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glib-web
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 7.0.0.beta1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activestorage
|
|
@@ -24,20 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '8.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: activejob
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '8.0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '8.0'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
27
|
name: pundit
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,7 +177,6 @@ dependencies:
|
|
|
192
177
|
- - ">="
|
|
193
178
|
- !ruby/object:Gem::Version
|
|
194
179
|
version: '0'
|
|
195
|
-
description:
|
|
196
180
|
email: ''
|
|
197
181
|
executables: []
|
|
198
182
|
extensions: []
|
|
@@ -265,11 +249,9 @@ files:
|
|
|
265
249
|
- app/helpers/glib/json_ui/view_builder/multimedia.rb
|
|
266
250
|
- app/helpers/glib/json_ui/view_builder/panels.rb
|
|
267
251
|
- app/helpers/glib/urls_helper.rb
|
|
268
|
-
- app/jobs/glib/purge_unattached_job.rb
|
|
269
252
|
- app/models/concerns/glib/enum_humanization.rb
|
|
270
253
|
- app/models/concerns/glib/enum_symbolization.rb
|
|
271
254
|
- app/models/concerns/glib/nilify_blanks.rb
|
|
272
|
-
- app/models/concerns/glib/snapshot_v2.rb
|
|
273
255
|
- app/models/concerns/glib/soft_deletable.rb
|
|
274
256
|
- app/models/glib/active_storage/attachment.rb
|
|
275
257
|
- app/models/glib/active_storage/blob.rb
|
|
@@ -277,11 +259,8 @@ files:
|
|
|
277
259
|
- app/models/glib/country_list.rb
|
|
278
260
|
- app/models/glib/dummy_job_application.rb
|
|
279
261
|
- app/models/glib/dynamic_text_record.rb
|
|
280
|
-
- app/models/glib/model.rb
|
|
281
|
-
- app/models/glib/plain_model.rb
|
|
282
262
|
- app/models/glib/state_list.rb
|
|
283
263
|
- app/models/glib/text.rb
|
|
284
|
-
- app/models/snapshot_blob_reference.rb
|
|
285
264
|
- app/policies/glib/application_policy.rb
|
|
286
265
|
- app/validators/email_typo_validator.rb
|
|
287
266
|
- app/validators/email_validator.rb
|
|
@@ -526,7 +505,6 @@ files:
|
|
|
526
505
|
- app/views/json_ui/garage/views/calendar_data.json.jbuilder
|
|
527
506
|
- app/views/json_ui/garage/views/charts.json.jbuilder
|
|
528
507
|
- app/views/json_ui/garage/views/components_replace.json.jbuilder
|
|
529
|
-
- app/views/json_ui/garage/views/components_set.json.jbuilder
|
|
530
508
|
- app/views/json_ui/garage/views/controls.json.jbuilder
|
|
531
509
|
- app/views/json_ui/garage/views/fields_focus.json.jbuilder
|
|
532
510
|
- app/views/json_ui/garage/views/iap.json.jbuilder
|
|
@@ -535,6 +513,7 @@ files:
|
|
|
535
513
|
- app/views/json_ui/garage/views/images.json.jbuilder
|
|
536
514
|
- app/views/json_ui/garage/views/index.json.jbuilder
|
|
537
515
|
- app/views/json_ui/garage/views/links.json.jbuilder
|
|
516
|
+
- app/views/json_ui/garage/views/logics_set.json.jbuilder
|
|
538
517
|
- app/views/json_ui/garage/views/map_cluster_data.json.jbuilder
|
|
539
518
|
- app/views/json_ui/garage/views/map_data.json.jbuilder
|
|
540
519
|
- app/views/json_ui/garage/views/map_direction_data.json.jbuilder
|
|
@@ -553,15 +532,12 @@ files:
|
|
|
553
532
|
- config/routes.rb
|
|
554
533
|
- lib/active_storage/service/glib_s3_service.rb
|
|
555
534
|
- lib/generators/glib/install_generator.rb
|
|
556
|
-
- lib/generators/glib/snapshot_v2_generator.rb
|
|
557
535
|
- lib/generators/templates/20191017062519_create_texts.rb
|
|
558
536
|
- lib/generators/templates/20191024063257_add_scope_to_texts.rb
|
|
559
537
|
- lib/generators/templates/20191112095018_add_lang_to_texts.rb
|
|
560
538
|
- lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb
|
|
561
539
|
- lib/generators/templates/database.yml
|
|
562
540
|
- lib/generators/templates/dynamic_text.rb
|
|
563
|
-
- lib/generators/templates/snapshot_v2/add_snapshot_v2_columns.rb
|
|
564
|
-
- lib/generators/templates/snapshot_v2/create_snapshot_blob_references.rb
|
|
565
541
|
- lib/glib-web.rb
|
|
566
542
|
- lib/glib/all_helpers.rb
|
|
567
543
|
- lib/glib/crypt/utils.rb
|
|
@@ -602,10 +578,8 @@ files:
|
|
|
602
578
|
- lib/glib/time_returning_mailer.rb
|
|
603
579
|
- lib/glib/value.rb
|
|
604
580
|
- lib/tasks/db.rake
|
|
605
|
-
homepage:
|
|
606
581
|
licenses: []
|
|
607
582
|
metadata: {}
|
|
608
|
-
post_install_message:
|
|
609
583
|
rdoc_options: []
|
|
610
584
|
require_paths:
|
|
611
585
|
- lib
|
|
@@ -620,8 +594,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
620
594
|
- !ruby/object:Gem::Version
|
|
621
595
|
version: '0'
|
|
622
596
|
requirements: []
|
|
623
|
-
rubygems_version:
|
|
624
|
-
signing_key:
|
|
597
|
+
rubygems_version: 4.0.16
|
|
625
598
|
specification_version: 4
|
|
626
599
|
summary: ''
|
|
627
600
|
test_files: []
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Glib
|
|
2
|
-
# Daily cleanup for ActiveStorage blobs that have no attachments. Excludes blobs referenced by
|
|
3
|
-
# any `SnapshotBlobReference` row, so old file versions that still appear in some snapshot's
|
|
4
|
-
# timeline (i.e. a previous version of an attached file) survive the purge.
|
|
5
|
-
#
|
|
6
|
-
# Opt-in: if the host app has not run the gem's `create_snapshot_blob_references` migration,
|
|
7
|
-
# `SnapshotBlobReference.table_exists?` is false and the exclusion subquery short-circuits —
|
|
8
|
-
# the job then behaves identically to Rails' built-in unattached-blob cleanup, just delayed
|
|
9
|
-
# by 8 hours to give upload flows time to attach.
|
|
10
|
-
#
|
|
11
|
-
# Schedule from the host app (e.g. via sidekiq-cron):
|
|
12
|
-
# Glib::PurgeUnattachedJob.perform_later
|
|
13
|
-
class PurgeUnattachedJob < ApplicationJob
|
|
14
|
-
queue_as :cleanup
|
|
15
|
-
|
|
16
|
-
def perform(*_args)
|
|
17
|
-
scope = ActiveStorage::Blob
|
|
18
|
-
.unattached
|
|
19
|
-
.where('active_storage_blobs.created_at < ?', 8.hours.ago)
|
|
20
|
-
|
|
21
|
-
if SnapshotBlobReference.table_exists?
|
|
22
|
-
scope = scope.where.not(id: SnapshotBlobReference.select(:blob_id))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
scope.find_each(&:purge_later)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|