paper_trail_diff 0.16.0 → 0.17.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 +566 -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 +314 -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 +170 -42
- 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 +1 -12
- 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 +185 -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 +103 -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 +0 -7
- 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
|
@@ -5,10 +5,16 @@ module PaperTrailDiff
|
|
|
5
5
|
class PreparedHistory
|
|
6
6
|
attr_reader activity_index: PreparedActivityIndex?
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# The transactions that crossed the history's start, keyed as
|
|
9
|
+
# ActivityTransactionGroups keys a version's; see
|
|
10
|
+
# PreparedHistoryLoader#reload.
|
|
11
|
+
attr_reader opening_transactions: Array[Array[untyped]]
|
|
9
12
|
|
|
10
|
-
# : (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
|
|
11
|
-
def initialize: (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?) -> void
|
|
13
|
+
# : (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?, ?opening_transactions: Array[Array[untyped]]) -> void
|
|
14
|
+
def initialize: (PreparedRecordIndex, ?activity_index: PreparedActivityIndex?, ?opening_transactions: Array[Array[untyped]]) -> void
|
|
15
|
+
|
|
16
|
+
# : () -> Array[untyped]
|
|
17
|
+
def versions: () -> Array[untyped]
|
|
12
18
|
|
|
13
19
|
# Returns every group the edge now holds.
|
|
14
20
|
# : (untyped, untyped, Hash[String, Hash[Symbol, untyped]]) -> Hash[String, Hash[Symbol, untyped]]
|
|
@@ -59,12 +65,6 @@ module PaperTrailDiff
|
|
|
59
65
|
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
60
66
|
def direct_records: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
61
67
|
|
|
62
|
-
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
63
|
-
def resolve_belongs_to: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
64
|
-
|
|
65
|
-
# : (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
|
|
66
|
-
def resolve_children: (untyped, untyped, untyped, untyped, bool) -> Array[untyped]
|
|
67
|
-
|
|
68
68
|
# : (untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
69
69
|
def belongs_to_records: (untyped, untyped, untyped, bool) -> Array[untyped]?
|
|
70
70
|
|
|
@@ -100,9 +100,6 @@ module PaperTrailDiff
|
|
|
100
100
|
# : (untyped, untyped, untyped) -> bool
|
|
101
101
|
def member_of?: (untyped, untyped, untyped) -> bool
|
|
102
102
|
|
|
103
|
-
# : (untyped) -> String?
|
|
104
|
-
def scalar_foreign_key: (untyped) -> String?
|
|
105
|
-
|
|
106
103
|
# : (untyped, untyped) -> Array[String]
|
|
107
104
|
def owner_types: (untyped, untyped) -> Array[String]
|
|
108
105
|
|
|
@@ -4,8 +4,11 @@ module PaperTrailDiff
|
|
|
4
4
|
# Expands the explicit association tree into a request-scoped PreparedHistory.
|
|
5
5
|
class PreparedHistoryLoader
|
|
6
6
|
# Without `end_at`, the activity range closes on the last root version.
|
|
7
|
-
#
|
|
8
|
-
|
|
7
|
+
# A `window` is a time range; a range of versions starts at the state its
|
|
8
|
+
# first version names. `opening` names the transactions that crossed the
|
|
9
|
+
# window's start when this history is read again from where they began.
|
|
10
|
+
# : (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped], ?window: bool, ?opening: Array[Array[untyped]]) -> void
|
|
11
|
+
def initialize: (untyped, root_ids: Array[untyped], root_versions: Array[untyped], tree: AssociationTree, traversal: AssociationTraversal, start_at: untyped, end_at: untyped, live_records: Array[untyped], ?window: bool, ?opening: Array[Array[untyped]]) -> void
|
|
9
12
|
|
|
10
13
|
# : () -> PreparedHistory
|
|
11
14
|
def call: () -> PreparedHistory
|
|
@@ -16,9 +19,13 @@ module PaperTrailDiff
|
|
|
16
19
|
|
|
17
20
|
@edges: PreparedEdgeLoader
|
|
18
21
|
|
|
22
|
+
@end_at: untyped
|
|
23
|
+
|
|
19
24
|
@history: PreparedHistory
|
|
20
25
|
|
|
21
|
-
@
|
|
26
|
+
@live_records: Array[untyped]
|
|
27
|
+
|
|
28
|
+
@prepared: Hash[untyped, Set[String]]
|
|
22
29
|
|
|
23
30
|
@record: untyped
|
|
24
31
|
|
|
@@ -32,6 +39,24 @@ module PaperTrailDiff
|
|
|
32
39
|
|
|
33
40
|
@tree: AssociationTree
|
|
34
41
|
|
|
42
|
+
@window: bool
|
|
43
|
+
|
|
44
|
+
# A transaction that crosses a window's start and saved a version of the
|
|
45
|
+
# root moves the window's edge back to where it began (see
|
|
46
|
+
# TransactionCut); one that saved only associated records moves nothing.
|
|
47
|
+
# A boundary in such a transaction still reads each record as it stood
|
|
48
|
+
# before the transaction began (see PreparedRecordSeries#boundary_index),
|
|
49
|
+
# and a history read from the window's start holds neither the versions
|
|
50
|
+
# it saved before the start nor the records only those versions name, such
|
|
51
|
+
# as one it destroyed there. Without them the window would start after
|
|
52
|
+
# changes that the window before it left to this one, by ending its step
|
|
53
|
+
# at one of the transaction's events here (see ActivityTreeFilter), and
|
|
54
|
+
# neither would report them. So the history is read again from where the
|
|
55
|
+
# earliest such transaction began; the window's events still start at its
|
|
56
|
+
# start.
|
|
57
|
+
# : (Array[Array[untyped]], untyped) -> PreparedHistory
|
|
58
|
+
def reload: (Array[Array[untyped]], untyped) -> PreparedHistory
|
|
59
|
+
|
|
35
60
|
# : (untyped, Array[untyped], AssociationTree, path: String) -> void
|
|
36
61
|
def load_node: (untyped, Array[untyped], AssociationTree, path: String) -> void
|
|
37
62
|
|
|
@@ -45,9 +45,6 @@ module PaperTrailDiff
|
|
|
45
45
|
|
|
46
46
|
@serializers: Hash[untyped, untyped]
|
|
47
47
|
|
|
48
|
-
# : (Hash[untyped, untyped]) -> Hash[String, untyped]
|
|
49
|
-
def stringify_keys: (Hash[untyped, untyped]) -> Hash[String, untyped]
|
|
50
|
-
|
|
51
48
|
# : (untyped, Hash[String, untyped]) -> untyped
|
|
52
49
|
def reification_class: (untyped, Hash[String, untyped]) -> untyped
|
|
53
50
|
|
|
@@ -62,8 +59,11 @@ module PaperTrailDiff
|
|
|
62
59
|
class PreparedRecordSeries
|
|
63
60
|
attr_reader versions: Array[untyped]
|
|
64
61
|
|
|
65
|
-
#
|
|
66
|
-
|
|
62
|
+
# The live fallback is a state, or a current record whose state is read
|
|
63
|
+
# the first time a read reaches past the last version. Most reads stop at
|
|
64
|
+
# a version, and reading a row's state casts every column it has.
|
|
65
|
+
# : (versions: Array[untyped], live: PreparedRecordState?, ?live_record: untyped, ?state_loader: PreparedVersionStateLoader) -> void
|
|
66
|
+
def initialize: (versions: Array[untyped], live: PreparedRecordState?, ?live_record: untyped, ?state_loader: PreparedVersionStateLoader) -> void
|
|
67
67
|
|
|
68
68
|
# : (untyped) -> untyped
|
|
69
69
|
def record_before: (untyped) -> untyped
|
|
@@ -88,14 +88,14 @@ module PaperTrailDiff
|
|
|
88
88
|
# : () -> Array[PreparedRecordState]
|
|
89
89
|
def states: () -> Array[PreparedRecordState]
|
|
90
90
|
|
|
91
|
-
# The classes the record had at any point, or either side of one version
|
|
91
|
+
# The classes the record had at any point, or either side of one version:
|
|
92
|
+
# a create has no state before it and a destroy none after.
|
|
92
93
|
# : (?untyped) -> Array[untyped]
|
|
93
94
|
def model_classes: (?untyped) -> Array[untyped]
|
|
94
95
|
|
|
95
|
-
# The states
|
|
96
|
-
#
|
|
97
|
-
|
|
98
|
-
def states_around: (untyped) -> Array[PreparedRecordState]
|
|
96
|
+
# The states before `first` and after `last`, where they exist.
|
|
97
|
+
# : (untyped, untyped) -> Array[PreparedRecordState]
|
|
98
|
+
def states_across: (untyped, untyped) -> Array[PreparedRecordState]
|
|
99
99
|
|
|
100
100
|
# : (untyped) -> [PreparedRecordState, PreparedRecordState]?
|
|
101
101
|
def transition: (untyped) -> [ PreparedRecordState, PreparedRecordState ]?
|
|
@@ -104,10 +104,14 @@ module PaperTrailDiff
|
|
|
104
104
|
|
|
105
105
|
@live: PreparedRecordState?
|
|
106
106
|
|
|
107
|
+
@live_record: untyped
|
|
108
|
+
|
|
107
109
|
@state_loader: PreparedVersionStateLoader
|
|
108
110
|
|
|
109
111
|
@states: Hash[untyped, PreparedRecordState?]
|
|
110
112
|
|
|
113
|
+
@times: Array[untyped]
|
|
114
|
+
|
|
111
115
|
@transaction_positions: Hash[untyped, Integer]
|
|
112
116
|
|
|
113
117
|
@version_positions: Hash[String, Integer]
|
|
@@ -115,6 +119,9 @@ module PaperTrailDiff
|
|
|
115
119
|
# : (Integer) -> PreparedRecordState?
|
|
116
120
|
def state_after: (Integer) -> PreparedRecordState?
|
|
117
121
|
|
|
122
|
+
# : () -> PreparedRecordState?
|
|
123
|
+
def live: () -> PreparedRecordState?
|
|
124
|
+
|
|
118
125
|
# A version is eligible when it is at or after the boundary, or shares the
|
|
119
126
|
# boundary's transaction. The first is monotonic over the chronological
|
|
120
127
|
# list and the second is indexed, so neither rescans a long history once
|
|
@@ -123,7 +130,8 @@ module PaperTrailDiff
|
|
|
123
130
|
# "At or after" is decided by the version order rather than the timestamp
|
|
124
131
|
# alone. A version written in the same instant as the boundary but before
|
|
125
132
|
# it already took effect there; reading its pre-change state would put the
|
|
126
|
-
# boundary on the wrong side of a change it follows.
|
|
133
|
+
# boundary on the wrong side of a change it follows. Each time is read
|
|
134
|
+
# once, since every record is placed against every boundary.
|
|
127
135
|
# : (untyped) -> Integer?
|
|
128
136
|
def boundary_index: (untyped) -> Integer?
|
|
129
137
|
|
|
@@ -148,6 +156,12 @@ module PaperTrailDiff
|
|
|
148
156
|
# : (untyped, Array[untyped], Array[untyped]) -> void
|
|
149
157
|
def seed: (untyped, Array[untyped], Array[untyped]) -> void
|
|
150
158
|
|
|
159
|
+
# The transactions the versions held from the start onward belong to that
|
|
160
|
+
# began before it, and where the earliest of them began; see
|
|
161
|
+
# PreparedHistoryLoader. Nothing when none did.
|
|
162
|
+
# : () -> [Array[Array[untyped]], untyped]?
|
|
163
|
+
def opening: () -> [ Array[Array[untyped]], untyped ]?
|
|
164
|
+
|
|
151
165
|
# : (untyped, untyped, untyped) -> untyped
|
|
152
166
|
def record_before: (untyped, untyped, untyped) -> untyped
|
|
153
167
|
|
|
@@ -175,11 +189,16 @@ module PaperTrailDiff
|
|
|
175
189
|
# : (untyped, untyped) -> Array[untyped]
|
|
176
190
|
def versions_for_id: (untyped, untyped) -> Array[untyped]
|
|
177
191
|
|
|
192
|
+
# : () -> Array[untyped]
|
|
193
|
+
def versions: () -> Array[untyped]
|
|
194
|
+
|
|
178
195
|
# : (untyped, untyped, ?untyped) -> Array[untyped]
|
|
179
196
|
def model_classes: (untyped, untyped, ?untyped) -> Array[untyped]
|
|
180
197
|
|
|
181
|
-
#
|
|
182
|
-
|
|
198
|
+
# The attributes before `first` and after `last`, where they exist, typed
|
|
199
|
+
# as a reified record's are.
|
|
200
|
+
# : (untyped, untyped, untyped, untyped) -> Array[Hash[untyped, untyped]]
|
|
201
|
+
def typed_states_across: (untyped, untyped, untyped, untyped) -> Array[Hash[untyped, untyped]]
|
|
183
202
|
|
|
184
203
|
# : (untyped, untyped) -> bool
|
|
185
204
|
def loaded?: (untyped, untyped) -> bool
|
|
@@ -191,6 +210,11 @@ module PaperTrailDiff
|
|
|
191
210
|
# : (PreparedRecordState) -> Hash[untyped, untyped]
|
|
192
211
|
def typed_attributes: (PreparedRecordState) -> Hash[untyped, untyped]
|
|
193
212
|
|
|
213
|
+
# A state completed as a record of its class would hold it, or nil where
|
|
214
|
+
# only instantiating can tell; each state is completed once.
|
|
215
|
+
# : (PreparedRecordState) -> PreparedRecordState?
|
|
216
|
+
def direct_state: (PreparedRecordState) -> PreparedRecordState?
|
|
217
|
+
|
|
194
218
|
# : (untyped, String) -> bool
|
|
195
219
|
def generated_reader?: (untyped, String) -> bool
|
|
196
220
|
|
|
@@ -224,7 +248,8 @@ module PaperTrailDiff
|
|
|
224
248
|
# A PaperTrail version is a pre-change snapshot, so the state at the last
|
|
225
249
|
# selected boundary can only live in the next version after it. One
|
|
226
250
|
# trailing version per identity is retained, rather than every version
|
|
227
|
-
# recorded between the requested range and the present.
|
|
251
|
+
# recorded between the requested range and the present. Each record's
|
|
252
|
+
# versions are read in one statement, which takes 500 records.
|
|
228
253
|
# : (untyped, Array[untyped]) -> Array[untyped]
|
|
229
254
|
def versions_for: (untyped, Array[untyped]) -> Array[untyped]
|
|
230
255
|
|
|
@@ -239,4 +264,33 @@ module PaperTrailDiff
|
|
|
239
264
|
# : (untyped, Array[untyped]) -> Array[untyped]
|
|
240
265
|
def live_records_for: (untyped, Array[untyped]) -> Array[untyped]
|
|
241
266
|
end
|
|
267
|
+
|
|
268
|
+
# Finds the transactions that crossed a history's start: those the versions
|
|
269
|
+
# held from the start onward belong to that also saved versions before it,
|
|
270
|
+
# of any record. One statement per 500 transactions.
|
|
271
|
+
class OpeningTransactions
|
|
272
|
+
# : (Hash[Array[String], PreparedRecordSeries], untyped) -> void
|
|
273
|
+
def initialize: (Hash[Array[String], PreparedRecordSeries], untyped) -> void
|
|
274
|
+
|
|
275
|
+
# Their keys, as ActivityTransactionGroups keys a version's, and when the
|
|
276
|
+
# earliest began; nil when none crossed the start.
|
|
277
|
+
# : () -> [Array[Array[untyped]], untyped]?
|
|
278
|
+
def call: () -> [ Array[Array[untyped]], untyped ]?
|
|
279
|
+
|
|
280
|
+
private
|
|
281
|
+
|
|
282
|
+
# When each of these transactions saved its first version before the
|
|
283
|
+
# start, for those that saved one there.
|
|
284
|
+
# : (untyped, Array[untyped]) -> Array[[untyped, untyped]]
|
|
285
|
+
def earliest: (untyped, Array[untyped]) -> Array[[ untyped, untyped ]]
|
|
286
|
+
|
|
287
|
+
@series: Hash[Array[String], PreparedRecordSeries]
|
|
288
|
+
|
|
289
|
+
@start: untyped
|
|
290
|
+
|
|
291
|
+
# The transactions of the versions held from the start onward, by version
|
|
292
|
+
# class, since each version table numbers its own.
|
|
293
|
+
# : () -> Hash[untyped, Array[untyped]]
|
|
294
|
+
def transactions: () -> Hash[untyped, Array[untyped]]
|
|
295
|
+
end
|
|
242
296
|
end
|
|
@@ -9,6 +9,18 @@ module PaperTrailDiff
|
|
|
9
9
|
# : (untyped, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [bool, RecordSnapshot?]
|
|
10
10
|
def call: (untyped, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [ bool, RecordSnapshot? ]
|
|
11
11
|
|
|
12
|
+
# The state `call` builds a version's snapshot from, or nil when the
|
|
13
|
+
# version stored none or must be reified.
|
|
14
|
+
# : (untyped) -> PreparedRecordState?
|
|
15
|
+
def state: (untyped) -> PreparedRecordState?
|
|
16
|
+
|
|
17
|
+
# The current row of a root, given as its state, with its associations as
|
|
18
|
+
# `boundary` reads them. Its attributes are the record's own, as the record
|
|
19
|
+
# path normalizes them, so its model need not be plain; its members are
|
|
20
|
+
# read as a version's are.
|
|
21
|
+
# : (PreparedRecordState, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [bool, RecordSnapshot?]
|
|
22
|
+
def live: (PreparedRecordState, untyped, tree: AssociationTree, normalizer: SnapshotNormalizer, history: PreparedHistory?) -> [ bool, RecordSnapshot? ]
|
|
23
|
+
|
|
12
24
|
private
|
|
13
25
|
|
|
14
26
|
@loader: DirectRecordStateLoader
|
|
@@ -34,9 +34,6 @@ module PaperTrailDiff
|
|
|
34
34
|
# : (PreparedRecordState, untyped, untyped, bool) -> [bool, Array[PreparedRecordState]]
|
|
35
35
|
def target: (PreparedRecordState, untyped, untyped, bool) -> [ bool, Array[PreparedRecordState] ]
|
|
36
36
|
|
|
37
|
-
# : (PreparedRecordState, untyped) -> untyped
|
|
38
|
-
def target_class: (PreparedRecordState, untyped) -> untyped
|
|
39
|
-
|
|
40
37
|
# The members of each join record the owner had at the boundary, as
|
|
41
38
|
# PreparedHistory#through_records reads them from records. Under
|
|
42
39
|
# `source_type:`, only join records of that type count. A has_many
|
|
@@ -60,14 +57,16 @@ module PaperTrailDiff
|
|
|
60
57
|
# : (PreparedRecordState) -> Array[untyped]
|
|
61
58
|
def identity: (PreparedRecordState) -> Array[untyped]
|
|
62
59
|
|
|
60
|
+
# The scope's condition and the owner's id are read once for all the
|
|
61
|
+
# owner's children, which are read at every boundary.
|
|
63
62
|
# : (PreparedRecordState, untyped, untyped, bool) -> [bool, Array[PreparedRecordState]]
|
|
64
63
|
def children: (PreparedRecordState, untyped, untyped, bool) -> [ bool, Array[PreparedRecordState] ]
|
|
65
64
|
|
|
66
|
-
# : (untyped,
|
|
67
|
-
def ids_for: (untyped,
|
|
65
|
+
# : (untyped, String) -> Array[untyped]
|
|
66
|
+
def ids_for: (untyped, String) -> Array[untyped]
|
|
68
67
|
|
|
69
|
-
# : (PreparedRecordState, PreparedRecordState, untyped,
|
|
70
|
-
def member?: (PreparedRecordState, PreparedRecordState, untyped,
|
|
68
|
+
# : (PreparedRecordState, PreparedRecordState, String, untyped, ScopeCondition) -> bool
|
|
69
|
+
def member?: (PreparedRecordState, PreparedRecordState, String, untyped, ScopeCondition) -> bool
|
|
71
70
|
|
|
72
71
|
# : (PreparedRecordState) -> String
|
|
73
72
|
def owner_id: (PreparedRecordState) -> String
|
|
@@ -8,36 +8,55 @@ module PaperTrailDiff
|
|
|
8
8
|
#
|
|
9
9
|
# PostgreSQL and MySQL (through mysql2 or trilogy), and adapters built on
|
|
10
10
|
# them such as PostGIS, run the read at REPEATABLE READ, which gives every
|
|
11
|
-
# statement of the transaction the same view.
|
|
12
|
-
#
|
|
11
|
+
# statement of the transaction the same view. SQL Server runs it at SNAPSHOT
|
|
12
|
+
# when the database allows that isolation level, which it does only after
|
|
13
|
+
# `ALTER DATABASE ... SET ALLOW_SNAPSHOT_ISOLATION ON`; otherwise SNAPSHOT
|
|
14
|
+
# raises, so it takes none. Other adapters get no snapshot; docs/reference.md
|
|
15
|
+
# lists them under limitations.
|
|
13
16
|
module ReadSnapshot
|
|
14
17
|
# The adapters whose subclasses take a snapshot, by name, since an
|
|
15
18
|
# application loads only the adapters it uses.
|
|
16
19
|
SNAPSHOT_ADAPTERS: untyped
|
|
17
20
|
|
|
21
|
+
SQL_SERVER_ADAPTER: ::String
|
|
22
|
+
|
|
23
|
+
# 1 is ON. The setting can change while the application runs, so it is
|
|
24
|
+
# read for each call; the catalog answers at once.
|
|
25
|
+
SQL_SERVER_SNAPSHOT_STATE: ::String
|
|
26
|
+
|
|
18
27
|
# Yields once. Each connection the values read through gets a snapshot
|
|
19
28
|
# transaction first, unless that connection already has a transaction open:
|
|
20
29
|
# its isolation level belongs to the caller, and this gem cannot change it.
|
|
21
30
|
# A value may be a model class, a relation, a record, or a version. Any
|
|
22
31
|
# other value reads no table and is ignored.
|
|
23
32
|
# : (Array[untyped]) { () -> untyped } -> untyped
|
|
24
|
-
def self
|
|
33
|
+
def self.call: (Array[untyped]) { () -> untyped } -> untyped
|
|
34
|
+
|
|
35
|
+
# The isolation level that gives this connection's statements one view, or
|
|
36
|
+
# nil when it has none.
|
|
37
|
+
# : (untyped) -> Symbol?
|
|
38
|
+
def self.isolation: (untyped) -> Symbol?
|
|
39
|
+
|
|
40
|
+
# : (untyped, Array[String]) -> bool
|
|
41
|
+
def self.adapter?: (untyped, Array[String]) -> bool
|
|
25
42
|
|
|
43
|
+
# Named as a schema query, as Active Record names its own catalog reads.
|
|
26
44
|
# : (untyped) -> bool
|
|
27
|
-
def self
|
|
45
|
+
def self.sql_server_snapshot?: (untyped) -> bool
|
|
28
46
|
|
|
29
47
|
# One class per connection: each read model and its version class, with the
|
|
30
48
|
# repeats through a shared connection dropped. An associated model on
|
|
31
49
|
# another database is not among them, so it is read outside the snapshot.
|
|
32
50
|
# : (Array[untyped]) -> Array[untyped]
|
|
33
|
-
def self
|
|
51
|
+
def self.connection_classes: (Array[untyped]) -> Array[untyped]
|
|
34
52
|
|
|
35
53
|
# The versioned model a value reads from, or nil.
|
|
36
54
|
# : (untyped) -> untyped
|
|
37
|
-
def self
|
|
55
|
+
def self.model_for: (untyped) -> untyped
|
|
38
56
|
|
|
39
|
-
# A version reads the model of its item;
|
|
57
|
+
# A version reads the model of its item; anything else its own class,
|
|
58
|
+
# which is a versioned model only for a record.
|
|
40
59
|
# : (untyped) -> untyped
|
|
41
|
-
def self
|
|
60
|
+
def self.endpoint_model: (untyped) -> untyped
|
|
42
61
|
end
|
|
43
62
|
end
|
|
@@ -41,7 +41,9 @@ module PaperTrailDiff
|
|
|
41
41
|
def recorded?: () -> bool
|
|
42
42
|
|
|
43
43
|
# Primary keys identify the record rather than describe it, as in a diff.
|
|
44
|
-
#
|
|
45
|
-
|
|
44
|
+
# Each side is read as a step's diff reads it (see StoredValues), so a
|
|
45
|
+
# value compares equal to the state the change produced.
|
|
46
|
+
# : (untyped, untyped, Array[String]) -> Hash[String, ValueChange]
|
|
47
|
+
def value_changes: (untyped, untyped, Array[String]) -> Hash[String, ValueChange]
|
|
46
48
|
end
|
|
47
49
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/recorded_changes_reader.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# Decodes what each version recorded at most once per request, and only when
|
|
5
|
+
# a boundary's changes are read. A version many roots share in a batch, such
|
|
6
|
+
# as an author's, is one decode however many steps name it, and a step the
|
|
7
|
+
# caller never reads costs none.
|
|
8
|
+
class RecordedChangesReader
|
|
9
|
+
# : (Array[String]) -> void
|
|
10
|
+
def initialize: (Array[String]) -> void
|
|
11
|
+
|
|
12
|
+
# What `version` recorded, as PaperTrailDiff.recorded_changes returns it.
|
|
13
|
+
# : (untyped) -> Hash[String, ValueChange]?
|
|
14
|
+
def call: (untyped) -> Hash[String, ValueChange]?
|
|
15
|
+
|
|
16
|
+
@changes: Hash[Array[untyped], Hash[String, ValueChange]?]
|
|
17
|
+
|
|
18
|
+
@ignore: Array[String]
|
|
19
|
+
|
|
20
|
+
@lock: Thread::Mutex
|
|
21
|
+
|
|
22
|
+
# One boundary's recorded changes, read when first asked for. It lets go of
|
|
23
|
+
# the version and the reader once read, so a result keeps only what was
|
|
24
|
+
# decoded, and not the decodes of the whole call.
|
|
25
|
+
class Pending
|
|
26
|
+
# : (RecordedChangesReader, untyped) -> void
|
|
27
|
+
def initialize: (RecordedChangesReader, untyped) -> void
|
|
28
|
+
|
|
29
|
+
# : () -> Hash[String, ValueChange]?
|
|
30
|
+
def value: () -> Hash[String, ValueChange]?
|
|
31
|
+
|
|
32
|
+
@lock: Thread::Mutex
|
|
33
|
+
|
|
34
|
+
@reader: RecordedChangesReader?
|
|
35
|
+
|
|
36
|
+
@value: Hash[String, ValueChange]?
|
|
37
|
+
|
|
38
|
+
@version: untyped
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -8,15 +8,16 @@ module PaperTrailDiff
|
|
|
8
8
|
# A version that stored neither stays on the base class.
|
|
9
9
|
module RecordedClass
|
|
10
10
|
# : (untyped) -> untyped
|
|
11
|
-
def self
|
|
11
|
+
def self.for: (untyped) -> untyped
|
|
12
|
+
|
|
13
|
+
# The class a version recorded, or a live record's own class.
|
|
14
|
+
# : (untyped) -> untyped
|
|
15
|
+
def self.of_endpoint: (untyped) -> untyped
|
|
12
16
|
|
|
13
17
|
# : (untyped) -> bool
|
|
14
|
-
def self
|
|
18
|
+
def self.sti_base?: (untyped) -> bool
|
|
15
19
|
|
|
16
20
|
# : (untyped, untyped) -> untyped
|
|
17
|
-
def self
|
|
18
|
-
|
|
19
|
-
# : (StandardError) -> bool
|
|
20
|
-
def self?.subclass_not_found?: (StandardError) -> bool
|
|
21
|
+
def self.stored_type: (untyped, untyped) -> untyped
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated from lib/paper_trail_diff/recorded_columns.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module PaperTrailDiff
|
|
4
|
+
# Whether PaperTrail writes a column's changes to `object_changes` whenever
|
|
5
|
+
# a version saves them. Only then does a version that left a column out of
|
|
6
|
+
# its recorded changes show that the column changed without a version.
|
|
7
|
+
#
|
|
8
|
+
# `has_paper_trail ignore:` and `skip:` leave a column out, and `only:`
|
|
9
|
+
# leaves out every column it does not name. Each can also name a column
|
|
10
|
+
# with a condition, read when the version was saved; such a column might
|
|
11
|
+
# have been left out, so it is not counted as recorded either.
|
|
12
|
+
module RecordedColumns
|
|
13
|
+
# : (untyped, String?) -> bool
|
|
14
|
+
def self.recorded?: (untyped, String?) -> bool
|
|
15
|
+
|
|
16
|
+
# PaperTrail keeps each entry as a name, or as a hash of names to
|
|
17
|
+
# conditions, which may be a subclass such as HashWithIndifferentAccess.
|
|
18
|
+
# : (Array[untyped], String?) -> bool
|
|
19
|
+
def self.named?: (Array[untyped], String?) -> bool
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -58,6 +58,11 @@ module PaperTrailDiff
|
|
|
58
58
|
# : () -> RootVersionPlan
|
|
59
59
|
def closing_on_destroy: () -> RootVersionPlan
|
|
60
60
|
|
|
61
|
+
# The same plan reporting only `selected` as mutations, of the versions it
|
|
62
|
+
# holds.
|
|
63
|
+
# : (Array[untyped]) -> RootVersionPlan
|
|
64
|
+
def reporting: (Array[untyped]) -> RootVersionPlan
|
|
65
|
+
|
|
61
66
|
# What the range's final state is read from, which is the live record when
|
|
62
67
|
# the window closes on current state and the last version otherwise.
|
|
63
68
|
# : () -> untyped
|
|
@@ -70,6 +75,9 @@ module PaperTrailDiff
|
|
|
70
75
|
|
|
71
76
|
@mutation_keys: Set[Array[untyped]]
|
|
72
77
|
|
|
78
|
+
# : (**untyped) -> RootVersionPlan
|
|
79
|
+
def copy: (**untyped) -> RootVersionPlan
|
|
80
|
+
|
|
73
81
|
# : () -> Array[untyped]
|
|
74
82
|
def default_mutations: () -> Array[untyped]
|
|
75
83
|
|
|
@@ -78,9 +86,5 @@ module PaperTrailDiff
|
|
|
78
86
|
# mutant:disable
|
|
79
87
|
# : (Array[untyped]) -> Set[Array[untyped]]
|
|
80
88
|
def key_set: (Array[untyped]) -> Set[Array[untyped]]
|
|
81
|
-
|
|
82
|
-
# By class name, so a version still matches after its class is reloaded.
|
|
83
|
-
# : (untyped) -> Array[untyped]
|
|
84
|
-
def key: (untyped) -> Array[untyped]
|
|
85
89
|
end
|
|
86
90
|
end
|
|
@@ -8,7 +8,9 @@ module PaperTrailDiff
|
|
|
8
8
|
# a filter must never remove it.
|
|
9
9
|
#
|
|
10
10
|
# Both the single-record and the batched selectors resolve this here, because
|
|
11
|
-
# the rule is subtle enough that two copies of it would drift apart.
|
|
11
|
+
# the rule is subtle enough that two copies of it would drift apart. Their
|
|
12
|
+
# versions are put in order here too, which refuses a sequence that cannot
|
|
13
|
+
# be ordered (see Support.chronological_sort) whichever selector read it.
|
|
12
14
|
class RootVersionSelection
|
|
13
15
|
# An error is a specification, so it names the way out as well as the wall.
|
|
14
16
|
# A window ending at the present can never gain a later version, which makes
|
|
@@ -17,8 +19,13 @@ module PaperTrailDiff
|
|
|
17
19
|
# this is raised only when there is none to read.
|
|
18
20
|
INCOMPLETE: ::String
|
|
19
21
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
+
# `selected` is what a filter keeps of `in_range`; one that keeps every
|
|
23
|
+
# version is no filter. Activity on associations reports the changes a
|
|
24
|
+
# filter keeps on them wherever they fall in the range, so a `whole` plan
|
|
25
|
+
# replays every root version there, as one without a filter does, and the
|
|
26
|
+
# filter names only which of them are the root's own mutations.
|
|
27
|
+
# : (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?live_endpoint: untyped, ?whole: bool) -> void
|
|
28
|
+
def initialize: (in_range: Array[untyped], selected: Array[untyped], after_range: untyped, windowed: bool, ?context_required: bool, ?live_endpoint: untyped, ?whole: bool) -> void
|
|
22
29
|
|
|
23
30
|
# : () -> RootVersionPlan
|
|
24
31
|
def call: () -> RootVersionPlan
|
|
@@ -35,6 +42,8 @@ module PaperTrailDiff
|
|
|
35
42
|
|
|
36
43
|
@live_endpoint: untyped
|
|
37
44
|
|
|
45
|
+
@reported: Array[untyped]
|
|
46
|
+
|
|
38
47
|
@selected: Array[untyped]
|
|
39
48
|
|
|
40
49
|
@windowed: bool
|
|
@@ -59,6 +68,7 @@ module PaperTrailDiff
|
|
|
59
68
|
# : (untyped) -> RootVersionPlan
|
|
60
69
|
def filtered_plan: (untyped) -> RootVersionPlan
|
|
61
70
|
|
|
71
|
+
# The steps run in order, and so do the versions they pass.
|
|
62
72
|
# : (Array[[untyped, untyped]], untyped) -> RootVersionPlan
|
|
63
73
|
def filtered_plan_for: (Array[[ untyped, untyped ]], untyped) -> RootVersionPlan
|
|
64
74
|
|
|
@@ -69,16 +79,20 @@ module PaperTrailDiff
|
|
|
69
79
|
# : () -> Array[untyped]
|
|
70
80
|
def closing_versions: () -> Array[untyped]
|
|
71
81
|
|
|
72
|
-
# Everything the span passes through, filtered out or not
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
#
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
# Everything the span passes through, filtered out or not, through the
|
|
83
|
+
# version that reveals the last selected mutation, which can lie after the
|
|
84
|
+
# range. A replay that skipped the excluded versions would carry a stale
|
|
85
|
+
# state into the next reported step, so the two selected mutations either
|
|
86
|
+
# side of a gap would disagree about what the record looked like between
|
|
87
|
+
# them. One that stopped before the revealing version would read what the
|
|
88
|
+
# last one produced from history that ends before it. Only the version
|
|
89
|
+
# that reveals the last can lie outside the range, and it comes after it.
|
|
90
|
+
# With no versions there is no span, and a plan replays its versions.
|
|
91
|
+
# : (Array[untyped]) -> Array[untyped]?
|
|
92
|
+
def spanned: (Array[untyped]) -> Array[untyped]?
|
|
93
|
+
|
|
94
|
+
# The versions in range are in order, so the first one after a version is
|
|
95
|
+
# found by a search rather than by passing every version before it.
|
|
82
96
|
# : (untyped) -> untyped
|
|
83
97
|
def immediate_successor: (untyped) -> untyped
|
|
84
98
|
|
|
@@ -26,8 +26,6 @@ module PaperTrailDiff
|
|
|
26
26
|
|
|
27
27
|
BIND_PARAM: ::String
|
|
28
28
|
|
|
29
|
-
ATTRIBUTE: ::String
|
|
30
|
-
|
|
31
29
|
# Adapters that compare strings exactly by default. MySQL and SQL Server
|
|
32
30
|
# ignore case and trailing spaces by default, which Ruby cannot follow.
|
|
33
31
|
EXACT_TEXT_ADAPTERS: untyped
|
|
@@ -54,11 +54,6 @@ module PaperTrailDiff
|
|
|
54
54
|
# : (untyped) -> bool
|
|
55
55
|
def self.own?: (untyped) -> bool
|
|
56
56
|
|
|
57
|
-
# Active Record casts a limit to an integer but keeps an offset as given,
|
|
58
|
-
# which may be a String or SQL.
|
|
59
|
-
# : (untyped) -> bool
|
|
60
|
-
def self.plain_offset?: (untyped) -> bool
|
|
61
|
-
|
|
62
57
|
# The order's keys up to the primary key, which makes it total. Keys
|
|
63
58
|
# after it never decide anything.
|
|
64
59
|
# : (Array[untyped], untyped) -> Array[[String, bool]]?
|
|
@@ -68,8 +63,13 @@ module PaperTrailDiff
|
|
|
68
63
|
# : (untyped, untyped) -> String?
|
|
69
64
|
def self.column: (untyped, untyped) -> String?
|
|
70
65
|
|
|
71
|
-
#
|
|
72
|
-
|
|
66
|
+
# The name an Arel attribute gives a column of the model's own table, not
|
|
67
|
+
# of another table or an alias of its own; nil for anything else.
|
|
68
|
+
# : (untyped, untyped) -> String?
|
|
69
|
+
def self.own_column: (untyped, untyped) -> String?
|
|
70
|
+
|
|
71
|
+
# : (untyped, String?) -> bool
|
|
72
|
+
def self.orderable?: (untyped, String?) -> bool
|
|
73
73
|
|
|
74
74
|
# The value the database sorts by, as the column's type casts it. An enum
|
|
75
75
|
# sorts by the integer it stores; other types are compared cast, since an
|
|
@@ -88,8 +88,8 @@ module PaperTrailDiff
|
|
|
88
88
|
# : (untyped, untyped) -> bool
|
|
89
89
|
def self.exact_time?: (untyped, untyped) -> bool
|
|
90
90
|
|
|
91
|
-
# : (untyped, Array[[String, bool]], bool, Integer?, Integer
|
|
92
|
-
def initialize: (untyped, Array[[ String, bool ]], bool, Integer?, Integer
|
|
91
|
+
# : (untyped, Array[[String, bool]], bool, Integer?, Integer) -> void
|
|
92
|
+
def initialize: (untyped, Array[[ String, bool ]], bool, Integer?, Integer) -> void
|
|
93
93
|
|
|
94
94
|
# The members among records that met the scope's conditions, in order.
|
|
95
95
|
# : (Array[untyped]) -> Array[untyped]
|
|
@@ -105,7 +105,7 @@ module PaperTrailDiff
|
|
|
105
105
|
|
|
106
106
|
@nulls_last: bool
|
|
107
107
|
|
|
108
|
-
@offset: Integer
|
|
108
|
+
@offset: Integer
|
|
109
109
|
|
|
110
110
|
# Keys compare in turn, and the primary key always decides. A descending
|
|
111
111
|
# key negates its places, which also moves NULL to the other end, as each
|