Skip to content

Commit

Permalink
Add SearchConfig, add test, update CLI (#81)
Browse files Browse the repository at this point in the history
Adds SearchConfig with `MatchType` (Exact, Regex, Contains, Startswith),
and `CaseSensitivity` (Insensitive or Sensitive), adds a test, and
incorporates into CLI with defaults for:
- `SearchText` when across all search contexts (regex)
- `MetricsId` (startswith, case insensitive)
  • Loading branch information
sgreenbury committed Sep 10, 2024
1 parent b0070d1 commit 116f277
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 61 deletions.
24 changes: 18 additions & 6 deletions popgetter/src/data_request_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};

use crate::geo::BBox;
use crate::search::{
DownloadParams, GeometryLevel, MetricId, Params, SearchContext, SearchParams, SearchText,
YearRange,
CaseSensitivity, DownloadParams, GeometryLevel, MatchType, MetricId, Params, SearchConfig,
SearchContext, SearchParams, SearchText, YearRange,
};

#[derive(Serialize, Deserialize, Clone, Debug, Default)]
Expand Down Expand Up @@ -36,6 +36,10 @@ impl TryFrom<DataRequestSpec> for Params {
SearchContext::Hxl,
SearchContext::Description
],
config: SearchConfig {
match_type: MatchType::Regex,
case_sensitivity: CaseSensitivity::Insensitive,
},
}),
_ => None,
})
Expand All @@ -57,10 +61,18 @@ impl TryFrom<DataRequestSpec> for Params {
_ => None,
})
.collect_vec(),
geometry_level: value
.geometry
.as_ref()
.and_then(|geometry| geometry.geometry_level.to_owned().map(GeometryLevel)),
geometry_level: value.geometry.as_ref().and_then(|geometry| {
geometry
.geometry_level
.to_owned()
.map(|geometry_level| GeometryLevel {
value: geometry_level,
config: SearchConfig {
match_type: MatchType::Exact,
case_sensitivity: CaseSensitivity::Insensitive,
},
})
}),
source_data_release: None,
data_publisher: None,
country: None,
Expand Down
Loading

0 comments on commit 116f277

Please sign in to comment.