Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
collect streaming servers only if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
segler-alex committed Oct 11, 2021
1 parent 753bf31 commit a370d4f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* CHECK: update stations with new languagecodes
* DB: check for empty lists in streaming servers api
* DB: collect streaming servers only if enabled

## [0.7.18] 2021-10-10
### Changed
Expand Down
31 changes: 17 additions & 14 deletions src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub fn dbcheck(
timeout: u64,
max_depth: u8,
retries: u8,
add_streaming_servers: bool,
) -> Result<usize, Box<dyn std::error::Error>> {
let mut conn = connect(connection_str)?;
let stations = conn.get_stations_to_check(24, stations_count)?;
Expand Down Expand Up @@ -269,22 +270,24 @@ pub fn dbcheck(
conn.insert_station_check_steps(&steps)?;
conn.update_station_with_check_data(&inserted, true)?;

let mut urls_full: Vec<_> = inserted.iter()
.filter_map(|station| Url::parse(&station.url).ok())
.map(|mut url| {
url.set_path("/");
url.set_query(None);
url.set_fragment(None);
url.to_string()
})
.collect();
if add_streaming_servers {
let mut urls_full: Vec<_> = inserted.iter()
.filter_map(|station| Url::parse(&station.url).ok())
.map(|mut url| {
url.set_path("/");
url.set_query(None);
url.set_fragment(None);
url.to_string()
})
.collect();

urls_full.sort();
urls_full.dedup();
urls_full.sort();
urls_full.dedup();

conn.insert_streaming_servers(urls_full.drain(..).map(|base_url|{
DbStreamingServerNew::new(base_url, None, None, None)
}).collect())?;
conn.insert_streaming_servers(urls_full.drain(..).map(|base_url|{
DbStreamingServerNew::new(base_url, None, None, None)
}).collect())?;
}

Ok(checked_count)
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn jobs(config: config::Config) {
config.tcp_timeout.as_secs(),
config.max_depth,
config.retries,
config.check_servers,
);
match result {
Ok(_) => {}
Expand Down

0 comments on commit a370d4f

Please sign in to comment.