patchwork_csv_utils 0.1.24-arm64-darwin → 0.1.25-arm64-darwin
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/Gemfile.lock +1 -1
- data/ext/csv_utils/src/utils/shared/filters.rs +70 -2
- data/lib/csv_utils/2.7/csv_utils.bundle +0 -0
- data/lib/csv_utils/3.0/csv_utils.bundle +0 -0
- data/lib/csv_utils/3.1/csv_utils.bundle +0 -0
- data/lib/csv_utils/3.2/csv_utils.bundle +0 -0
- data/lib/csv_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73651fcf0c950deeb381336f8ebe5677fc584bbbebe796992835afa689272b69
|
|
4
|
+
data.tar.gz: 6c4056a66f3154ed839aa3e8c864e49368bec0d970b9b2597757f3e38ce94ea6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb66ac70a22fd5dd4168ad1ee23d67faf8c50f23ac65a683cc315dfa0b69d9d8b0bf89af543c302bb190a2ed6b68dcf9d262f34aba77a2f9901caed5afc0230f
|
|
7
|
+
data.tar.gz: 150b602ad74dd3334b3a7dc699b39234255c09a874be3a4f3eadeee385a6cad36a092ba36a584bf79c0e1382c74ef23ad27e1a7351def1c3004da9ab09fccbba
|
data/Gemfile.lock
CHANGED
|
@@ -16,6 +16,17 @@ pub struct RowFilters {
|
|
|
16
16
|
earliest_start_date: Option<NaiveDateTime>,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
// Mirror Patchwork-on-Rails' Allocate::ExternalShiftInput#pad_request_id
|
|
20
|
+
// (gsub(/[^0-9a-zA-Z]/, '') then rjust(10, '0')). The exclusion set is built
|
|
21
|
+
// from Patchwork's cleaned external_ids, but Request Ids in BankStaff/Optima
|
|
22
|
+
// sheets can carry a leading apostrophe (CSV text marker) or drop a leading
|
|
23
|
+
// zero (Excel numeric cell). Normalising both sides identically keeps the
|
|
24
|
+
// exclusion match aligned with how Rails stored the id.
|
|
25
|
+
fn normalise_request_id(id: &str) -> String {
|
|
26
|
+
let cleaned: String = id.chars().filter(|c| c.is_ascii_alphanumeric()).collect();
|
|
27
|
+
format!("{cleaned:0>10}")
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
impl RowFilters {
|
|
20
31
|
pub fn new(
|
|
21
32
|
exclusions: Vec<String>,
|
|
@@ -23,7 +34,10 @@ impl RowFilters {
|
|
|
23
34
|
earliest_start_date: Option<NaiveDateTime>,
|
|
24
35
|
) -> Self {
|
|
25
36
|
RowFilters {
|
|
26
|
-
exclusions
|
|
37
|
+
exclusions: exclusions
|
|
38
|
+
.iter()
|
|
39
|
+
.map(|id| normalise_request_id(id))
|
|
40
|
+
.collect(),
|
|
27
41
|
status_exclusions,
|
|
28
42
|
earliest_start_date,
|
|
29
43
|
}
|
|
@@ -57,7 +71,7 @@ impl RowFilters {
|
|
|
57
71
|
|
|
58
72
|
record
|
|
59
73
|
.get_request_id(request_id_index)
|
|
60
|
-
.map(|id| self.exclusions.contains(&id))
|
|
74
|
+
.map(|id| self.exclusions.contains(&normalise_request_id(&id)))
|
|
61
75
|
.unwrap_or(false)
|
|
62
76
|
}
|
|
63
77
|
|
|
@@ -128,3 +142,57 @@ impl FilterableRecord for Vec<&Data> {
|
|
|
128
142
|
})
|
|
129
143
|
}
|
|
130
144
|
}
|
|
145
|
+
|
|
146
|
+
#[cfg(test)]
|
|
147
|
+
mod tests {
|
|
148
|
+
use super::*;
|
|
149
|
+
use csv::StringRecord;
|
|
150
|
+
|
|
151
|
+
fn row(cells: &[&str]) -> StringRecord {
|
|
152
|
+
StringRecord::from(cells.to_vec())
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fn excluding(id: &str) -> RowFilters {
|
|
156
|
+
RowFilters::new(vec![id.to_string()], vec![], None)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn skips_exclusion(filters: &RowFilters, request_id: &str) -> bool {
|
|
160
|
+
filters.should_skip(
|
|
161
|
+
&row(&[request_id, "UnFilled Bank", "2026-07-30 00:00:00"]),
|
|
162
|
+
0,
|
|
163
|
+
Some(1),
|
|
164
|
+
2,
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#[test]
|
|
169
|
+
fn excludes_apostrophe_prefixed_request_id_against_clean_exclusion() {
|
|
170
|
+
assert!(skips_exclusion(&excluding("0726154700"), "'0726154700"));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#[test]
|
|
174
|
+
fn excludes_request_id_with_dropped_leading_zero() {
|
|
175
|
+
assert!(skips_exclusion(&excluding("0726154700"), "726154700"));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#[test]
|
|
179
|
+
fn normalises_dirty_exclusion_entries_too() {
|
|
180
|
+
assert!(skips_exclusion(&excluding("'0726154700"), "0726154700"));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#[test]
|
|
184
|
+
fn keeps_request_id_not_in_the_exclusion_set() {
|
|
185
|
+
assert!(!skips_exclusion(&excluding("0726154700"), "'0726154701"));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#[test]
|
|
189
|
+
fn recalled_rows_bypass_the_exclusion() {
|
|
190
|
+
let filters = excluding("0726154700");
|
|
191
|
+
assert!(!filters.should_skip(
|
|
192
|
+
&row(&["'0726154700", "Recalled", "2026-07-30 00:00:00"]),
|
|
193
|
+
0,
|
|
194
|
+
Some(1),
|
|
195
|
+
2
|
|
196
|
+
));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/csv_utils/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: patchwork_csv_utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.25
|
|
5
5
|
platform: arm64-darwin
|
|
6
6
|
authors:
|
|
7
7
|
- kingsley.hendrickse
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-07-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Deduplication of CSV files and XLS to CSV conversion.
|
|
14
14
|
email:
|