paper_trail_diff 0.17.0 → 0.18.0
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/CHANGELOG.md +663 -0
- data/QUICKSTART.md +12 -14
- data/README.md +32 -30
- data/docs/architecture.md +65 -29
- data/docs/performance.md +161 -46
- data/docs/reference.md +495 -394
- data/docs/testing.md +9 -15
- data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +42 -9
- data/lib/paper_trail_diff/activity_boundary.rb +15 -6
- data/lib/paper_trail_diff/activity_child_candidate_loader.rb +91 -18
- data/lib/paper_trail_diff/activity_collection_event_applier.rb +14 -15
- data/lib/paper_trail_diff/activity_collection_record_updater.rb +18 -8
- data/lib/paper_trail_diff/activity_collection_route_updater.rb +12 -25
- data/lib/paper_trail_diff/activity_event.rb +53 -34
- data/lib/paper_trail_diff/activity_event_record_normalizer.rb +12 -26
- data/lib/paper_trail_diff/activity_event_record_resolver.rb +45 -32
- data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +26 -33
- data/lib/paper_trail_diff/activity_history.rb +28 -34
- data/lib/paper_trail_diff/activity_relationship.rb +3 -26
- data/lib/paper_trail_diff/activity_root_snapshot_refresher.rb +14 -8
- data/lib/paper_trail_diff/activity_snapshot_delta.rb +2 -3
- data/lib/paper_trail_diff/activity_snapshot_sequence.rb +92 -25
- data/lib/paper_trail_diff/activity_timeline_builder.rb +128 -77
- data/lib/paper_trail_diff/activity_transaction_applier.rb +49 -0
- data/lib/paper_trail_diff/activity_tree_filter.rb +70 -57
- data/lib/paper_trail_diff/activity_tree_places.rb +76 -0
- data/lib/paper_trail_diff/activity_version_collector.rb +45 -32
- data/lib/paper_trail_diff/activity_view.rb +2 -0
- data/lib/paper_trail_diff/analysis.rb +6 -5
- data/lib/paper_trail_diff/analysis_batch.rb +21 -17
- data/lib/paper_trail_diff/association_activity_edge.rb +99 -85
- data/lib/paper_trail_diff/association_activity_selection.rb +46 -14
- data/lib/paper_trail_diff/association_discovery.rb +4 -4
- data/lib/paper_trail_diff/association_key.rb +10 -18
- data/lib/paper_trail_diff/association_traversal.rb +72 -92
- data/lib/paper_trail_diff/batch_boundary_resolver.rb +1 -7
- data/lib/paper_trail_diff/batch_preload.rb +2 -3
- data/lib/paper_trail_diff/batched_root_analyses.rb +60 -25
- data/lib/paper_trail_diff/batched_root_analyzer.rb +5 -5
- data/lib/paper_trail_diff/batched_root_versions.rb +7 -30
- data/lib/paper_trail_diff/branch_snapshot_refresher.rb +19 -14
- data/lib/paper_trail_diff/candidate_table.rb +160 -0
- data/lib/paper_trail_diff/change_attribution.rb +35 -28
- data/lib/paper_trail_diff/collection_identity_index.rb +68 -24
- data/lib/paper_trail_diff/collection_transition.rb +3 -3
- data/lib/paper_trail_diff/comparison_batch.rb +13 -6
- data/lib/paper_trail_diff/database_time.rb +85 -0
- data/lib/paper_trail_diff/deleted_analysis_batch.rb +22 -23
- data/lib/paper_trail_diff/deleted_root_filter.rb +10 -6
- data/lib/paper_trail_diff/diagnostics.rb +26 -86
- data/lib/paper_trail_diff/endpoint.rb +37 -5
- data/lib/paper_trail_diff/engine.rb +1 -1
- data/lib/paper_trail_diff/errors.rb +0 -6
- data/lib/paper_trail_diff/exact_column_type.rb +96 -0
- data/lib/paper_trail_diff/historical_snapshot_store.rb +88 -83
- data/lib/paper_trail_diff/instrumentation.rb +0 -8
- data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +1 -4
- data/lib/paper_trail_diff/live_graph_collector.rb +1 -3
- data/lib/paper_trail_diff/nested_comparator.rb +42 -10
- data/lib/paper_trail_diff/paper_trail_adapter.rb +55 -98
- data/lib/paper_trail_diff/prepared_activity_index.rb +235 -179
- data/lib/paper_trail_diff/prepared_child_candidates.rb +13 -3
- data/lib/paper_trail_diff/prepared_edge_loader.rb +11 -49
- data/lib/paper_trail_diff/prepared_history.rb +27 -177
- data/lib/paper_trail_diff/prepared_history_loader.rb +39 -57
- data/lib/paper_trail_diff/prepared_record_index.rb +221 -147
- data/lib/paper_trail_diff/prepared_snapshot_builder.rb +47 -42
- data/lib/paper_trail_diff/prepared_state_association_reader.rb +85 -62
- data/lib/paper_trail_diff/recorded_changes.rb +34 -10
- data/lib/paper_trail_diff/recorded_owner.rb +67 -0
- data/lib/paper_trail_diff/root_version_selection.rb +6 -2
- data/lib/paper_trail_diff/scope_condition.rb +120 -80
- data/lib/paper_trail_diff/scope_ranking.rb +14 -32
- data/lib/paper_trail_diff/scoped_analysis.rb +11 -6
- data/lib/paper_trail_diff/scoped_analysis_builder.rb +17 -11
- data/lib/paper_trail_diff/scoped_root_selection.rb +91 -85
- data/lib/paper_trail_diff/selection_window.rb +31 -0
- data/lib/paper_trail_diff/snapshot.rb +60 -58
- data/lib/paper_trail_diff/snapshot_members.rb +115 -0
- data/lib/paper_trail_diff/snapshot_normalizer.rb +0 -11
- data/lib/paper_trail_diff/step.rb +1 -5
- data/lib/paper_trail_diff/stored_form.rb +146 -0
- data/lib/paper_trail_diff/stored_json_values.rb +8 -5
- data/lib/paper_trail_diff/stored_time_precision.rb +67 -33
- data/lib/paper_trail_diff/stored_values.rb +35 -3
- data/lib/paper_trail_diff/support.rb +185 -35
- data/lib/paper_trail_diff/time_of_day.rb +13 -2
- data/lib/paper_trail_diff/time_range.rb +85 -11
- data/lib/paper_trail_diff/time_version_range.rb +5 -1
- data/lib/paper_trail_diff/timeline_builder.rb +5 -11
- data/lib/paper_trail_diff/timeline_range.rb +56 -19
- data/lib/paper_trail_diff/timeline_snapshot_provider.rb +31 -7
- data/lib/paper_trail_diff/total_order.rb +19 -5
- data/lib/paper_trail_diff/transaction_anchors.rb +138 -0
- data/lib/paper_trail_diff/transaction_cut.rb +67 -327
- data/lib/paper_trail_diff/transaction_ends.rb +194 -0
- data/lib/paper_trail_diff/traversal_preparer.rb +12 -24
- data/lib/paper_trail_diff/{approximate_paths.rb → unreadable_paths.rb} +8 -9
- data/lib/paper_trail_diff/value_objects.rb +8 -6
- data/lib/paper_trail_diff/version.rb +1 -1
- data/lib/paper_trail_diff/version_association_candidate_scope.rb +28 -4
- data/lib/paper_trail_diff/version_boundary.rb +0 -29
- data/lib/paper_trail_diff/version_query.rb +49 -1
- data/lib/paper_trail_diff/version_scope_filter.rb +74 -5
- data/lib/paper_trail_diff/version_sequence_diagnostics.rb +4 -31
- data/lib/paper_trail_diff/version_table.rb +8 -1
- data/lib/paper_trail_diff.rb +56 -110
- data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +24 -2
- data/sig/generated/paper_trail_diff/activity_boundary.rbs +6 -0
- data/sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs +46 -5
- data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +7 -4
- data/sig/generated/paper_trail_diff/activity_collection_record_updater.rbs +11 -2
- data/sig/generated/paper_trail_diff/activity_collection_route_updater.rbs +8 -6
- data/sig/generated/paper_trail_diff/activity_event.rbs +27 -18
- data/sig/generated/paper_trail_diff/activity_event_record_normalizer.rbs +7 -11
- data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +26 -8
- data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +10 -2
- data/sig/generated/paper_trail_diff/activity_history.rbs +23 -26
- data/sig/generated/paper_trail_diff/activity_relationship.rbs +0 -6
- data/sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs +5 -0
- data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +53 -10
- data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +64 -38
- data/sig/generated/paper_trail_diff/activity_transaction_applier.rbs +28 -0
- data/sig/generated/paper_trail_diff/activity_tree_filter.rbs +46 -38
- data/sig/generated/paper_trail_diff/activity_tree_places.rbs +45 -0
- data/sig/generated/paper_trail_diff/activity_version_collector.rbs +21 -11
- data/sig/generated/paper_trail_diff/analysis.rbs +6 -5
- data/sig/generated/paper_trail_diff/analysis_batch.rbs +8 -6
- data/sig/generated/paper_trail_diff/association_activity_edge.rbs +58 -45
- data/sig/generated/paper_trail_diff/association_activity_selection.rbs +20 -3
- data/sig/generated/paper_trail_diff/association_discovery.rbs +2 -2
- data/sig/generated/paper_trail_diff/association_key.rbs +2 -11
- data/sig/generated/paper_trail_diff/association_traversal.rbs +43 -44
- data/sig/generated/paper_trail_diff/batch_boundary_resolver.rbs +0 -2
- data/sig/generated/paper_trail_diff/batched_root_analyses.rbs +40 -17
- data/sig/generated/paper_trail_diff/batched_root_analyzer.rbs +2 -2
- data/sig/generated/paper_trail_diff/batched_root_versions.rbs +2 -11
- data/sig/generated/paper_trail_diff/branch_snapshot_refresher.rbs +12 -8
- data/sig/generated/paper_trail_diff/candidate_table.rbs +97 -0
- data/sig/generated/paper_trail_diff/change_attribution.rbs +21 -19
- data/sig/generated/paper_trail_diff/collection_identity_index.rbs +33 -13
- data/sig/generated/paper_trail_diff/collection_transition.rbs +2 -2
- data/sig/generated/paper_trail_diff/comparison_batch.rbs +5 -0
- data/sig/generated/paper_trail_diff/database_time.rbs +48 -0
- data/sig/generated/paper_trail_diff/deleted_analysis_batch.rbs +13 -15
- data/sig/generated/paper_trail_diff/deleted_root_filter.rbs +4 -0
- data/sig/generated/paper_trail_diff/diagnostics.rbs +13 -31
- data/sig/generated/paper_trail_diff/endpoint.rbs +14 -1
- data/sig/generated/paper_trail_diff/errors.rbs +0 -8
- data/sig/generated/paper_trail_diff/exact_column_type.rbs +51 -0
- data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +51 -31
- data/sig/generated/paper_trail_diff/instrumentation.rbs +0 -5
- data/sig/generated/paper_trail_diff/nested_comparator.rbs +21 -0
- data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +18 -29
- data/sig/generated/paper_trail_diff/prepared_activity_index.rbs +149 -94
- data/sig/generated/paper_trail_diff/prepared_child_candidates.rbs +10 -2
- data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +4 -21
- data/sig/generated/paper_trail_diff/prepared_history.rbs +22 -79
- data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +24 -32
- data/sig/generated/paper_trail_diff/prepared_record_index.rbs +137 -63
- data/sig/generated/paper_trail_diff/prepared_snapshot_builder.rbs +22 -13
- data/sig/generated/paper_trail_diff/prepared_state_association_reader.rbs +41 -28
- data/sig/generated/paper_trail_diff/recorded_changes.rbs +19 -3
- data/sig/generated/paper_trail_diff/recorded_owner.rbs +39 -0
- data/sig/generated/paper_trail_diff/root_version_selection.rbs +4 -1
- data/sig/generated/paper_trail_diff/scope_condition.rbs +65 -52
- data/sig/generated/paper_trail_diff/scope_ranking.rbs +10 -23
- data/sig/generated/paper_trail_diff/scoped_analysis.rbs +11 -6
- data/sig/generated/paper_trail_diff/scoped_analysis_builder.rbs +7 -2
- data/sig/generated/paper_trail_diff/scoped_root_selection.rbs +49 -43
- data/sig/generated/paper_trail_diff/selection_window.rbs +19 -0
- data/sig/generated/paper_trail_diff/snapshot.rbs +37 -38
- data/sig/generated/paper_trail_diff/snapshot_members.rbs +58 -0
- data/sig/generated/paper_trail_diff/snapshot_normalizer.rbs +0 -4
- data/sig/generated/paper_trail_diff/stored_form.rbs +63 -0
- data/sig/generated/paper_trail_diff/stored_json_values.rbs +0 -2
- data/sig/generated/paper_trail_diff/stored_time_precision.rbs +33 -20
- data/sig/generated/paper_trail_diff/stored_values.rbs +18 -2
- data/sig/generated/paper_trail_diff/support.rbs +96 -16
- data/sig/generated/paper_trail_diff/time_of_day.rbs +4 -0
- data/sig/generated/paper_trail_diff/time_range.rbs +49 -4
- data/sig/generated/paper_trail_diff/time_version_range.rbs +3 -0
- data/sig/generated/paper_trail_diff/timeline_builder.rbs +3 -6
- data/sig/generated/paper_trail_diff/timeline_range.rbs +29 -8
- data/sig/generated/paper_trail_diff/timeline_snapshot_provider.rbs +17 -4
- data/sig/generated/paper_trail_diff/total_order.rbs +9 -3
- data/sig/generated/paper_trail_diff/transaction_anchors.rbs +80 -0
- data/sig/generated/paper_trail_diff/transaction_cut.rbs +43 -176
- data/sig/generated/paper_trail_diff/transaction_ends.rbs +124 -0
- data/sig/generated/paper_trail_diff/traversal_preparer.rbs +6 -11
- data/sig/generated/paper_trail_diff/{approximate_paths.rbs → unreadable_paths.rbs} +6 -7
- data/sig/generated/paper_trail_diff/value_objects.rbs +4 -2
- data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +16 -2
- data/sig/generated/paper_trail_diff/version_boundary.rbs +0 -14
- data/sig/generated/paper_trail_diff/version_query.rbs +26 -0
- data/sig/generated/paper_trail_diff/version_scope_filter.rbs +28 -2
- data/sig/generated/paper_trail_diff/version_sequence_diagnostics.rbs +4 -15
- data/sig/generated/paper_trail_diff/version_table.rbs +4 -0
- data/sig/generated/paper_trail_diff.rbs +22 -23
- metadata +28 -20
- data/lib/paper_trail_diff/activity_target_candidate_loader.rb +0 -123
- data/lib/paper_trail_diff/fallback_paths.rb +0 -35
- data/lib/paper_trail_diff/habtm_transaction_owners.rb +0 -70
- data/lib/paper_trail_diff/historical_association_reifier.rb +0 -161
- data/lib/paper_trail_diff/historical_filter.rb +0 -210
- data/lib/paper_trail_diff/own_window.rb +0 -35
- data/lib/paper_trail_diff/prepared_association_reifier.rb +0 -51
- data/sig/generated/paper_trail_diff/activity_target_candidate_loader.rbs +0 -74
- data/sig/generated/paper_trail_diff/fallback_paths.rbs +0 -22
- data/sig/generated/paper_trail_diff/habtm_transaction_owners.rbs +0 -41
- data/sig/generated/paper_trail_diff/historical_association_reifier.rbs +0 -58
- data/sig/generated/paper_trail_diff/historical_filter.rbs +0 -96
- data/sig/generated/paper_trail_diff/own_window.rbs +0 -22
- data/sig/generated/paper_trail_diff/prepared_association_reifier.rbs +0 -27
|
@@ -6,29 +6,20 @@ module PaperTrailDiff
|
|
|
6
6
|
# record's state there rather than by a query. A limit, offset or has_one
|
|
7
7
|
# order then ranks the records that meet the conditions (ScopeRanking). It
|
|
8
8
|
# reads the relation the scope builds once and never runs application code
|
|
9
|
-
# per record. A scope it cannot read exactly builds no condition, and
|
|
10
|
-
#
|
|
9
|
+
# per record. A scope it cannot read exactly builds no condition, and a
|
|
10
|
+
# request that names it is refused (UnreadablePaths).
|
|
11
11
|
class ScopeCondition
|
|
12
|
-
# Relation parts that
|
|
13
|
-
# ranking
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
LOADING_VALUES: untyped
|
|
18
|
-
|
|
19
|
-
# Types whose stored values compare in Ruby as the database compares them,
|
|
20
|
-
# named rather than referenced so that loading needs no Active Model.
|
|
21
|
-
VALUE_TYPES: untyped
|
|
22
|
-
|
|
23
|
-
TEXT_TYPE: ::String
|
|
24
|
-
|
|
25
|
-
ENUM_TYPE: ::String
|
|
12
|
+
# Relation parts that choose rows other than by the where clause and the
|
|
13
|
+
# ranking the reader follows. Any other part, such as a lock, a comment,
|
|
14
|
+
# a table named for a string order, or what to load, leaves membership
|
|
15
|
+
# alone; `reverse_order` is applied to the order at once.
|
|
16
|
+
ROW_CHOOSING_VALUES: untyped
|
|
26
17
|
|
|
27
18
|
BIND_PARAM: ::String
|
|
28
19
|
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
|
|
20
|
+
# Column kinds (ExactColumnType) whose values compare for equality in
|
|
21
|
+
# Ruby as the database compares them.
|
|
22
|
+
COMPARABLE_KINDS: untyped
|
|
32
23
|
|
|
33
24
|
# Raised while reading a node that has no exact plain-Ruby reading.
|
|
34
25
|
class Unreadable < StandardError
|
|
@@ -57,6 +48,13 @@ module PaperTrailDiff
|
|
|
57
48
|
# : (untyped, untyped) -> ScopeCondition?
|
|
58
49
|
def self.for_relation: (untyped, untyped) -> ScopeCondition?
|
|
59
50
|
|
|
51
|
+
# A destroyed record's state holds a column `has_paper_trail skip:`
|
|
52
|
+
# leaves out of history only as its default. A default scope is read
|
|
53
|
+
# with it so; a condition the caller wrote is refused. PaperTrail lists
|
|
54
|
+
# the skipped columns by name.
|
|
55
|
+
# : (untyped, untyped) -> void
|
|
56
|
+
def self.check_recorded!: (untyped, untyped) -> void
|
|
57
|
+
|
|
60
58
|
# A relation `none` built, whose where clause is SQL text. A condition
|
|
61
59
|
# that matches nothing reads no attribute, so it names no model.
|
|
62
60
|
# : () -> ScopeCondition
|
|
@@ -86,9 +84,16 @@ module PaperTrailDiff
|
|
|
86
84
|
def self.scoped_relation: (untyped, untyped) -> untyped
|
|
87
85
|
|
|
88
86
|
# Some parts, such as the having clause `or` sets, may be present but
|
|
89
|
-
# empty.
|
|
90
|
-
# : (untyped
|
|
91
|
-
def self.plain_relation?: (untyped
|
|
87
|
+
# empty.
|
|
88
|
+
# : (untyped) -> bool
|
|
89
|
+
def self.plain_relation?: (untyped) -> bool
|
|
90
|
+
|
|
91
|
+
# Join rows in primary key order, the order whose first target an
|
|
92
|
+
# unordered has_one through reads (see #first). The block names a row's
|
|
93
|
+
# model; rows with no key yet come last, as given. Saved rows' keys
|
|
94
|
+
# differ.
|
|
95
|
+
# : (Array[untyped]) { (untyped) -> untyped } -> Array[untyped]
|
|
96
|
+
def self.in_key_order: (Array[untyped]) { (untyped) -> untyped } -> Array[untyped]
|
|
92
97
|
|
|
93
98
|
# : (untyped, Array[untyped], ?ScopeRanking?) -> void
|
|
94
99
|
def initialize: (untyped, Array[untyped], ?ScopeRanking?) -> void
|
|
@@ -107,6 +112,17 @@ module PaperTrailDiff
|
|
|
107
112
|
# : (Array[untyped]) -> Array[untyped]
|
|
108
113
|
def members: (Array[untyped]) -> Array[untyped]
|
|
109
114
|
|
|
115
|
+
# The one record a has_one reads of several that meet its conditions:
|
|
116
|
+
# the first as ranked, or without an order of its own, the one with the
|
|
117
|
+
# lowest primary key. Active Record reads an unordered has_one with
|
|
118
|
+
# LIMIT 1, which SQLite, MySQL and SQL Server answer in key order for a
|
|
119
|
+
# clustered or indexed key; reading any other row would differ from the
|
|
120
|
+
# current record where nothing changed. PostgreSQL promises no order. A
|
|
121
|
+
# has_one through gives its records in the order of its join rows, whose
|
|
122
|
+
# first target is the one Active Record reads (see AssociationTraversal.join_order?).
|
|
123
|
+
# : (Array[untyped], ?in_order: bool) -> Array[untyped]
|
|
124
|
+
def first: (Array[untyped], ?in_order: bool) -> Array[untyped]
|
|
125
|
+
|
|
110
126
|
# Records that meet the conditions, as ranked; unchanged without a
|
|
111
127
|
# ranking.
|
|
112
128
|
# : (Array[untyped]) -> Array[untyped]
|
|
@@ -118,9 +134,6 @@ module PaperTrailDiff
|
|
|
118
134
|
# unknown where false would become true.
|
|
119
135
|
COMPARISONS: untyped
|
|
120
136
|
|
|
121
|
-
# Comparisons that order values, which read them as ScopeRanking sorts.
|
|
122
|
-
ORDERED: untyped
|
|
123
|
-
|
|
124
137
|
private
|
|
125
138
|
|
|
126
139
|
@model_class: untyped
|
|
@@ -144,11 +157,12 @@ module PaperTrailDiff
|
|
|
144
157
|
# : (bool?) -> bool?
|
|
145
158
|
def negate: (bool?) -> bool?
|
|
146
159
|
|
|
147
|
-
# The
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
|
|
160
|
+
# The value the database compares and sorts by, as the scope's own
|
|
161
|
+
# values were read (see ScopeRanking.sort_value): SQL Server holds a time
|
|
162
|
+
# or date in a wrapper that only compares for equality, and history may
|
|
163
|
+
# hold either as text.
|
|
164
|
+
# : (String, Hash[String, untyped]) -> untyped
|
|
165
|
+
def stored: (String, Hash[String, untyped]) -> untyped
|
|
152
166
|
|
|
153
167
|
# Builds each reflection's condition once per target class.
|
|
154
168
|
class Cache
|
|
@@ -159,18 +173,13 @@ module PaperTrailDiff
|
|
|
159
173
|
# : (untyped, ?untyped, ?ranked: bool) -> ScopeCondition?
|
|
160
174
|
def call: (untyped, ?untyped, ?ranked: bool) -> ScopeCondition?
|
|
161
175
|
|
|
162
|
-
# The records the reflection's scope admits, as it ranks them. Its
|
|
163
|
-
# condition must exist.
|
|
164
|
-
# : (untyped, Array[untyped], ?untyped, ranked: bool) -> Array[untyped]
|
|
165
|
-
def select: (untyped, Array[untyped], ?untyped, ranked: bool) -> Array[untyped]
|
|
166
|
-
|
|
167
176
|
@conditions: Hash[Array[untyped], ScopeCondition?]
|
|
168
177
|
end
|
|
169
178
|
|
|
170
179
|
# Compiles a where clause into nested arrays of plain comparisons.
|
|
171
180
|
class Reader
|
|
172
|
-
# : (untyped) -> void
|
|
173
|
-
def initialize: (untyped) -> void
|
|
181
|
+
# : (untyped, ?refused: Array[String]) -> void
|
|
182
|
+
def initialize: (untyped, ?refused: Array[String]) -> void
|
|
174
183
|
|
|
175
184
|
# : (untyped) -> Array[untyped]
|
|
176
185
|
def call: (untyped) -> Array[untyped]
|
|
@@ -201,9 +210,14 @@ module PaperTrailDiff
|
|
|
201
210
|
|
|
202
211
|
# A bound in the form the database holds, read back as the value the
|
|
203
212
|
# database sorts by. Reading it back unwraps what an adapter wraps.
|
|
213
|
+
# SQLite keeps a time as text and compares a date with it as text, so
|
|
214
|
+
# a date there is no midnight, and is left unread.
|
|
204
215
|
# : (String, untyped) -> untyped
|
|
205
216
|
def sort_value: (String, untyped) -> untyped
|
|
206
217
|
|
|
218
|
+
# : (String, untyped) -> bool
|
|
219
|
+
def text_date?: (String, untyped) -> bool
|
|
220
|
+
|
|
207
221
|
# Whether a value is NULL compares alike on every type.
|
|
208
222
|
# : (Symbol, untyped) -> Array[untyped]
|
|
209
223
|
def binary: (Symbol, untyped) -> Array[untyped]
|
|
@@ -211,28 +225,27 @@ module PaperTrailDiff
|
|
|
211
225
|
# : (untyped) -> Array[untyped]
|
|
212
226
|
def homogeneous_in: (untyped) -> Array[untyped]
|
|
213
227
|
|
|
214
|
-
# Active Record writes an empty
|
|
215
|
-
#
|
|
228
|
+
# Active Record writes an empty IN as a condition that is always false
|
|
229
|
+
# and an empty NOT IN as one that is always true, for a NULL as for any
|
|
230
|
+
# value, so neither is unknown under NOT. A NOT IN list holding NULL
|
|
231
|
+
# matches no row.
|
|
216
232
|
# : (Symbol, untyped, Array[untyped]) -> Array[untyped]
|
|
217
233
|
def list: (Symbol, untyped, Array[untyped]) -> Array[untyped]
|
|
218
234
|
|
|
235
|
+
# A column that sorts in Ruby as in SQL (ScopeRanking) is compared as
|
|
236
|
+
# the value it sorts by, which the block reads from the expected one: a
|
|
237
|
+
# date, or a time history holds as it was stored, can be held as text.
|
|
238
|
+
# : (Symbol, untyped, untyped) { (String) -> untyped } -> Array[untyped]
|
|
239
|
+
def compared: (Symbol, untyped, untyped) { (String) -> untyped } -> Array[untyped]
|
|
240
|
+
|
|
219
241
|
# Ruby comparison stands in for SQL only on the record's own column of
|
|
220
|
-
# a type both compare alike. Whether a value is NULL,
|
|
221
|
-
# type compares alike.
|
|
242
|
+
# a type both compare alike (ExactColumnType). Whether a value is NULL,
|
|
243
|
+
# any column's type compares alike.
|
|
222
244
|
# : (untyped, ?null_test: bool) -> String
|
|
223
245
|
def column: (untyped, ?null_test: bool) -> String
|
|
224
246
|
|
|
225
|
-
# : (String
|
|
226
|
-
def comparable?: (String
|
|
227
|
-
|
|
228
|
-
# PostgreSQL's citext is text that compares without regard to case.
|
|
229
|
-
# : (untyped) -> bool
|
|
230
|
-
def exact_text?: (untyped) -> bool
|
|
231
|
-
|
|
232
|
-
# An enum compares the values it stores, which its subtype describes. A
|
|
233
|
-
# wrapper such as a serialized or encrypted type is none of these.
|
|
234
|
-
# : (untyped) -> untyped
|
|
235
|
-
def value_type: (untyped) -> untyped
|
|
247
|
+
# : (String) -> bool
|
|
248
|
+
def comparable?: (String) -> bool
|
|
236
249
|
|
|
237
250
|
# A list that is not plain values, such as a subquery, is unreadable.
|
|
238
251
|
# : (untyped) -> Array[untyped]
|
|
@@ -4,27 +4,17 @@ module PaperTrailDiff
|
|
|
4
4
|
# The order, offset and limit by which a scope picks its members from the
|
|
5
5
|
# records that meet its conditions, as the database would rank them. It is
|
|
6
6
|
# read only when the order is total and every key compares in Ruby as SQL
|
|
7
|
-
# compares it; otherwise build returns nil and the
|
|
8
|
-
#
|
|
7
|
+
# compares it; otherwise build returns nil and the scope is unreadable
|
|
8
|
+
# (UnreadablePaths).
|
|
9
9
|
class ScopeRanking
|
|
10
10
|
DIRECTIONS: untyped
|
|
11
11
|
|
|
12
12
|
ATTRIBUTE: ::String
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
TIME_ZONE_TYPE: ::String
|
|
19
|
-
|
|
20
|
-
# Integers, booleans and dates sort alike everywhere. Strings follow a
|
|
21
|
-
# collation, so they are not read.
|
|
22
|
-
ORDER_TYPES: untyped
|
|
23
|
-
|
|
24
|
-
# Times sort alike only at the precision both the column and history
|
|
25
|
-
# keep. A time of day is not read: in memory it keeps the date it was
|
|
26
|
-
# given, which the database drops.
|
|
27
|
-
DATETIME_TYPE: ::String
|
|
14
|
+
# Column kinds (ExactColumnType) that sort alike everywhere. Text follows
|
|
15
|
+
# a collation, so it is not read. Times sort alike only at the precision
|
|
16
|
+
# both the column and history keep.
|
|
17
|
+
ORDER_KINDS: untyped
|
|
28
18
|
|
|
29
19
|
# Where each adapter sorts NULL in an ascending order by default; a
|
|
30
20
|
# descending order reverses it. Another adapter's ranking is not read.
|
|
@@ -77,16 +67,13 @@ module PaperTrailDiff
|
|
|
77
67
|
# : (untyped, String, untyped) -> untyped
|
|
78
68
|
def self.sort_value: (untyped, String, untyped) -> untyped
|
|
79
69
|
|
|
80
|
-
# The type of the value a column stores, under an enum or time zone wrapper.
|
|
81
|
-
# : (untyped) -> untyped
|
|
82
|
-
def self.stored_type: (untyped) -> untyped
|
|
83
|
-
|
|
84
70
|
# Active Record truncates a time to its column's precision before writing
|
|
85
71
|
# it, so history holds the stored value when it keeps that many digits.
|
|
86
72
|
# Times the type stores in UTC sort as the instants they name; local
|
|
87
|
-
# times repeat an hour when clocks go back.
|
|
88
|
-
#
|
|
89
|
-
|
|
73
|
+
# times repeat an hour when clocks go back. A time-zone-aware type passes
|
|
74
|
+
# both questions to the time it wraps.
|
|
75
|
+
# : (untyped, String?) -> bool
|
|
76
|
+
def self.exact_time?: (untyped, String?) -> bool
|
|
90
77
|
|
|
91
78
|
# : (untyped, Array[[String, bool]], bool, Integer?, Integer) -> void
|
|
92
79
|
def initialize: (untyped, Array[[ String, bool ]], bool, Integer?, Integer) -> void
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Generated from lib/paper_trail_diff/scoped_analysis.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
|
-
# What
|
|
5
|
-
#
|
|
4
|
+
# What `analyze_scope` and `report` return: the analyses, plus the roots the
|
|
5
|
+
# relation could not reach.
|
|
6
6
|
#
|
|
7
7
|
# `to_ary` is defined so the pair destructures, which keeps the common case
|
|
8
|
-
# reading like the plain Hash
|
|
8
|
+
# reading like the plain Hash `analyze_many` returns:
|
|
9
9
|
#
|
|
10
|
-
# analyses, unreachable = PaperTrailDiff.
|
|
10
|
+
# analyses, unreachable = PaperTrailDiff.analyze_scope(Article.all, limit: 500)
|
|
11
11
|
#
|
|
12
12
|
# It deliberately does not pretend to be a Hash beyond that. Somebody
|
|
13
13
|
# iterating this object should have to decide which half they meant.
|
|
@@ -26,8 +26,13 @@ module PaperTrailDiff
|
|
|
26
26
|
# cannot prove which deleted rows matched. nil means no destroy history.
|
|
27
27
|
attr_reader deleted: Hash[Array[String], Analysis?]
|
|
28
28
|
|
|
29
|
-
#
|
|
30
|
-
|
|
29
|
+
# How many existing records the relation selects before its own `limit`
|
|
30
|
+
# and `offset`, for a pager's "page 2 of 6". Without either, it is
|
|
31
|
+
# `roots.length`. Deleted records are not counted; they are not paged.
|
|
32
|
+
attr_reader total: Integer
|
|
33
|
+
|
|
34
|
+
# : (analyses: Hash[Array[String], Analysis], unreachable: Array[Array[String]], ?roots: Array[untyped], ?deleted: Hash[Array[String], Analysis?], ?total: Integer?) -> void
|
|
35
|
+
def initialize: (analyses: Hash[Array[String], Analysis], unreachable: Array[Array[String]], ?roots: Array[untyped], ?deleted: Hash[Array[String], Analysis?], ?total: Integer?) -> void
|
|
31
36
|
|
|
32
37
|
# Each root's change rows, keyed as `analyses` is: the roots that still
|
|
33
38
|
# exist, then the deleted ones that have history to report. A deleted root
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
4
|
# Selects both populations and checks their shared ceiling before analysis.
|
|
5
5
|
class ScopedAnalysisBuilder
|
|
6
|
-
# : (untyped, limit: Integer?, within: untyped,
|
|
7
|
-
def initialize: (untyped, limit: Integer?, within: untyped,
|
|
6
|
+
# : (untyped, limit: Integer?, within: untyped, include_deleted: bool, analyzer: untyped, deleted_analyzer: untyped, ?activity_traversal: AssociationTraversal?, ?version_scope: untyped) -> void
|
|
7
|
+
def initialize: (untyped, limit: Integer?, within: untyped, include_deleted: bool, analyzer: untyped, deleted_analyzer: untyped, ?activity_traversal: AssociationTraversal?, ?version_scope: untyped) -> void
|
|
8
8
|
|
|
9
9
|
# : () -> ScopedAnalysis
|
|
10
10
|
def call: () -> ScopedAnalysis
|
|
11
11
|
|
|
12
12
|
private
|
|
13
13
|
|
|
14
|
+
# The window as the relation's version table keeps times. Anything but a
|
|
15
|
+
# relation or a model is left for the selection to refuse.
|
|
16
|
+
# : (untyped, untyped) -> TimeRange?
|
|
17
|
+
def time_range: (untyped, untyped) -> TimeRange?
|
|
18
|
+
|
|
14
19
|
# Without the option, the deleted roots are still tested when the
|
|
15
20
|
# relation can be read, so that another selection's are not listed.
|
|
16
21
|
# : (untyped, bool) -> DeletedRootFilter?
|
|
@@ -36,34 +36,39 @@ module PaperTrailDiff
|
|
|
36
36
|
|
|
37
37
|
attr_reader unreachable: Array[Array[String]]
|
|
38
38
|
|
|
39
|
-
#
|
|
40
|
-
|
|
39
|
+
# How many records the relation selects before its limit and offset.
|
|
40
|
+
attr_reader total: Integer
|
|
41
|
+
|
|
42
|
+
# : (records: Array[untyped], unreachable: Array[Array[String]], total: Integer) -> void
|
|
43
|
+
def initialize: (records: Array[untyped], unreachable: Array[Array[String]], total: Integer) -> void
|
|
41
44
|
end
|
|
42
45
|
|
|
43
|
-
# `
|
|
46
|
+
# `activity_traversal` names the association paths whose changes also select a
|
|
44
47
|
# root, as an activity analysis reports them. Without one, only a root's
|
|
45
48
|
# own versions select it. `version_scope` narrows which of either count,
|
|
46
|
-
# as it narrows which are reported.
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
49
|
+
# as it narrows which are reported.
|
|
50
|
+
#
|
|
51
|
+
# A window selects by the versions saved in it. A transaction that saves
|
|
52
|
+
# there and ends after it is reported in a later window (see
|
|
53
|
+
# TransactionEnds), so a root can be selected with nothing to report. One
|
|
54
|
+
# open at the window's start is reported in it, though it may have saved
|
|
55
|
+
# the root's tree only before it, so with associations the roots are
|
|
56
|
+
# selected from where the earliest such transaction began.
|
|
57
|
+
# : (untyped, time_range: TimeRange?, limit: Integer, ?activity_traversal: AssociationTraversal?, ?version_scope: untyped) -> void
|
|
58
|
+
def initialize: (untyped, time_range: TimeRange?, limit: Integer, ?activity_traversal: AssociationTraversal?, ?version_scope: untyped) -> void
|
|
50
59
|
|
|
51
60
|
# : () -> Result
|
|
52
61
|
def call: () -> Result
|
|
53
62
|
|
|
54
63
|
private
|
|
55
64
|
|
|
56
|
-
@historical_filter: untyped
|
|
57
|
-
|
|
58
65
|
@limit: Integer
|
|
59
66
|
|
|
60
|
-
@path_types: Array[String]
|
|
61
|
-
|
|
62
67
|
@related: AssociationActivitySelection?
|
|
63
68
|
|
|
64
69
|
@scope: untyped
|
|
65
70
|
|
|
66
|
-
@
|
|
71
|
+
@selecting: TimeRange?
|
|
67
72
|
|
|
68
73
|
@version_scope: untyped
|
|
69
74
|
|
|
@@ -75,26 +80,23 @@ module PaperTrailDiff
|
|
|
75
80
|
# : (Array[AssociationActivitySelection::Query]) -> Result
|
|
76
81
|
def database_selection: (Array[AssociationActivitySelection::Query]) -> Result
|
|
77
82
|
|
|
83
|
+
# The roots with a version of their own in the window. Those without a
|
|
84
|
+
# row are found in the database too (see Query#missing), not by comparing
|
|
85
|
+
# two plucked lists. Only the related queries' types are compared, so
|
|
86
|
+
# this one names none.
|
|
87
|
+
# : () -> AssociationActivitySelection::Query
|
|
88
|
+
def changed_roots: () -> AssociationActivitySelection::Query
|
|
89
|
+
|
|
78
90
|
# Comparing in SQL needs every subquery's column to share the key's type.
|
|
79
91
|
# : (Array[AssociationActivitySelection::source]) -> Array[AssociationActivitySelection::Query]?
|
|
80
92
|
def subqueries: (Array[AssociationActivitySelection::source]) -> Array[AssociationActivitySelection::Query]?
|
|
81
93
|
|
|
82
94
|
# Which candidates still have a row is asked without the relation's
|
|
83
95
|
# conditions, so that "filtered out" and "no longer exists" stay
|
|
84
|
-
# separable.
|
|
85
|
-
# only, whose order and page choose among those that match, and of the
|
|
86
|
-
# deleted ones, which no relation can test. Those it lists, as without a
|
|
87
|
-
# filter, but does not count toward `limit:`.
|
|
96
|
+
# separable.
|
|
88
97
|
# : (Array[String]) -> Result
|
|
89
98
|
def plucked_selection: (Array[String]) -> Result
|
|
90
99
|
|
|
91
|
-
# The candidates the relation's conditions accept. A grouped relation's
|
|
92
|
-
# rows are groups, which a condition on one record cannot decide, and its
|
|
93
|
-
# aggregates read every candidate at once, so it keeps them all: the
|
|
94
|
-
# filter reads each, and the relation groups those that match.
|
|
95
|
-
# : (Array[String]) -> Array[String]
|
|
96
|
-
def relation_members: (Array[String]) -> Array[String]
|
|
97
|
-
|
|
98
100
|
# Comparing the two columns in SQL needs them to share a type: PostgreSQL
|
|
99
101
|
# rejects an integer key against a string item_id outright. A composite
|
|
100
102
|
# key names no single attribute, so it has no type and never matches.
|
|
@@ -104,25 +106,12 @@ module PaperTrailDiff
|
|
|
104
106
|
# : () -> Symbol?
|
|
105
107
|
def key_type: () -> Symbol?
|
|
106
108
|
|
|
107
|
-
# : (Array[AssociationActivitySelection::Query]) -> Array[String]
|
|
108
|
-
def related_missing_ids: (Array[AssociationActivitySelection::Query]) -> Array[String]
|
|
109
|
-
|
|
110
|
-
# Changed in the window but without a row, found with an anti-join instead
|
|
111
|
-
# of comparing two plucked lists.
|
|
112
|
-
# : () -> Array[String]
|
|
113
|
-
def missing_ids: () -> Array[String]
|
|
114
|
-
|
|
115
109
|
# Only the versions `version_scope` keeps select a root: one whose versions
|
|
116
|
-
# in the window it drops would have nothing to report.
|
|
117
|
-
#
|
|
118
|
-
# root's window back to take it in.
|
|
110
|
+
# in the window it drops would have nothing to report. With associations
|
|
111
|
+
# it keeps whole transactions, as their activity reports them.
|
|
119
112
|
# : () -> untyped
|
|
120
113
|
def window_versions: () -> untyped
|
|
121
114
|
|
|
122
|
-
# The filter reads each candidate over the window its analysis will.
|
|
123
|
-
# : (untyped, Integer, AssociationTraversal?) -> HistoricalFilter?
|
|
124
|
-
def historical_filter_for: (untyped, Integer, AssociationTraversal?) -> HistoricalFilter?
|
|
125
|
-
|
|
126
115
|
# Accepts a model class as readily as a relation: `Article` and
|
|
127
116
|
# `Article.where(...)` both name a population, and `all` is what makes them
|
|
128
117
|
# the same kind of thing.
|
|
@@ -145,17 +134,33 @@ module PaperTrailDiff
|
|
|
145
134
|
# : (untyped, Array[String]) -> Array[String]
|
|
146
135
|
def ids_in: (untyped, Array[String]) -> Array[String]
|
|
147
136
|
|
|
137
|
+
# The records, and how many the relation selects before its limit and
|
|
138
|
+
# offset. An unpaged relation has read them all already; a paged one is
|
|
139
|
+
# counted in one more statement, with each record once, and a relation
|
|
140
|
+
# grouped by another column by its groups, each of which reads a record.
|
|
141
|
+
# : (Array[untyped]) -> [Array[untyped], Integer]
|
|
142
|
+
def page_and_total: (Array[untyped]) -> [ Array[untyped], Integer ]
|
|
143
|
+
|
|
148
144
|
# Deduplicate records rather than adding SQL DISTINCT: an otherwise valid
|
|
149
145
|
# relation may order by joined columns or select a PostgreSQL json column.
|
|
150
146
|
# Read bounded pages until the relation ends or too many unique roots appear.
|
|
151
|
-
# Each candidate source is an id list or a subquery
|
|
152
|
-
# of them is selected.
|
|
147
|
+
# Each candidate source is an id list or a subquery, such as a
|
|
148
|
+
# CandidateTable's; a record matching any of them is selected.
|
|
153
149
|
# : (Array[untyped]) -> Array[untyped]
|
|
154
150
|
def selected_records: (Array[untyped]) -> Array[untyped]
|
|
155
151
|
|
|
152
|
+
# A relation that selects columns without the primary key reads rows that
|
|
153
|
+
# name no record.
|
|
154
|
+
# : (Array[untyped]) -> void
|
|
155
|
+
def reject_keyless!: (Array[untyped]) -> void
|
|
156
|
+
|
|
157
|
+
# A composite key names a record only when every part of it is read.
|
|
158
|
+
# : (untyped) -> bool
|
|
159
|
+
def keyless?: (untyped) -> bool
|
|
160
|
+
|
|
156
161
|
# Pages are read by offset, so under a total order.
|
|
157
|
-
# : (
|
|
158
|
-
def candidate_relation: (
|
|
162
|
+
# : (*untyped) -> untyped
|
|
163
|
+
def candidate_relation: (*untyped) -> untyped
|
|
159
164
|
|
|
160
165
|
# : (untyped, Integer) -> Array[untyped]
|
|
161
166
|
def record_page: (untyped, Integer) -> Array[untyped]
|
|
@@ -170,7 +175,8 @@ module PaperTrailDiff
|
|
|
170
175
|
# holds at least 250 rows, for a relation whose joins repeat a record,
|
|
171
176
|
# and at most 2,000: SQL Server compiles a statement with its ids written
|
|
172
177
|
# in, and one that listed 20,000 and returned them all outlasted the
|
|
173
|
-
# adapter's default timeout of 5 seconds.
|
|
178
|
+
# adapter's default timeout of 5 seconds. There a long list is now read
|
|
179
|
+
# from a CandidateTable, but other databases still repeat it.
|
|
174
180
|
# : () -> Integer
|
|
175
181
|
def page_size: () -> Integer
|
|
176
182
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/selection_window.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# A window that selects records by activity, widened to where the earliest
|
|
5
|
+
# transaction open at its start began, as its history is read (see
|
|
6
|
+
# AssociationTraversal#reach_before). Associations are followed over all of
|
|
7
|
+
# it, but before the start only the versions of the transactions open there
|
|
8
|
+
# select a record: the window reports those transactions, and none of the
|
|
9
|
+
# others, which ended before it.
|
|
10
|
+
class SelectionWindow < TimeRange
|
|
11
|
+
# : (TimeRange, untyped) -> void
|
|
12
|
+
def initialize: (TimeRange, untyped) -> void
|
|
13
|
+
|
|
14
|
+
# : (untyped) -> untyped
|
|
15
|
+
def scope: (untyped) -> untyped
|
|
16
|
+
|
|
17
|
+
@window: TimeRange
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -22,38 +22,19 @@ module PaperTrailDiff
|
|
|
22
22
|
|
|
23
23
|
# A normalized association in a bounded record snapshot tree.
|
|
24
24
|
class AssociationSnapshot
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
class IdentityIndexCache
|
|
25
|
+
# Whether a collection's identities were found distinct. The snapshots a
|
|
26
|
+
# transition derives from one another share the answer: a transition
|
|
27
|
+
# replaces a record in its place, takes one out, or puts in one that was
|
|
28
|
+
# not there, and none of those can repeat an identity. Records are held
|
|
29
|
+
# in identity order, so two with one identity are neighbours.
|
|
30
|
+
class IdentityCheck
|
|
32
31
|
# : () -> void
|
|
33
32
|
def initialize: () -> void
|
|
34
33
|
|
|
35
|
-
# : (Array[RecordSnapshot]) ->
|
|
36
|
-
def
|
|
34
|
+
# : (Array[RecordSnapshot]) -> void
|
|
35
|
+
def call: (Array[RecordSnapshot]) -> void
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
# Identifies one snapshot for internal carry-forward. A transition cannot
|
|
40
|
-
# hold its origin without retaining every earlier snapshot at that path,
|
|
41
|
-
# and `object_id` is only guaranteed unique among live objects, so Ruby may
|
|
42
|
-
# hand a collected snapshot's id to a later one.
|
|
43
|
-
class SerialSequence
|
|
44
|
-
# : () -> void
|
|
45
|
-
def initialize: () -> void
|
|
46
|
-
|
|
47
|
-
# : () -> Integer
|
|
48
|
-
def next_serial: () -> Integer
|
|
49
|
-
|
|
50
|
-
@counter: Integer
|
|
51
|
-
|
|
52
|
-
@mutex: Thread::Mutex
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
SERIALS: untyped
|
|
56
|
-
|
|
57
38
|
# : (Symbol) -> bool
|
|
58
39
|
def self.collection_kind?: (Symbol) -> bool
|
|
59
40
|
|
|
@@ -61,14 +42,25 @@ module PaperTrailDiff
|
|
|
61
42
|
|
|
62
43
|
attr_reader records: Array[RecordSnapshot]
|
|
63
44
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
|
|
45
|
+
# Identifies this snapshot for internal carry-forward (see
|
|
46
|
+
# CollectionTransition). A token of its own, as `object_id` is unique
|
|
47
|
+
# only among live objects: Ruby may hand a collected snapshot's id to a
|
|
48
|
+
# later one.
|
|
49
|
+
attr_reader serial: Object
|
|
50
|
+
|
|
51
|
+
# `ordered` says the records are already in documented order, as a
|
|
52
|
+
# transition's are: checking them again for each event made a replay's
|
|
53
|
+
# time grow with its events times the size of the collection they changed.
|
|
54
|
+
# : (kind: Symbol, records: Array[RecordSnapshot], ?identity_check: untyped, ?transition: CollectionTransition?, ?ordered: bool) -> void
|
|
55
|
+
def initialize: (kind: Symbol, records: Array[RecordSnapshot], ?identity_check: untyped, ?transition: CollectionTransition?, ?ordered: bool) -> void
|
|
56
|
+
|
|
57
|
+
# Builds a structurally adjacent collection snapshot for internal activity
|
|
58
|
+
# carry-forward. Its records are this one's with one of them replaced in
|
|
59
|
+
# its place, taken out, or put in where its identity sorts, so they are in
|
|
60
|
+
# order, and as distinct as these unless the record put in repeats one
|
|
61
|
+
# beside it.
|
|
62
|
+
# : (Array[RecordSnapshot], before: RecordSnapshot?, after: RecordSnapshot?) -> AssociationSnapshot
|
|
63
|
+
def transition_to: (Array[RecordSnapshot], before: RecordSnapshot?, after: RecordSnapshot?) -> AssociationSnapshot
|
|
72
64
|
|
|
73
65
|
# Collections are documented in record type, then ID, order wherever they
|
|
74
66
|
# were read from. Most arrive sorted, so they are checked before sorting.
|
|
@@ -95,12 +87,19 @@ module PaperTrailDiff
|
|
|
95
87
|
|
|
96
88
|
private
|
|
97
89
|
|
|
98
|
-
@
|
|
90
|
+
@identity_check: untyped
|
|
91
|
+
|
|
92
|
+
@identity_index: CollectionIdentityIndex
|
|
99
93
|
|
|
100
94
|
@transition: CollectionTransition?
|
|
101
95
|
|
|
102
|
-
# : () ->
|
|
103
|
-
def
|
|
96
|
+
# : (Array[RecordSnapshot]) -> Array[RecordSnapshot]
|
|
97
|
+
def in_order: (Array[RecordSnapshot]) -> Array[RecordSnapshot]
|
|
98
|
+
|
|
99
|
+
# Whether the records hold this record's identity twice: a second one
|
|
100
|
+
# follows the first in their order.
|
|
101
|
+
# : (Array[RecordSnapshot], RecordSnapshot) -> bool
|
|
102
|
+
def repeated?: (Array[RecordSnapshot], RecordSnapshot) -> bool
|
|
104
103
|
end
|
|
105
104
|
|
|
106
105
|
# An immutable, ActiveRecord-independent representation of a reified record.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/snapshot_members.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# The records one snapshot of a root holds under each of its associations,
|
|
5
|
+
# at any depth, kept up as a replay moves from each snapshot to the next.
|
|
6
|
+
#
|
|
7
|
+
# Looking through a snapshot for a record means reading every collection in
|
|
8
|
+
# it, and a replay asks for each of its events, so its time grew with its
|
|
9
|
+
# events times the records of the tree. A snapshot differs from the one
|
|
10
|
+
# before it by the record its event changed, which the collections say
|
|
11
|
+
# (see AssociationSnapshot#transition_to), so moving costs what changed.
|
|
12
|
+
#
|
|
13
|
+
# A record can be in a tree at several places, so each is counted.
|
|
14
|
+
class SnapshotMembers
|
|
15
|
+
# : () -> void
|
|
16
|
+
def initialize: () -> void
|
|
17
|
+
|
|
18
|
+
# : (RecordSnapshot?) -> void
|
|
19
|
+
def move_to: (RecordSnapshot?) -> void
|
|
20
|
+
|
|
21
|
+
# Whether a record of one of the types is under one of the root's
|
|
22
|
+
# associations named. Ids match by their text, as a collection's do.
|
|
23
|
+
# : (Array[String], Array[String?], untyped) -> bool
|
|
24
|
+
def holds?: (Array[String], Array[String?], untyped) -> bool
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
@counts: Hash[String, Hash[String, Hash[String, Integer]]]
|
|
29
|
+
|
|
30
|
+
@snapshot: RecordSnapshot?
|
|
31
|
+
|
|
32
|
+
# : (Hash[String, Hash[String, Integer]], AssociationSnapshot?, AssociationSnapshot?) -> void
|
|
33
|
+
def change: (Hash[String, Hash[String, Integer]], AssociationSnapshot?, AssociationSnapshot?) -> void
|
|
34
|
+
|
|
35
|
+
# Two collections with no transition between them share the records
|
|
36
|
+
# before and after those that changed.
|
|
37
|
+
# : (Hash[String, Hash[String, Integer]], Array[RecordSnapshot], Array[RecordSnapshot]) -> void
|
|
38
|
+
def compare: (Hash[String, Hash[String, Integer]], Array[RecordSnapshot], Array[RecordSnapshot]) -> void
|
|
39
|
+
|
|
40
|
+
# How many records two lists begin with alike.
|
|
41
|
+
# : (Array[RecordSnapshot], Array[RecordSnapshot]) -> Integer
|
|
42
|
+
def shared: (Array[RecordSnapshot], Array[RecordSnapshot]) -> Integer
|
|
43
|
+
|
|
44
|
+
# : (Hash[String, Hash[String, Integer]], Array[RecordSnapshot], Array[RecordSnapshot]) -> void
|
|
45
|
+
def exchange: (Hash[String, Hash[String, Integer]], Array[RecordSnapshot], Array[RecordSnapshot]) -> void
|
|
46
|
+
|
|
47
|
+
# A record that stays is followed into its collections; another is taken
|
|
48
|
+
# out, or put in, with everything it holds.
|
|
49
|
+
# : (Hash[String, Hash[String, Integer]], RecordSnapshot?, RecordSnapshot?) -> void
|
|
50
|
+
def replace: (Hash[String, Hash[String, Integer]], RecordSnapshot?, RecordSnapshot?) -> void
|
|
51
|
+
|
|
52
|
+
# : (Hash[String, Hash[String, Integer]], RecordSnapshot, RecordSnapshot) -> void
|
|
53
|
+
def follow: (Hash[String, Hash[String, Integer]], RecordSnapshot, RecordSnapshot) -> void
|
|
54
|
+
|
|
55
|
+
# : (Hash[String, Hash[String, Integer]], RecordSnapshot?, Integer) -> void
|
|
56
|
+
def count: (Hash[String, Hash[String, Integer]], RecordSnapshot?, Integer) -> void
|
|
57
|
+
end
|
|
58
|
+
end
|