patchwork_csv_utils 0.1.24-aarch64-linux → 0.1.25-aarch64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2a4f0279fe4f7e8bb2ac99679765184f8e0e532fbc16c1e10ead5cc64311ec4
4
- data.tar.gz: 765ece8e2414a957b04b0b29e8c83e58c8caaa41a5720796543a44702fb3bf73
3
+ metadata.gz: 428e2f4abd57105c275a4391288a71fabfc5cae964ba8c7b825027d71164b446
4
+ data.tar.gz: 7f717a0d5577da392d8f11a71e9117c65762b6da973314443378837c56acd97d
5
5
  SHA512:
6
- metadata.gz: c402279b8b631c2501a4f1be63eafc0ef41c0b7615291e78580365d43ef06649743d6d25d25f24d266a601ff880c9ec3ab25d8bb135fa3d422a8155100d96a34
7
- data.tar.gz: 33f0926fbd5e8418c6941f65e3d6ea27438602b7adbe61cc923cc601e0ed089a6ba522e0acb52d076d04b877db3a8213888e6a40f66d195989ae59ac8eb87928
6
+ metadata.gz: c9d64bc47d070017c3d5311cb1f0083ca82c6892f6ad644938fa38e3b8bb2e5571952a0c097b0069f15a1e25af6c3bb9e7f08e821763633e382682a741a16fe3
7
+ data.tar.gz: 0ef2e4c2597e023d8fa85dc6100a1672e54f6250840e668b997c946852cbbb5bec5a7c951cb798f05ba345b7dee97b2d8172681708790a3d1a3215141d414e26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patchwork_csv_utils (0.1.24)
4
+ patchwork_csv_utils (0.1.25)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CsvUtils
4
- VERSION = '0.1.24'
4
+ VERSION = '0.1.25'
5
5
  end
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.24
4
+ version: 0.1.25
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - kingsley.hendrickse
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-14 00:00:00.000000000 Z
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: