paper_trail_diff 0.16.0 → 0.17.1
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 +581 -1
- data/README.md +42 -7
- data/docs/architecture.md +7 -5
- data/docs/performance.md +86 -38
- data/docs/reference.md +309 -92
- data/docs/testing.md +240 -32
- data/lib/paper_trail_diff/activity_belongs_to_event_applier.rb +2 -16
- data/lib/paper_trail_diff/activity_boundary.rb +55 -34
- data/lib/paper_trail_diff/activity_child_candidate_loader.rb +46 -57
- data/lib/paper_trail_diff/activity_collection_event_applier.rb +3 -13
- data/lib/paper_trail_diff/activity_collection_route_updater.rb +1 -1
- data/lib/paper_trail_diff/activity_event.rb +33 -21
- data/lib/paper_trail_diff/activity_event_record_resolver.rb +16 -116
- data/lib/paper_trail_diff/activity_event_route_finder.rb +29 -29
- data/lib/paper_trail_diff/activity_event_snapshot_refresher.rb +2 -7
- data/lib/paper_trail_diff/activity_history.rb +90 -49
- data/lib/paper_trail_diff/activity_range.rb +9 -35
- data/lib/paper_trail_diff/activity_root_snapshot_refresher.rb +74 -40
- data/lib/paper_trail_diff/activity_root_steps.rb +10 -13
- data/lib/paper_trail_diff/activity_scope_filter.rb +77 -0
- data/lib/paper_trail_diff/activity_snapshot_delta.rb +12 -15
- data/lib/paper_trail_diff/activity_snapshot_sequence.rb +37 -15
- data/lib/paper_trail_diff/activity_target_candidate_loader.rb +35 -43
- data/lib/paper_trail_diff/activity_timeline_builder.rb +194 -249
- data/lib/paper_trail_diff/activity_transaction_grouper.rb +3 -1
- data/lib/paper_trail_diff/activity_tree_filter.rb +54 -13
- data/lib/paper_trail_diff/activity_version_collector.rb +72 -138
- data/lib/paper_trail_diff/activity_view.rb +22 -11
- data/lib/paper_trail_diff/analysis.rb +19 -5
- data/lib/paper_trail_diff/analysis_batch.rb +16 -58
- data/lib/paper_trail_diff/approximate_paths.rb +4 -8
- data/lib/paper_trail_diff/association_activity_edge.rb +5 -24
- data/lib/paper_trail_diff/association_activity_selection.rb +10 -18
- data/lib/paper_trail_diff/association_discovery.rb +1 -6
- data/lib/paper_trail_diff/association_key.rb +9 -6
- data/lib/paper_trail_diff/association_traversal.rb +49 -6
- data/lib/paper_trail_diff/batch_boundary_resolver.rb +33 -42
- data/lib/paper_trail_diff/batch_preload.rb +2 -12
- data/lib/paper_trail_diff/batched_root_analyses.rb +72 -0
- data/lib/paper_trail_diff/batched_root_analyzer.rb +16 -14
- data/lib/paper_trail_diff/batched_root_versions.rb +25 -20
- data/lib/paper_trail_diff/branch_snapshot_refresher.rb +27 -31
- data/lib/paper_trail_diff/change_attribution.rb +329 -0
- data/lib/paper_trail_diff/change_row.rb +30 -10
- data/lib/paper_trail_diff/comparison_batch.rb +3 -4
- data/lib/paper_trail_diff/configuration.rb +1 -1
- data/lib/paper_trail_diff/deleted_analysis_batch.rb +22 -37
- data/lib/paper_trail_diff/deleted_root_filter.rb +3 -6
- data/lib/paper_trail_diff/deprecation.rb +4 -43
- data/lib/paper_trail_diff/diagnostics.rb +1 -2
- data/lib/paper_trail_diff/direct_record_state_loader.rb +8 -1
- data/lib/paper_trail_diff/endpoint.rb +78 -44
- data/lib/paper_trail_diff/errors.rb +2 -9
- data/lib/paper_trail_diff/fallback_paths.rb +2 -5
- data/lib/paper_trail_diff/habtm_transaction_owners.rb +5 -3
- data/lib/paper_trail_diff/historical_association_reifier.rb +3 -1
- data/lib/paper_trail_diff/historical_filter.rb +40 -15
- data/lib/paper_trail_diff/historical_snapshot_store.rb +80 -38
- data/lib/paper_trail_diff/instrumentation.rb +0 -8
- data/lib/paper_trail_diff/live_endpoint_batch_loader.rb +11 -7
- data/lib/paper_trail_diff/live_endpoint_provider.rb +7 -23
- data/lib/paper_trail_diff/live_graph_collector.rb +3 -3
- data/lib/paper_trail_diff/nested_comparator.rb +46 -19
- data/lib/paper_trail_diff/net_change.rb +276 -0
- data/lib/paper_trail_diff/own_window.rb +35 -0
- data/lib/paper_trail_diff/paper_trail_adapter.rb +40 -45
- data/lib/paper_trail_diff/prepared_activity_index.rb +197 -45
- data/lib/paper_trail_diff/prepared_child_candidates.rb +58 -0
- data/lib/paper_trail_diff/prepared_edge_loader.rb +43 -107
- data/lib/paper_trail_diff/prepared_history.rb +20 -31
- data/lib/paper_trail_diff/prepared_history_loader.rb +46 -9
- data/lib/paper_trail_diff/prepared_record_index.rb +137 -47
- data/lib/paper_trail_diff/prepared_snapshot_builder.rb +16 -0
- data/lib/paper_trail_diff/prepared_state_association_reader.rb +17 -19
- data/lib/paper_trail_diff/read_snapshot.rb +41 -19
- data/lib/paper_trail_diff/recorded_changes.rb +10 -11
- data/lib/paper_trail_diff/recorded_changes_reader.rb +60 -0
- data/lib/paper_trail_diff/recorded_class.rb +14 -19
- data/lib/paper_trail_diff/recorded_columns.rb +33 -0
- data/lib/paper_trail_diff/root_version_plan.rb +20 -22
- data/lib/paper_trail_diff/root_version_selection.rb +39 -29
- data/lib/paper_trail_diff/scope_condition.rb +7 -17
- data/lib/paper_trail_diff/scope_ranking.rb +16 -22
- data/lib/paper_trail_diff/scoped_analysis.rb +27 -4
- data/lib/paper_trail_diff/scoped_analysis_builder.rb +4 -3
- data/lib/paper_trail_diff/scoped_root_selection.rb +60 -41
- data/lib/paper_trail_diff/snapshot_normalizer.rb +18 -3
- data/lib/paper_trail_diff/stored_json_values.rb +52 -0
- data/lib/paper_trail_diff/stored_time_precision.rb +30 -18
- data/lib/paper_trail_diff/stored_values.rb +20 -0
- data/lib/paper_trail_diff/support.rb +185 -35
- data/lib/paper_trail_diff/time_of_day.rb +39 -0
- data/lib/paper_trail_diff/time_range.rb +37 -20
- data/lib/paper_trail_diff/time_version_range.rb +5 -10
- data/lib/paper_trail_diff/timeline_builder.rb +3 -3
- data/lib/paper_trail_diff/timeline_range.rb +18 -12
- data/lib/paper_trail_diff/timeline_snapshot_provider.rb +1 -1
- data/lib/paper_trail_diff/total_order.rb +55 -0
- data/lib/paper_trail_diff/transaction_cut.rb +192 -91
- data/lib/paper_trail_diff/traversal_preparer.rb +5 -8
- data/lib/paper_trail_diff/value_objects.rb +8 -4
- data/lib/paper_trail_diff/version.rb +1 -1
- data/lib/paper_trail_diff/version_association_candidate_scope.rb +27 -16
- data/lib/paper_trail_diff/version_boundary.rb +37 -21
- data/lib/paper_trail_diff/version_query.rb +25 -25
- data/lib/paper_trail_diff/version_range.rb +12 -16
- data/lib/paper_trail_diff/version_sequence_diagnostics.rb +32 -0
- data/lib/paper_trail_diff/version_table.rb +12 -8
- data/lib/paper_trail_diff.rb +28 -42
- data/sig/generated/paper_trail_diff/activity_belongs_to_event_applier.rbs +0 -8
- data/sig/generated/paper_trail_diff/activity_boundary.rbs +39 -17
- data/sig/generated/paper_trail_diff/activity_child_candidate_loader.rbs +19 -22
- data/sig/generated/paper_trail_diff/activity_collection_event_applier.rbs +0 -5
- data/sig/generated/paper_trail_diff/activity_event.rbs +25 -9
- data/sig/generated/paper_trail_diff/activity_event_record_resolver.rbs +6 -34
- data/sig/generated/paper_trail_diff/activity_event_route_finder.rbs +11 -4
- data/sig/generated/paper_trail_diff/activity_event_snapshot_refresher.rbs +0 -3
- data/sig/generated/paper_trail_diff/activity_history.rbs +54 -19
- data/sig/generated/paper_trail_diff/activity_range.rbs +6 -20
- data/sig/generated/paper_trail_diff/activity_root_snapshot_refresher.rbs +36 -2
- data/sig/generated/paper_trail_diff/activity_root_steps.rbs +6 -6
- data/sig/generated/paper_trail_diff/activity_scope_filter.rbs +51 -0
- data/sig/generated/paper_trail_diff/activity_snapshot_delta.rbs +5 -3
- data/sig/generated/paper_trail_diff/activity_snapshot_sequence.rbs +21 -3
- data/sig/generated/paper_trail_diff/activity_target_candidate_loader.rbs +19 -24
- data/sig/generated/paper_trail_diff/activity_timeline_builder.rbs +121 -127
- data/sig/generated/paper_trail_diff/activity_tree_filter.rbs +41 -8
- data/sig/generated/paper_trail_diff/activity_version_collector.rbs +42 -35
- data/sig/generated/paper_trail_diff/activity_view.rbs +16 -8
- data/sig/generated/paper_trail_diff/analysis.rbs +15 -6
- data/sig/generated/paper_trail_diff/analysis_batch.rbs +6 -24
- data/sig/generated/paper_trail_diff/association_activity_edge.rbs +0 -13
- data/sig/generated/paper_trail_diff/association_activity_selection.rbs +6 -9
- data/sig/generated/paper_trail_diff/association_discovery.rbs +0 -3
- data/sig/generated/paper_trail_diff/association_key.rbs +5 -0
- data/sig/generated/paper_trail_diff/association_traversal.rbs +26 -2
- data/sig/generated/paper_trail_diff/batch_boundary_resolver.rbs +17 -17
- data/sig/generated/paper_trail_diff/batch_preload.rbs +0 -4
- data/sig/generated/paper_trail_diff/batched_root_analyses.rbs +47 -0
- data/sig/generated/paper_trail_diff/batched_root_analyzer.rbs +9 -8
- data/sig/generated/paper_trail_diff/batched_root_versions.rbs +10 -6
- data/sig/generated/paper_trail_diff/branch_snapshot_refresher.rbs +11 -5
- data/sig/generated/paper_trail_diff/change_attribution.rbs +194 -0
- data/sig/generated/paper_trail_diff/change_row.rbs +22 -7
- data/sig/generated/paper_trail_diff/deleted_analysis_batch.rbs +11 -12
- data/sig/generated/paper_trail_diff/deleted_root_filter.rbs +0 -2
- data/sig/generated/paper_trail_diff/deprecation.rbs +4 -24
- data/sig/generated/paper_trail_diff/direct_record_state_loader.rbs +4 -0
- data/sig/generated/paper_trail_diff/endpoint.rbs +40 -16
- data/sig/generated/paper_trail_diff/errors.rbs +2 -11
- data/sig/generated/paper_trail_diff/habtm_transaction_owners.rbs +2 -1
- data/sig/generated/paper_trail_diff/historical_filter.rbs +20 -9
- data/sig/generated/paper_trail_diff/historical_snapshot_store.rbs +40 -10
- data/sig/generated/paper_trail_diff/instrumentation.rbs +0 -3
- data/sig/generated/paper_trail_diff/live_endpoint_batch_loader.rbs +3 -0
- data/sig/generated/paper_trail_diff/live_endpoint_provider.rbs +5 -8
- data/sig/generated/paper_trail_diff/live_graph_collector.rbs +2 -2
- data/sig/generated/paper_trail_diff/nested_comparator.rbs +20 -4
- data/sig/generated/paper_trail_diff/net_change.rbs +168 -0
- data/sig/generated/paper_trail_diff/own_window.rbs +22 -0
- data/sig/generated/paper_trail_diff/paper_trail_adapter.rbs +9 -6
- data/sig/generated/paper_trail_diff/prepared_activity_index.rbs +114 -14
- data/sig/generated/paper_trail_diff/prepared_child_candidates.rbs +39 -0
- data/sig/generated/paper_trail_diff/prepared_edge_loader.rbs +18 -35
- data/sig/generated/paper_trail_diff/prepared_history.rbs +9 -12
- data/sig/generated/paper_trail_diff/prepared_history_loader.rbs +28 -3
- data/sig/generated/paper_trail_diff/prepared_record_index.rbs +68 -14
- data/sig/generated/paper_trail_diff/prepared_snapshot_builder.rbs +12 -0
- data/sig/generated/paper_trail_diff/prepared_state_association_reader.rbs +6 -7
- data/sig/generated/paper_trail_diff/read_snapshot.rbs +27 -8
- data/sig/generated/paper_trail_diff/recorded_changes.rbs +4 -2
- data/sig/generated/paper_trail_diff/recorded_changes_reader.rbs +41 -0
- data/sig/generated/paper_trail_diff/recorded_class.rbs +7 -6
- data/sig/generated/paper_trail_diff/recorded_columns.rbs +21 -0
- data/sig/generated/paper_trail_diff/root_version_plan.rbs +8 -4
- data/sig/generated/paper_trail_diff/root_version_selection.rbs +27 -13
- data/sig/generated/paper_trail_diff/scope_condition.rbs +0 -2
- data/sig/generated/paper_trail_diff/scope_ranking.rbs +10 -10
- data/sig/generated/paper_trail_diff/scoped_analysis.rbs +19 -0
- data/sig/generated/paper_trail_diff/scoped_analysis_builder.rbs +2 -2
- data/sig/generated/paper_trail_diff/scoped_root_selection.rbs +37 -14
- data/sig/generated/paper_trail_diff/snapshot_normalizer.rbs +7 -0
- data/sig/generated/paper_trail_diff/stored_json_values.rbs +35 -0
- data/sig/generated/paper_trail_diff/stored_time_precision.rbs +19 -5
- data/sig/generated/paper_trail_diff/stored_values.rbs +13 -0
- data/sig/generated/paper_trail_diff/support.rbs +120 -23
- data/sig/generated/paper_trail_diff/time_of_day.rbs +21 -0
- data/sig/generated/paper_trail_diff/time_range.rbs +15 -8
- data/sig/generated/paper_trail_diff/time_version_range.rbs +2 -5
- data/sig/generated/paper_trail_diff/timeline_builder.rbs +2 -2
- data/sig/generated/paper_trail_diff/timeline_range.rbs +12 -7
- data/sig/generated/paper_trail_diff/total_order.rbs +32 -0
- data/sig/generated/paper_trail_diff/transaction_cut.rbs +111 -52
- data/sig/generated/paper_trail_diff/traversal_preparer.rbs +2 -2
- data/sig/generated/paper_trail_diff/value_objects.rbs +5 -1
- data/sig/generated/paper_trail_diff/version_association_candidate_scope.rbs +10 -9
- data/sig/generated/paper_trail_diff/version_boundary.rbs +15 -8
- data/sig/generated/paper_trail_diff/version_query.rbs +17 -10
- data/sig/generated/paper_trail_diff/version_range.rbs +6 -9
- data/sig/generated/paper_trail_diff/version_sequence_diagnostics.rbs +13 -0
- data/sig/generated/paper_trail_diff/version_table.rbs +3 -0
- data/sig/generated/paper_trail_diff.rbs +16 -16
- metadata +28 -6
- data/lib/paper_trail_diff/preloaded_endpoint_batch_loader.rb +0 -60
- data/sig/generated/paper_trail_diff/preloaded_endpoint_batch_loader.rbs +0 -32
|
@@ -32,27 +32,37 @@ module PaperTrailDiff
|
|
|
32
32
|
|
|
33
33
|
NOT_READ_MESSAGE: ::String
|
|
34
34
|
|
|
35
|
-
# `recorded:`
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
# : (untyped, ?recorded:
|
|
39
|
-
def self.from_version: (untyped, ?recorded:
|
|
35
|
+
# `recorded:` reads the version's recorded changes, or is nil when they
|
|
36
|
+
# were not asked for. Reading them decodes `object_changes`, which waits
|
|
37
|
+
# until a caller reads them, and which one who never does should not pay.
|
|
38
|
+
# : (untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
39
|
+
def self.from_version: (untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
40
40
|
|
|
41
41
|
# The current record has no version, so it recorded nothing.
|
|
42
|
-
# : (untyped, captured_at: untyped, ?recorded:
|
|
43
|
-
def self.current: (untyped, captured_at: untyped, ?recorded:
|
|
42
|
+
# : (untyped, captured_at: untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
43
|
+
def self.current: (untyped, captured_at: untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
44
44
|
|
|
45
45
|
# The state a `destroy` version leaves behind. A version records the state
|
|
46
46
|
# before its own event, so the boundary built from a destroy version still
|
|
47
47
|
# holds the record; this one is the absence that follows it.
|
|
48
|
-
# : (untyped, ?recorded:
|
|
49
|
-
def self.destroyed: (untyped, ?recorded:
|
|
48
|
+
# : (untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
49
|
+
def self.destroyed: (untyped, ?recorded: RecordedChangesReader?) -> ActivityBoundary
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
|
|
51
|
+
# Where a change saved without a version came from, such as an
|
|
52
|
+
# `update_columns` call: no version, event, author or time recorded it,
|
|
53
|
+
# so it has none to report. A change row names it as its source.
|
|
54
|
+
# : (item_type: String, item_id: untyped) -> ActivityBoundary
|
|
55
|
+
def self.unversioned: (item_type: String, item_id: untyped) -> ActivityBoundary
|
|
56
|
+
|
|
57
|
+
# : (untyped, Symbol, RecordedChangesReader?) -> ActivityBoundary
|
|
58
|
+
private def self.of_version: (untyped, Symbol, RecordedChangesReader?) -> ActivityBoundary
|
|
59
|
+
|
|
60
|
+
# : (untyped, RecordedChangesReader?) -> untyped
|
|
61
|
+
private def self.recorded_changes: (untyped, RecordedChangesReader?) -> untyped
|
|
53
62
|
|
|
54
63
|
# `recorded_changes:` takes what `PaperTrailDiff.recorded_changes` returns
|
|
55
|
-
# for the version
|
|
64
|
+
# for the version, or a RecordedChangesReader::Pending that reads it when
|
|
65
|
+
# first asked; leave it out when they were not read.
|
|
56
66
|
# : (kind: Symbol, version_id: untyped, item_type: untyped, item_id: untyped, recorded_at: untyped, ?event: untyped, ?whodunnit: untyped, ?transaction_id: untyped, ?recorded_changes: untyped) -> void
|
|
57
67
|
def initialize: (kind: Symbol, version_id: untyped, item_type: untyped, item_id: untyped, recorded_at: untyped, ?event: untyped, ?whodunnit: untyped, ?transaction_id: untyped, ?recorded_changes: untyped) -> void
|
|
58
68
|
|
|
@@ -77,6 +87,9 @@ module PaperTrailDiff
|
|
|
77
87
|
# : () -> bool
|
|
78
88
|
def destroyed?: () -> bool
|
|
79
89
|
|
|
90
|
+
# : () -> bool
|
|
91
|
+
def unversioned?: () -> bool
|
|
92
|
+
|
|
80
93
|
# : (?metadata: bool) -> Hash[Symbol, untyped]
|
|
81
94
|
def to_h: (?metadata: bool) -> Hash[Symbol, untyped]
|
|
82
95
|
end
|
|
@@ -104,14 +117,21 @@ module PaperTrailDiff
|
|
|
104
117
|
# would credit the rest of the save to whoever opened it.
|
|
105
118
|
attr_reader sources: Array[ActivityBoundary]
|
|
106
119
|
|
|
120
|
+
# @api private
|
|
121
|
+
# What credits this step's change rows, which a transaction group extends
|
|
122
|
+
# over the steps it merges.
|
|
123
|
+
attr_reader attribution: ChangeAttribution?
|
|
124
|
+
|
|
107
125
|
# Compares two reconstructed states and keeps them only when asked, which is
|
|
108
126
|
# every caller's shape: the diff always comes from the pair, the pair itself
|
|
109
127
|
# is retained on request.
|
|
110
|
-
# : (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, from_snapshot: RecordSnapshot?, to_snapshot: RecordSnapshot?, retain: bool, ?sources: Array[ActivityBoundary]?) -> ActivityStep
|
|
111
|
-
def self.between: (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, from_snapshot: RecordSnapshot?, to_snapshot: RecordSnapshot?, retain: bool, ?sources: Array[ActivityBoundary]?) -> ActivityStep
|
|
128
|
+
# : (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, from_snapshot: RecordSnapshot?, to_snapshot: RecordSnapshot?, retain: bool, ?sources: Array[ActivityBoundary]?, ?attribution: ChangeAttribution?) -> ActivityStep
|
|
129
|
+
def self.between: (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, from_snapshot: RecordSnapshot?, to_snapshot: RecordSnapshot?, retain: bool, ?sources: Array[ActivityBoundary]?, ?attribution: ChangeAttribution?) -> ActivityStep
|
|
112
130
|
|
|
113
|
-
#
|
|
114
|
-
|
|
131
|
+
# `attribution` credits each change row to the version that made it (see
|
|
132
|
+
# ChangeAttribution); without it, every row names `source_boundary`.
|
|
133
|
+
# : (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, diff: Diff, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?sources: Array[ActivityBoundary]?, ?attribution: ChangeAttribution?) -> void
|
|
134
|
+
def initialize: (from_boundary: ActivityBoundary, to_boundary: ActivityBoundary, diff: Diff, ?from_snapshot: RecordSnapshot?, ?to_snapshot: RecordSnapshot?, ?sources: Array[ActivityBoundary]?, ?attribution: ChangeAttribution?) -> void
|
|
115
135
|
|
|
116
136
|
# : () -> bool
|
|
117
137
|
def empty?: () -> bool
|
|
@@ -121,7 +141,9 @@ module PaperTrailDiff
|
|
|
121
141
|
# : () -> ActivityBoundary
|
|
122
142
|
def source_boundary: () -> ActivityBoundary
|
|
123
143
|
|
|
124
|
-
# The diff as flat rows, each
|
|
144
|
+
# The diff as flat rows, each credited to the event that made its change:
|
|
145
|
+
# the version of the row's record that recorded it, an unversioned source
|
|
146
|
+
# for a part saved without a version, or else `source_boundary`.
|
|
125
147
|
# : () -> Array[ChangeRow]
|
|
126
148
|
def change_rows: () -> Array[ChangeRow]
|
|
127
149
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Generated from lib/paper_trail_diff/activity_child_candidate_loader.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
|
-
# Loads
|
|
4
|
+
# Loads the children of a has_many or has_one that its owners had from a
|
|
5
|
+
# start onward, from PT-AT's version associations and the live rows.
|
|
6
|
+
# Prepared history and activity both read children through it. A composite
|
|
7
|
+
# foreign key reads none, as loaded history cannot index it.
|
|
5
8
|
class ActivityChildCandidateLoader
|
|
6
|
-
# : (untyped, Array[untyped], untyped,
|
|
7
|
-
def initialize: (untyped, Array[untyped], untyped,
|
|
9
|
+
# : (untyped, Array[untyped], untyped, untyped) -> void
|
|
10
|
+
def initialize: (untyped, Array[untyped], untyped, untyped) -> void
|
|
8
11
|
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# One shared query retains the owner and timestamp needed to partition a
|
|
13
|
-
# batch's candidates back into each root's exact activity range.
|
|
12
|
+
# Queries shared by a batch's roots keep the owner and timestamp needed to
|
|
13
|
+
# partition its candidates back into each root's exact activity range.
|
|
14
14
|
# : () -> Array[Array[untyped]]
|
|
15
15
|
def historical_rows: () -> Array[Array[untyped]]
|
|
16
16
|
|
|
@@ -19,31 +19,28 @@ module PaperTrailDiff
|
|
|
19
19
|
|
|
20
20
|
private
|
|
21
21
|
|
|
22
|
+
@foreign_key: String?
|
|
23
|
+
|
|
22
24
|
@parent_class: untyped
|
|
23
25
|
|
|
24
26
|
@parent_ids: Array[untyped]
|
|
25
27
|
|
|
26
|
-
@range: ActivityRange
|
|
27
|
-
|
|
28
28
|
@reflection: untyped
|
|
29
29
|
|
|
30
|
+
@start_at: untyped
|
|
31
|
+
|
|
30
32
|
# : (Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
31
33
|
def typed_rows: (Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
32
34
|
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# : (untyped) -> untyped
|
|
37
|
-
def historical_relation: (untyped) -> untyped
|
|
38
|
-
|
|
39
|
-
# : (untyped) -> VersionAssociationCandidateScope
|
|
40
|
-
def candidate_scope: (untyped) -> VersionAssociationCandidateScope
|
|
35
|
+
# Each statement reads the children of 500 owners.
|
|
36
|
+
# : () -> Enumerator[Array[untyped], untyped]
|
|
37
|
+
def owner_slices: () -> Enumerator[Array[untyped], untyped]
|
|
41
38
|
|
|
42
|
-
# : (
|
|
43
|
-
def
|
|
39
|
+
# : (untyped, String, Array[untyped]) -> untyped
|
|
40
|
+
def historical_relation: (untyped, String, Array[untyped]) -> untyped
|
|
44
41
|
|
|
45
|
-
# : () ->
|
|
46
|
-
def
|
|
42
|
+
# : (untyped, untyped) -> Array[Array[untyped]]
|
|
43
|
+
def pluck_rows: (untyped, untyped) -> Array[Array[untyped]]
|
|
47
44
|
|
|
48
45
|
# : () -> Array[String?]
|
|
49
46
|
def parent_types: () -> Array[String?]
|
|
@@ -25,11 +25,6 @@ module PaperTrailDiff
|
|
|
25
25
|
# : (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped], ?direct: bool) -> RecordSnapshot
|
|
26
26
|
def apply_route: (RecordSnapshot, Array[untyped], untyped, ActivitySnapshotDelta?, Array[untyped], SnapshotNormalizer, Array[untyped], ?direct: bool) -> RecordSnapshot
|
|
27
27
|
|
|
28
|
-
# Any edit can move a record into or out of a scope, so a scoped route's
|
|
29
|
-
# branch is read again from history instead.
|
|
30
|
-
# : (Array[Array[untyped]]) -> bool
|
|
31
|
-
def scoped_route?: (Array[Array[untyped]]) -> bool
|
|
32
|
-
|
|
33
28
|
# : (Array[Array[untyped]], untyped) -> bool
|
|
34
29
|
def unsafe_through_membership_event?: (Array[Array[untyped]], untyped) -> bool
|
|
35
30
|
|
|
@@ -55,27 +55,43 @@ module PaperTrailDiff
|
|
|
55
55
|
# : (untyped) -> Array[untyped]?
|
|
56
56
|
def self.transaction_key: (untyped) -> Array[untyped]?
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
# An `opening` transaction began before the history's start, so its
|
|
59
|
+
# versions there are not events, yet the state after it has their changes
|
|
60
|
+
# (see PreparedHistoryLoader#reload). The snapshot after
|
|
61
|
+
# it is read whole rather than refreshed from its events alone.
|
|
62
|
+
# : (Array[ActivityEvent], ?opening: Array[Array[untyped]]) -> void
|
|
63
|
+
def initialize: (Array[ActivityEvent], ?opening: Array[Array[untyped]]) -> void
|
|
64
|
+
|
|
65
|
+
# An event outside a transaction, or in one it was not given, keeps its
|
|
66
|
+
# own.
|
|
61
67
|
# : (ActivityEvent) -> Array[String]?
|
|
62
68
|
def branches_for: (ActivityEvent) -> Array[String]?
|
|
63
69
|
|
|
64
70
|
# : (ActivityEvent) -> bool
|
|
65
71
|
def isolated?: (ActivityEvent) -> bool
|
|
66
72
|
|
|
73
|
+
# Whether two events were saved in one transaction that began inside the
|
|
74
|
+
# history.
|
|
75
|
+
# : (ActivityEvent, ActivityEvent) -> bool
|
|
76
|
+
def shared?: (ActivityEvent, ActivityEvent) -> bool
|
|
77
|
+
|
|
67
78
|
private
|
|
68
79
|
|
|
69
|
-
@branches: Hash[Array[untyped]
|
|
80
|
+
@branches: Hash[Array[untyped]?, Array[String]?]
|
|
81
|
+
|
|
82
|
+
@group_sizes: Hash[Array[untyped]?, Integer]
|
|
70
83
|
|
|
71
|
-
@
|
|
84
|
+
@opening: Array[untyped]
|
|
72
85
|
|
|
73
|
-
# : (Hash[Array[untyped]
|
|
74
|
-
def build_groups: (Hash[Array[untyped]
|
|
86
|
+
# : (Hash[Array[untyped]?, Array[ActivityEvent]]) -> Hash[Array[untyped]?, Array[String]?]
|
|
87
|
+
def build_groups: (Hash[Array[untyped]?, Array[ActivityEvent]]) -> Hash[Array[untyped]?, Array[String]?]
|
|
75
88
|
|
|
76
|
-
#
|
|
77
|
-
|
|
89
|
+
# The events of each transaction; one outside a transaction is in none.
|
|
90
|
+
# : (Array[ActivityEvent]) -> Hash[Array[untyped]?, Array[ActivityEvent]]
|
|
91
|
+
def grouped_events: (Array[ActivityEvent]) -> Hash[Array[untyped]?, Array[ActivityEvent]]
|
|
78
92
|
|
|
93
|
+
# A transaction with a root event is read as the root's; every other
|
|
94
|
+
# event has branches.
|
|
79
95
|
# : (Array[ActivityEvent]) -> Array[String]?
|
|
80
96
|
def group_branches: (Array[ActivityEvent]) -> Array[String]?
|
|
81
97
|
|
|
@@ -3,32 +3,19 @@
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
4
|
# Reconstructs an event's post-change record or immutable scalar delta.
|
|
5
5
|
class ActivityEventRecordResolver
|
|
6
|
-
RECORD_AFTER_HANDLERS: untyped
|
|
7
|
-
|
|
8
6
|
# : (?record_transition: untyped, ?prepared_record_after: untyped) -> void
|
|
9
7
|
def initialize: (?record_transition: untyped, ?prepared_record_after: untyped) -> void
|
|
10
8
|
|
|
9
|
+
# The record as the version left it: the state recorded next, which holds
|
|
10
|
+
# any change saved after the version without one of its own. Prepared
|
|
11
|
+
# history answers without a query; without it, the next version or the
|
|
12
|
+
# live row does.
|
|
11
13
|
# : (untyped, ?direct: bool) -> untyped
|
|
12
14
|
def record_after: (untyped, ?direct: bool) -> untyped
|
|
13
15
|
|
|
14
|
-
# : (untyped) -> [bool, untyped]
|
|
15
|
-
def direct_after: (untyped) -> [ bool, untyped ]
|
|
16
|
-
|
|
17
|
-
# : (untyped) -> untyped
|
|
18
|
-
def fallback_record_after: (untyped) -> untyped
|
|
19
|
-
|
|
20
16
|
# : (untyped) -> ActivitySnapshotDelta?
|
|
21
17
|
def snapshot_delta: (untyped) -> ActivitySnapshotDelta?
|
|
22
18
|
|
|
23
|
-
# : (untyped) -> untyped
|
|
24
|
-
def changed_record_after: (untyped) -> untyped
|
|
25
|
-
|
|
26
|
-
# : (untyped) -> untyped
|
|
27
|
-
def created_record_after: (untyped) -> untyped
|
|
28
|
-
|
|
29
|
-
# : (untyped) -> untyped
|
|
30
|
-
def updated_record_after: (untyped) -> untyped
|
|
31
|
-
|
|
32
19
|
# Mirrors PaperTrail's changeset deserialization without resolving
|
|
33
20
|
# +version.item+, which would issue one live-record query per event.
|
|
34
21
|
# : (untyped, untyped) -> untyped
|
|
@@ -36,31 +23,16 @@ module PaperTrailDiff
|
|
|
36
23
|
|
|
37
24
|
private
|
|
38
25
|
|
|
39
|
-
@direct_loader: DirectRecordStateLoader
|
|
40
|
-
|
|
41
26
|
@prepared_record_after: untyped
|
|
42
27
|
|
|
43
28
|
@record_transition: untyped
|
|
44
29
|
|
|
45
|
-
# : (untyped) ->
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
# Without `item_subtype` a version names only the STI base class, and a
|
|
49
|
-
# change can move the row to another class, so the type the row holds
|
|
50
|
-
# after the change decides. A type that names no class has no direct
|
|
51
|
-
# state; the caller falls back to reifying the record.
|
|
52
|
-
# : (untyped, Hash[untyped, untyped]) -> untyped
|
|
53
|
-
def class_after: (untyped, Hash[untyped, untyped]) -> untyped
|
|
30
|
+
# : (untyped) -> untyped
|
|
31
|
+
def recorded_after: (untyped) -> untyped
|
|
54
32
|
|
|
55
33
|
# : (untyped) -> untyped
|
|
56
34
|
def prepared_changeset: (untyped) -> untyped
|
|
57
35
|
|
|
58
|
-
# : (untyped, untyped) -> Hash[untyped, untyped]
|
|
59
|
-
def after_attributes: (untyped, untyped) -> Hash[untyped, untyped]
|
|
60
|
-
|
|
61
|
-
# : (untyped, untyped) -> untyped
|
|
62
|
-
def apply_changes: (untyped, untyped) -> untyped
|
|
63
|
-
|
|
64
36
|
# : (untyped, untyped, untyped) -> untyped
|
|
65
37
|
def standard_changeset: (untyped, untyped, untyped) -> untyped
|
|
66
38
|
end
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
4
|
# Finds explicitly selected collection and belongs-to routes for one event type.
|
|
5
5
|
class ActivityEventRouteFinder
|
|
6
|
+
# An edit can move a record into or out of a scope, which a change in
|
|
7
|
+
# place cannot show, so an event on a scoped route has its branch read
|
|
8
|
+
# again from history instead.
|
|
9
|
+
# : (Array[Array[untyped]]) -> bool
|
|
10
|
+
def self.scoped_route?: (Array[Array[untyped]]) -> bool
|
|
11
|
+
|
|
6
12
|
# : (AssociationTraversal) -> void
|
|
7
13
|
def initialize: (AssociationTraversal) -> void
|
|
8
14
|
|
|
@@ -28,6 +34,8 @@ module PaperTrailDiff
|
|
|
28
34
|
|
|
29
35
|
@traversal: AssociationTraversal
|
|
30
36
|
|
|
37
|
+
# Validation rejects a path that continues past a polymorphic target, so
|
|
38
|
+
# only a target of one class has a subtree to search.
|
|
31
39
|
# : (untyped, AssociationTree, String, String) -> bool
|
|
32
40
|
def through_part_below?: (untyped, AssociationTree, String, String) -> bool
|
|
33
41
|
|
|
@@ -36,19 +44,18 @@ module PaperTrailDiff
|
|
|
36
44
|
|
|
37
45
|
# Timelines interleave event types, so every requested combination is
|
|
38
46
|
# retained. Model, tree, and path are fixed per adapter, leaving one entry
|
|
39
|
-
# per selected item type.
|
|
47
|
+
# per selected item type. The strings are kept as frozen copies, which a
|
|
48
|
+
# caller cannot change.
|
|
40
49
|
# : (Hash[Array[untyped], Array[Array[untyped]]], untyped, AssociationTree, String, String, Symbol) -> Array[Array[untyped]]
|
|
41
50
|
def cached: (Hash[Array[untyped], Array[Array[untyped]]], untyped, AssociationTree, String, String, Symbol) -> Array[Array[untyped]]
|
|
42
51
|
|
|
43
|
-
# : (Array[untyped]) -> Array[untyped]
|
|
44
|
-
def cache_key: (Array[untyped]) -> Array[untyped]
|
|
45
|
-
|
|
46
52
|
# : (Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
47
53
|
def freeze_routes: (Array[Array[untyped]]) -> Array[Array[untyped]]
|
|
48
54
|
|
|
49
55
|
# : (untyped, AssociationTree, String, Symbol, path: String) -> Array[Array[untyped]]
|
|
50
56
|
def routes: (untyped, AssociationTree, String, Symbol, path: String) -> Array[Array[untyped]]
|
|
51
57
|
|
|
58
|
+
# Each reflection is of a child the tree names.
|
|
52
59
|
# : (untyped, AssociationTree, String, Symbol, String) -> Array[Array[untyped]]
|
|
53
60
|
def routes_for_reflection: (untyped, AssociationTree, String, Symbol, String) -> Array[Array[untyped]]
|
|
54
61
|
|
|
@@ -15,8 +15,14 @@ module PaperTrailDiff
|
|
|
15
15
|
|
|
16
16
|
attr_reader last_event_snapshot: RecordSnapshot?
|
|
17
17
|
|
|
18
|
-
#
|
|
19
|
-
|
|
18
|
+
# The event of `last_boundary`.
|
|
19
|
+
attr_reader last_event: ActivityEvent?
|
|
20
|
+
|
|
21
|
+
# What credits the rows of a step `last_boundary` opens.
|
|
22
|
+
attr_reader last_attribution: ChangeAttribution?
|
|
23
|
+
|
|
24
|
+
# : (steps: Array[ActivityStep], root_snapshots: Hash[Array[untyped], RecordSnapshot?], first_snapshot: RecordSnapshot?, last_snapshot: RecordSnapshot?, ?last_boundary: ActivityBoundary?, ?last_event_snapshot: RecordSnapshot?, ?last_event: ActivityEvent?, ?last_attribution: ChangeAttribution?) -> void
|
|
25
|
+
def initialize: (steps: Array[ActivityStep], root_snapshots: Hash[Array[untyped], RecordSnapshot?], first_snapshot: RecordSnapshot?, last_snapshot: RecordSnapshot?, ?last_boundary: ActivityBoundary?, ?last_event_snapshot: RecordSnapshot?, ?last_event: ActivityEvent?, ?last_attribution: ChangeAttribution?) -> void
|
|
20
26
|
|
|
21
27
|
# : () -> ActivityHistory
|
|
22
28
|
def self.empty: () -> ActivityHistory
|
|
@@ -27,8 +33,11 @@ module PaperTrailDiff
|
|
|
27
33
|
# `closing` is the snapshot after the last event when the range closes on
|
|
28
34
|
# the current record. Any other range ends at a root event, or at events
|
|
29
35
|
# after a window whose steps are not reported, so nothing reads it.
|
|
30
|
-
#
|
|
31
|
-
|
|
36
|
+
# `include_step` says whether an event's step is reported. `root` names
|
|
37
|
+
# the root, whose steps then credit each change row to the version that
|
|
38
|
+
# made it (see ChangeAttribution).
|
|
39
|
+
# : (Array[untyped], Array[ActivityEvent], untyped, view: ActivityView, include_step: untyped, ?current: untyped, ?closing: RecordSnapshot?, ?root: RecordReference?) -> void
|
|
40
|
+
def initialize: (Array[untyped], Array[ActivityEvent], untyped, view: ActivityView, include_step: untyped, ?current: untyped, ?closing: RecordSnapshot?, ?root: RecordReference?) -> void
|
|
32
41
|
|
|
33
42
|
# : () -> ActivityHistory
|
|
34
43
|
def call: () -> ActivityHistory
|
|
@@ -41,11 +50,17 @@ module PaperTrailDiff
|
|
|
41
50
|
|
|
42
51
|
@events: Array[ActivityEvent]
|
|
43
52
|
|
|
53
|
+
@first_pending: bool
|
|
54
|
+
|
|
44
55
|
@first_snapshot: RecordSnapshot?
|
|
45
56
|
|
|
46
57
|
@include_step: untyped
|
|
47
58
|
|
|
48
|
-
@
|
|
59
|
+
@opening: Array[Array[untyped]]?
|
|
60
|
+
|
|
61
|
+
@passed_reported: bool?
|
|
62
|
+
|
|
63
|
+
@previous_attribution: ChangeAttribution?
|
|
49
64
|
|
|
50
65
|
@previous_boundary: ActivityBoundary?
|
|
51
66
|
|
|
@@ -53,6 +68,8 @@ module PaperTrailDiff
|
|
|
53
68
|
|
|
54
69
|
@previous_snapshot: RecordSnapshot?
|
|
55
70
|
|
|
71
|
+
@root: RecordReference?
|
|
72
|
+
|
|
56
73
|
@root_snapshots: Hash[Array[untyped], RecordSnapshot?]
|
|
57
74
|
|
|
58
75
|
@root_versions: Array[untyped]
|
|
@@ -63,10 +80,9 @@ module PaperTrailDiff
|
|
|
63
80
|
|
|
64
81
|
@steps: Array[ActivityStep]
|
|
65
82
|
|
|
66
|
-
@
|
|
83
|
+
@transactions: Hash[Array[untyped], ChangeAttribution::Transaction]
|
|
67
84
|
|
|
68
|
-
|
|
69
|
-
def reset: () -> void
|
|
85
|
+
@view: ActivityView
|
|
70
86
|
|
|
71
87
|
# : () -> ActivityTreeFilter
|
|
72
88
|
def filter: () -> ActivityTreeFilter
|
|
@@ -76,25 +92,44 @@ module PaperTrailDiff
|
|
|
76
92
|
|
|
77
93
|
# A left-out event bounds nothing. A reported step it would have opened
|
|
78
94
|
# still moves the reported range's end past it, to the next boundary.
|
|
95
|
+
#
|
|
96
|
+
# The history starts at the first kept event whose step is reported. The
|
|
97
|
+
# events left out before it change nothing the root shows, unless they are
|
|
98
|
+
# of a transaction that crossed the window's start and has no event kept
|
|
99
|
+
# here: the snapshot at them is the state before that transaction, whose
|
|
100
|
+
# changes the window before this one reports (see ActivityTreeFilter). And
|
|
101
|
+
# a version filter starts it at the first change it keeps.
|
|
79
102
|
# : (ActivityEvent, RecordSnapshot?, bool) -> void
|
|
80
103
|
def consume: (ActivityEvent, RecordSnapshot?, bool) -> void
|
|
81
104
|
|
|
105
|
+
# Inside a transaction a record's change can surface at a later event
|
|
106
|
+
# than its own, so the rows of a step its boundary opens are read with
|
|
107
|
+
# the boundaries its transaction kept before it (see ChangeAttribution).
|
|
108
|
+
# : (ActivityEvent, ActivityBoundary) -> ChangeAttribution?
|
|
109
|
+
def attribution: (ActivityEvent, ActivityBoundary) -> ChangeAttribution?
|
|
110
|
+
|
|
111
|
+
# The boundaries kept so far of the event's transaction, and whether the
|
|
112
|
+
# history holds all of it. A version saved outside a transaction is a
|
|
113
|
+
# transaction of its own.
|
|
114
|
+
# : (ActivityEvent) -> [ChangeAttribution::Transaction, bool]
|
|
115
|
+
def transaction_of: (ActivityEvent) -> [ ChangeAttribution::Transaction, bool ]
|
|
116
|
+
|
|
117
|
+
# The transactions that began before the history did (see
|
|
118
|
+
# PreparedHistoryLoader#reload).
|
|
119
|
+
# : () -> Array[Array[untyped]]
|
|
120
|
+
def opening: () -> Array[Array[untyped]]
|
|
121
|
+
|
|
82
122
|
# : (ActivityEvent) -> void
|
|
83
123
|
def pass: (ActivityEvent) -> void
|
|
84
124
|
|
|
85
|
-
# : (RecordSnapshot?) -> void
|
|
86
|
-
def capture_first: (RecordSnapshot?) -> void
|
|
125
|
+
# : (ActivityEvent, RecordSnapshot?) -> void
|
|
126
|
+
def capture_first: (ActivityEvent, RecordSnapshot?) -> void
|
|
127
|
+
|
|
128
|
+
# : (ActivityEvent) -> bool
|
|
129
|
+
def reported?: (ActivityEvent) -> bool
|
|
87
130
|
|
|
131
|
+
# The step from the previous boundary, which `consume` has, to this one.
|
|
88
132
|
# : (ActivityBoundary, RecordSnapshot?) -> void
|
|
89
133
|
def append_step: (ActivityBoundary, RecordSnapshot?) -> void
|
|
90
|
-
|
|
91
|
-
# : () -> bool
|
|
92
|
-
def include_previous_step?: () -> bool
|
|
93
|
-
|
|
94
|
-
# : () -> RecordSnapshot?
|
|
95
|
-
def final_snapshot: () -> RecordSnapshot?
|
|
96
|
-
|
|
97
|
-
# : (untyped) -> Array[untyped]
|
|
98
|
-
def version_key: (untyped) -> Array[untyped]
|
|
99
134
|
end
|
|
100
135
|
end
|
|
@@ -5,28 +5,18 @@ module PaperTrailDiff
|
|
|
5
5
|
class ActivityRange
|
|
6
6
|
attr_reader start_time: untyped
|
|
7
7
|
|
|
8
|
-
attr_reader end_time: untyped
|
|
9
|
-
|
|
10
8
|
# : (untyped, untyped) -> void
|
|
11
9
|
def initialize: (untyped, untyped) -> void
|
|
12
10
|
|
|
13
11
|
# : (untyped) -> bool
|
|
14
12
|
def include?: (untyped) -> bool
|
|
15
13
|
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# : () -> bool
|
|
23
|
-
def current_end?: () -> bool
|
|
24
|
-
|
|
25
|
-
# Whether the state a version recorded after its change held inside the
|
|
26
|
-
# range. A range ending at a version ends at the state before it, so the
|
|
27
|
-
# change that version records is past the end, unlike #include?.
|
|
28
|
-
# : (untyped, untyped) -> bool
|
|
29
|
-
def recorded_before_end?: (untyped, untyped) -> bool
|
|
14
|
+
# A range starting at a version starts before that version's transaction,
|
|
15
|
+
# where PT-AT reads its associations. A version saved earlier in it, such
|
|
16
|
+
# as the child update behind a `touch: true` parent version, is a change
|
|
17
|
+
# inside the range.
|
|
18
|
+
# : (untyped) -> bool
|
|
19
|
+
def opening?: (untyped) -> bool
|
|
30
20
|
|
|
31
21
|
private
|
|
32
22
|
|
|
@@ -40,10 +30,6 @@ module PaperTrailDiff
|
|
|
40
30
|
|
|
41
31
|
@start_time: untyped
|
|
42
32
|
|
|
43
|
-
# A range starting at a version starts before that version's transaction,
|
|
44
|
-
# where PT-AT reads its associations. A version saved earlier in it, such
|
|
45
|
-
# as the child update behind a `touch: true` parent version, is a change
|
|
46
|
-
# inside the range.
|
|
47
33
|
# : (untyped, Array[untyped]) -> bool
|
|
48
34
|
def after_start?: (untyped, Array[untyped]) -> bool
|
|
49
35
|
|
|
@@ -3,14 +3,46 @@
|
|
|
3
3
|
module PaperTrailDiff
|
|
4
4
|
# Advances scalar-only root events while retaining already reconstructed associations.
|
|
5
5
|
class ActivityRootSnapshotRefresher
|
|
6
|
-
#
|
|
7
|
-
|
|
6
|
+
# `root_state` gives the state a root endpoint's snapshot is built from,
|
|
7
|
+
# where prepared history builds it.
|
|
8
|
+
# : (traversal: AssociationTraversal, normalizer: SnapshotNormalizer, record_after: untyped, changeset: untyped, partial_snapshotter: untyped, ?record_transition: untyped, ?root_state: untyped) -> void
|
|
9
|
+
def initialize: (traversal: AssociationTraversal, normalizer: SnapshotNormalizer, record_after: untyped, changeset: untyped, partial_snapshotter: untyped, ?record_transition: untyped, ?root_state: untyped) -> void
|
|
8
10
|
|
|
11
|
+
# `previous` is the snapshot at the root's `event`, and the result the one
|
|
12
|
+
# at the next event, whose root is read at `root_endpoint`.
|
|
9
13
|
# : (untyped, untyped, RecordSnapshot?, ActivityEvent) -> [bool, RecordSnapshot?]
|
|
10
14
|
def call: (untyped, untyped, RecordSnapshot?, ActivityEvent) -> [ bool, RecordSnapshot? ]
|
|
11
15
|
|
|
12
16
|
private
|
|
13
17
|
|
|
18
|
+
# The snapshot at a root version starts from the state stored in that
|
|
19
|
+
# version, and the next one from the state at its own root endpoint. Where
|
|
20
|
+
# prepared history built both from those states, the two are compared
|
|
21
|
+
# directly; nothing else needs to be decoded. Otherwise the version's
|
|
22
|
+
# recorded change and the record after it are read.
|
|
23
|
+
# : (RecordSnapshot, untyped, untyped) -> [untyped, Array[String]]?
|
|
24
|
+
def target: (RecordSnapshot, untyped, untyped) -> [ untyped, Array[String] ]?
|
|
25
|
+
|
|
26
|
+
# The state at the next event and the branches whose reads the root's
|
|
27
|
+
# change between the two states can alter. A change of STI class can
|
|
28
|
+
# change the associations themselves, so it is rebuilt in full.
|
|
29
|
+
# : (RecordSnapshot, untyped, PreparedRecordState, PreparedRecordState) -> [PreparedRecordState, Array[String]]?
|
|
30
|
+
def state_target: (RecordSnapshot, untyped, PreparedRecordState, PreparedRecordState) -> [ PreparedRecordState, Array[String] ]?
|
|
31
|
+
|
|
32
|
+
# The names of the columns whose values differ between two sets of them.
|
|
33
|
+
# : (Hash[untyped, untyped], Hash[untyped, untyped]) -> Array[String]
|
|
34
|
+
def differing: (Hash[untyped, untyped], Hash[untyped, untyped]) -> Array[String]
|
|
35
|
+
|
|
36
|
+
# The record after a root version and the branches its change reaches, or
|
|
37
|
+
# nil when the version cannot be applied to the previous snapshot alone.
|
|
38
|
+
# : (RecordSnapshot, untyped) -> [untyped, Array[String]]?
|
|
39
|
+
def advance_target: (RecordSnapshot, untyped) -> [ untyped, Array[String] ]?
|
|
40
|
+
|
|
41
|
+
# The previous snapshot with the record's attributes and any branches read
|
|
42
|
+
# again, or the previous snapshot itself when nothing differs.
|
|
43
|
+
# : (RecordSnapshot, untyped, RecordSnapshot?) -> RecordSnapshot
|
|
44
|
+
def advanced: (RecordSnapshot, untyped, RecordSnapshot?) -> RecordSnapshot
|
|
45
|
+
|
|
14
46
|
@changeset: untyped
|
|
15
47
|
|
|
16
48
|
@normalizer: SnapshotNormalizer
|
|
@@ -23,6 +55,8 @@ module PaperTrailDiff
|
|
|
23
55
|
|
|
24
56
|
@relationship_reflections: Hash[String, Array[untyped]]
|
|
25
57
|
|
|
58
|
+
@root_state: untyped
|
|
59
|
+
|
|
26
60
|
@traversal: AssociationTraversal
|
|
27
61
|
|
|
28
62
|
@tree: AssociationTree
|
|
@@ -5,14 +5,14 @@ module PaperTrailDiff
|
|
|
5
5
|
# so a combined result does not reconstruct the same boundaries twice.
|
|
6
6
|
module ActivityRootSteps
|
|
7
7
|
# A window closing on current state ends at the live record, which no
|
|
8
|
-
# version-keyed snapshot can supply, so that endpoint is passed in.
|
|
8
|
+
# version-keyed snapshot can supply, so that endpoint is passed in. A plan
|
|
9
|
+
# that replays versions a filter left out reports the steps of the ones it
|
|
10
|
+
# kept, as `timeline` does. Every version a plan names is a root event of
|
|
11
|
+
# the history, which keeps its snapshot.
|
|
9
12
|
# : (RootVersionPlan, Hash[Array[untyped], RecordSnapshot?], ?closing_snapshot: RecordSnapshot?, ?captured_at: untyped) -> Array[Step]
|
|
10
|
-
def self
|
|
13
|
+
def self.call: (RootVersionPlan, Hash[Array[untyped], RecordSnapshot?], ?closing_snapshot: RecordSnapshot?, ?captured_at: untyped) -> Array[Step]
|
|
11
14
|
|
|
12
15
|
# : (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?
|
|
13
|
-
def self
|
|
14
|
-
|
|
15
|
-
# : (untyped) -> Array[untyped]
|
|
16
|
-
def self?.version_key: (untyped) -> Array[untyped]
|
|
16
|
+
def self.snapshot_for: (untyped, Hash[Array[untyped], RecordSnapshot?], RecordSnapshot?) -> RecordSnapshot?
|
|
17
17
|
end
|
|
18
18
|
end
|