swh_graph/views/spy/
timestamps.rs1use super::*;
9use properties::{OptTimestamps, PropertiesBackend, PropertiesResult};
10
11impl<
12 G: SwhGraphWithProperties<Timestamps: OptTimestamps>,
13 MAPS: properties::MaybeMaps,
14 PERSONS: properties::MaybePersons,
15 CONTENTS: properties::MaybeContents,
16 STRINGS: properties::MaybeStrings,
17 LABELNAMES: properties::MaybeLabelNames,
18 > GraphSpy<G, MAPS, properties::NoTimestamps, PERSONS, CONTENTS, STRINGS, LABELNAMES>
19{
20 pub fn with_timestamps(
21 self,
22 ) -> GraphSpy<G, MAPS, TimestampsSpy<G>, PERSONS, CONTENTS, STRINGS, LABELNAMES> {
23 let GraphSpy {
24 properties:
25 properties::SwhGraphProperties {
26 path,
27 num_nodes,
28 maps,
29 timestamps: properties::NoTimestamps,
30 persons,
31 contents,
32 strings,
33 label_names,
34 label_names_are_in_base64_order,
35 },
36 inner,
37 history,
38 } = self;
39
40 GraphSpy {
41 properties: properties::SwhGraphProperties {
42 path,
43 num_nodes,
44 maps,
45 timestamps: TimestampsSpy {
46 graph: Arc::clone(&inner),
47 history: Arc::clone(&history),
48 },
49 persons,
50 contents,
51 strings,
52 label_names,
53 label_names_are_in_base64_order,
54 },
55 inner,
56 history,
57 }
58 }
59}
60
61pub struct TimestampsSpy<G: SwhGraphWithProperties<Timestamps: OptTimestamps>> {
62 graph: Arc<GraphSpyInner<G>>,
63 history: Arc<Mutex<Vec<GraphAccessRecord>>>,
64}
65
66impl<G: SwhGraphWithProperties<Timestamps: OptTimestamps>> PropertiesBackend for TimestampsSpy<G> {
67 type DataFilesAvailability =
68 <<G as SwhGraphWithProperties>::Timestamps as PropertiesBackend>::DataFilesAvailability;
69}
70
71impl<G: SwhGraphWithProperties<Timestamps: OptTimestamps>> OptTimestamps for TimestampsSpy<G> {
72 fn author_timestamp(&self, node: NodeId) -> PropertiesResult<'_, Option<i64>, Self> {
73 self.history
74 .lock()
75 .unwrap()
76 .push(GraphAccessRecord::Property(
77 PropertyAccess::AuthorTimestamp(node),
78 ));
79 self.graph
80 .graph
81 .properties()
82 .timestamps
83 .author_timestamp(node)
84 }
85
86 fn author_timestamp_offset(&self, node: NodeId) -> PropertiesResult<'_, Option<i16>, Self> {
87 self.history
88 .lock()
89 .unwrap()
90 .push(GraphAccessRecord::Property(
91 PropertyAccess::AuthorTimestampOffset(node),
92 ));
93 self.graph
94 .graph
95 .properties()
96 .timestamps
97 .author_timestamp_offset(node)
98 }
99
100 fn committer_timestamp(&self, node: NodeId) -> PropertiesResult<'_, Option<i64>, Self> {
101 self.history
102 .lock()
103 .unwrap()
104 .push(GraphAccessRecord::Property(
105 PropertyAccess::CommitterTimestamp(node),
106 ));
107 self.graph
108 .graph
109 .properties()
110 .timestamps
111 .committer_timestamp(node)
112 }
113
114 fn committer_timestamp_offset(&self, node: NodeId) -> PropertiesResult<'_, Option<i16>, Self> {
115 self.history
116 .lock()
117 .unwrap()
118 .push(GraphAccessRecord::Property(
119 PropertyAccess::CommitterTimestampOffset(node),
120 ));
121 self.graph
122 .graph
123 .properties()
124 .timestamps
125 .committer_timestamp_offset(node)
126 }
127}