Skip to content

Commit

Permalink
[web] Fix Includefield handling
Browse files Browse the repository at this point in the history
  • Loading branch information
feliwir committed Jan 16, 2025
1 parent 76a743e commit f091018
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/src/qido.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct QidoRequest {

limit: Option<u32>,
offset: Option<u32>,
includefields: Option<String>,
includefields: Vec<Tag>,
fuzzymatching: Option<bool>,
filters: Vec<(Tag, String)>,
}
Expand All @@ -25,7 +25,7 @@ impl QidoRequest {
url,
limit: None,
offset: None,
includefields: None,
includefields: vec![],
fuzzymatching: None,
filters: vec![],
}
Expand All @@ -39,8 +39,15 @@ impl QidoRequest {
if let Some(offset) = self.offset {
query.push((String::from("offset"), offset.to_string()));
}
if let Some(includefields) = &self.includefields {
query.push((String::from("includefields"), includefields.to_string()));
for include_field in self.includefields.iter() {
// Convert the tag to a radix string
let radix_string = format!(
"{:04x}{:04x}",
include_field.group(),
include_field.element()
);

query.push((String::from("includefield"), radix_string));
}
for filter in self.filters.iter() {
query.push((filter.0.to_string(), filter.1.clone()));
Expand Down Expand Up @@ -103,14 +110,7 @@ impl QidoRequest {
}

pub fn with_includefields(self: &mut Self, includefields: Vec<Tag>) -> &mut Self {

Check failure on line 112 in web/src/qido.rs

View workflow job for this annotation

GitHub Actions / Test (default) (stable)

the type of the `self` parameter does not need to be arbitrary
self.includefields = Some(
includefields
.iter()
.map(|tag| tag.to_string())
.collect::<Vec<String>>()
.join(","),
);

self.includefields = includefields;
self
}

Expand Down

0 comments on commit f091018

Please sign in to comment.