Search options are expected to be in an array now instead of top level

definitions when searching.
This commit is contained in:
Sebastian Hugentobler 2024-10-01 13:59:50 +02:00
parent ac740c76b6
commit d7c865663b
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
6 changed files with 15 additions and 10 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ node_modules
/target
nzz/
result
.direnv/

2
Cargo.lock generated
View File

@ -921,7 +921,7 @@ dependencies = [
[[package]]
name = "nzz-download"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"anyhow",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "nzz-download"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = { workspace = true }
authors = { workspace = true }

View File

@ -12,15 +12,17 @@ const SEARCH_URL: &str = "https://zeitungsarchiv.nzz.ch/solr-epaper-search/1.0/s
const ISSUE_URL: &str = "https://zeitungsarchiv.nzz.ch/archive/1.0/getPages";
const MAX_DOWNLOADS: usize = 4;
#[derive(Debug, Serialize, Deserialize)]
struct SortOption {
field: String,
order: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct SearchData {
query: String,
offset: u32,
#[serde(rename = "sortField")]
sort_field: String,
#[serde(rename = "sortOrder")]
sort_order: String,
#[serde(
#[serde(
rename = "startDate",
serialize_with = "crate::date::serialize",
deserialize_with = "crate::date::deserialize"
@ -32,6 +34,8 @@ struct SearchData {
deserialize_with = "crate::date::deserialize"
)]
end_date: Date,
#[serde(rename = "sortOptions")]
sort_options: Vec<SortOption>
}
#[derive(Debug, Serialize, Deserialize)]
@ -105,8 +109,7 @@ impl SearchData {
Self {
query: "".to_string(),
offset,
sort_field: "media_ts".to_string(),
sort_order: "desc".to_string(),
sort_options: vec![SortOption { field: "media_ts".to_string(), order: "desc".to_string() }],
start_date,
end_date,
}

View File

@ -21,7 +21,7 @@
fenixPkgs:
fenixPkgs.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-Ngiz76YP4HTY75GGdH2P+APE/DEIx2R/Dn+BwwOyzZU=";
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
};
buildTargets = {