diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e75de99..2df37ec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,4 +34,4 @@ jobs: with: files: target/x86_64-unknown-linux-musl/release/* tag_name: v1.0.0 - release_name: Release v1.0.0 + release_name: Release v1.1.0 diff --git a/src/history_processing.rs b/src/history_processing.rs index bdcdcf8..fcabca7 100644 --- a/src/history_processing.rs +++ b/src/history_processing.rs @@ -10,7 +10,7 @@ pub fn process_history( tag_list: HashSet<&str>, ) -> HashMap { let mut elements_info: HashMap = HashMap::new(); - // + let reader_result = ElementReader::from_path(history_file_path); let reader = match reader_result { diff --git a/src/load_infos.rs b/src/load_infos.rs index 5db187a..cdbff56 100644 --- a/src/load_infos.rs +++ b/src/load_infos.rs @@ -32,15 +32,15 @@ pub fn load( for (key, value) in nodes_info.iter() { let mut row: Vec<&(dyn ToSql + Sync)> = Vec::new(); - let first_timestamp = value.timestamps.iter().min().unwrap(); - let last_timestamp = value.timestamps.iter().max().unwrap(); + let first_update = value.timestamps.iter().min().unwrap(); + let last_update = value.timestamps.iter().max().unwrap(); let users_number = value.uids.iter().unique().count() as i64; let versions_number = value.timestamps.len() as i64; row.push(key); row.push(&value.timestamps); row.push(&value.changesets); - row.push(first_timestamp); - row.push(last_timestamp); + row.push(first_update); + row.push(last_update); row.push(&users_number); row.push(&versions_number); writer.write(&row).unwrap(); diff --git a/src/main.rs b/src/main.rs index 3b023cf..03dfe32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ use std::collections::HashSet; use std::env; +use std::fs::File; +use std::io::{self, BufRead}; +use std::path::Path; use std::time::Instant; mod history_processing; @@ -7,10 +10,6 @@ mod infos; mod load_infos; mod postgres_client; -use std::fs::File; -use std::io::{self, BufRead}; -use std::path::Path; - const SCHEMA: &str = "OSM"; const TABLE: &str = "HISTORY"; @@ -34,12 +33,22 @@ fn main() { } } + // Read tag_list file and store tags into an Hashset (ignore values after the equal signs) let file = File::open(tag_list_file_path).expect("Failed to open tag list file."); let reader = io::BufReader::new(file); let mut tag_list_string: Vec = Vec::new(); for line in reader.lines() { - let line = line.unwrap_or("".parse().unwrap()); - tag_list_string.push(line); + let final_line = match line { + Ok(line) => { + if let Some(index) = line.find('=') { + line[..index].to_owned() + } else { + line.to_owned() + } + } + Err(_) => String::new(), + }; + tag_list_string.push(final_line); } let tag_list: HashSet<&str> = tag_list_string.iter().map(|s| s.as_str()).collect(); diff --git a/src/postgres_client.rs b/src/postgres_client.rs index 0bd5837..a27d025 100644 --- a/src/postgres_client.rs +++ b/src/postgres_client.rs @@ -51,8 +51,8 @@ pub fn create_table_history(client: &mut Client, schema: &str, table: &str) { id int8, timestamps TIMESTAMP WITH TIME ZONE[], changesets int8[], - first_timestamps TIMESTAMP WITH TIME ZONE, - last_timestamps TIMESTAMP WITH TIME ZONE, + first_update TIMESTAMP WITH TIME ZONE, + last_update TIMESTAMP WITH TIME ZONE, users_number int8, versions_number int8)", schema, table