Updating name
This commit is contained in:
Generated
+1012
-219
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -10,7 +10,7 @@ tokio = { version = "1.52.3", features = ["full"] }
|
|||||||
futures = { version = "0.3.32" }
|
futures = { version = "0.3.32" }
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.150" }
|
serde_json = { version = "1.0.150" }
|
||||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.4.0", features = ["contact"] }
|
schedtxt_models = { git = "ssh://git@git.kundeng.us/phoenix/schedtxt_models.git", tag = "v0.5.3", features = ["contact"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.27.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
|
|||||||
+14
-18
@@ -11,9 +11,9 @@ pub struct NumberParser {
|
|||||||
impl NumberParser {
|
impl NumberParser {
|
||||||
pub async fn file_dump(
|
pub async fn file_dump(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<Vec<textsender_models::contact::Contact>, std::io::Error> {
|
) -> Result<Vec<schedtxt_models::contact::Contact>, std::io::Error> {
|
||||||
println!("Dumping files");
|
println!("Dumping files");
|
||||||
let mut objs: Vec<textsender_models::contact::Contact> = Vec::new();
|
let mut objs: Vec<schedtxt_models::contact::Contact> = Vec::new();
|
||||||
|
|
||||||
match self.read_lines(&self.filepath).await {
|
match self.read_lines(&self.filepath).await {
|
||||||
Ok(lines) => {
|
Ok(lines) => {
|
||||||
@@ -22,7 +22,7 @@ impl NumberParser {
|
|||||||
if contains_letters {
|
if contains_letters {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
let my_obj = textsender_models::contact::Contact {
|
let my_obj = schedtxt_models::contact::Contact {
|
||||||
phone_number: line.clone(),
|
phone_number: line.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -41,11 +41,7 @@ impl NumberParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn save_file(
|
pub async fn save_file(&self, numbers: Vec<schedtxt_models::contact::Contact>, filename: &str) {
|
||||||
&self,
|
|
||||||
numbers: Vec<textsender_models::contact::Contact>,
|
|
||||||
filename: &str,
|
|
||||||
) {
|
|
||||||
match serde_json::to_string(&numbers) {
|
match serde_json::to_string(&numbers) {
|
||||||
Ok(json_string) => match std::fs::write(filename, json_string) {
|
Ok(json_string) => match std::fs::write(filename, json_string) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -61,7 +57,7 @@ impl NumberParser {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_phone_numbers(&self, contacts: &Vec<textsender_models::contact::Contact>) {
|
pub fn print_phone_numbers(&self, contacts: &Vec<schedtxt_models::contact::Contact>) {
|
||||||
println!("Printing phone numbers");
|
println!("Printing phone numbers");
|
||||||
|
|
||||||
for contact in contacts {
|
for contact in contacts {
|
||||||
@@ -83,9 +79,9 @@ impl NumberParser {
|
|||||||
|
|
||||||
async fn remove_dups(
|
async fn remove_dups(
|
||||||
&self,
|
&self,
|
||||||
contacts: &Vec<textsender_models::contact::Contact>,
|
contacts: &Vec<schedtxt_models::contact::Contact>,
|
||||||
) -> Vec<textsender_models::contact::Contact> {
|
) -> Vec<schedtxt_models::contact::Contact> {
|
||||||
let mut unique_contacts: Vec<textsender_models::contact::Contact> = Vec::new();
|
let mut unique_contacts: Vec<schedtxt_models::contact::Contact> = Vec::new();
|
||||||
let mut unique_items = std::collections::HashSet::new();
|
let mut unique_items = std::collections::HashSet::new();
|
||||||
|
|
||||||
for val in contacts {
|
for val in contacts {
|
||||||
@@ -93,7 +89,7 @@ impl NumberParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for unique_item in unique_items {
|
for unique_item in unique_items {
|
||||||
let contact = textsender_models::contact::Contact {
|
let contact = schedtxt_models::contact::Contact {
|
||||||
phone_number: unique_item,
|
phone_number: unique_item,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -105,9 +101,9 @@ impl NumberParser {
|
|||||||
|
|
||||||
async fn update_contacts(
|
async fn update_contacts(
|
||||||
&self,
|
&self,
|
||||||
contacts: &Vec<textsender_models::contact::Contact>,
|
contacts: &Vec<schedtxt_models::contact::Contact>,
|
||||||
) -> Vec<textsender_models::contact::Contact> {
|
) -> Vec<schedtxt_models::contact::Contact> {
|
||||||
let mut updated: Vec<textsender_models::contact::Contact> = Vec::new();
|
let mut updated: Vec<schedtxt_models::contact::Contact> = Vec::new();
|
||||||
|
|
||||||
for ct in contacts {
|
for ct in contacts {
|
||||||
let phone_number = ct.phone_number.clone();
|
let phone_number = ct.phone_number.clone();
|
||||||
@@ -120,7 +116,7 @@ impl NumberParser {
|
|||||||
|
|
||||||
match self.add_prefix(&pars) {
|
match self.add_prefix(&pars) {
|
||||||
Ok(updated_parsed) => {
|
Ok(updated_parsed) => {
|
||||||
let contact = textsender_models::contact::Contact {
|
let contact = schedtxt_models::contact::Contact {
|
||||||
phone_number: updated_parsed,
|
phone_number: updated_parsed,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -172,7 +168,7 @@ impl NumberParser {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use textsender_models::contact::Contact;
|
use schedtxt_models::contact::Contact;
|
||||||
|
|
||||||
const TEST_NUMBERS_0: &str = "tests/numbers-0.txt";
|
const TEST_NUMBERS_0: &str = "tests/numbers-0.txt";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user