Migrate #4

Merged
phoenix merged 14 commits from migrate into v1.x 2026-06-06 12:48:59 -04:00
Showing only changes of commit 9881b489f3 - Show all commits
+39 -32
View File
@@ -28,6 +28,43 @@ impl NumberParser {
println!("Total numbers: {:?}", numbers.len());
}
fn remove_dups(&self, contacts: &Vec<textsender_models::contact::Contact>) -> Vec<textsender_models::contact::Contact> {
let mut unique_contacts: Vec<textsender_models::contact::Contact> = Vec::new();
let mut unique_items = std::collections::HashSet::new();
for val in contacts {
unique_items.insert(val.phone_number.clone());
}
for unique_item in unique_items {
let contact = textsender_models::contact::Contact {
phone_number: unique_item,
..Default::default()
};
unique_contacts.push(contact);
}
unique_contacts
}
fn add_prefix(&self, raw: &String) -> String {
let mut parsed: String = String::new();
let first_char = raw.chars().nth(0).unwrap();
let second_char = raw.chars().nth(1).unwrap();
if first_char == '1' {
parsed = format!("+{raw}");
} else if first_char != '+' {
if second_char != '1' {
parsed = format!("+1{raw}");
} else {
parsed = format!("+1{raw}");
}
}
parsed
}
}
@@ -75,6 +112,7 @@ func (prsr *NumberParser) updateContacts(contacts []contact.Contact) []contact.C
return updated
}
func (prsr *NumberParser) removeDups(contacts []contact.Contact) []contact.Contact {
updated := []contact.Contact{}
uniqueItems := make(map[string]string)
@@ -90,18 +128,6 @@ func (prsr *NumberParser) removeDups(contacts []contact.Contact) []contact.Conta
return updated
}
func (prsr NumberParser) PrintValues(contacts []contact.Contact, printTotal bool) {
fmt.Println("Printing numbers")
for _, ct := range contacts {
fmt.Println("Number:", ct.PhoneNumber)
}
if printTotal {
fmt.Println("Total Numbers:", len(contacts))
}
}
func (prsr NumberParser) SaveFile(vals []contact.Contact) {
filename := "numbers.json"
@@ -162,24 +188,5 @@ func (prsr NumberParser) removeSomeData(unparsed string) string {
return parsed
}
func (prsr NumberParser) addPrefix(raw string) string {
parsed := raw
firstChar := raw[0]
secondChar := raw[1]
if firstChar == '1' {
parsed = "+" + parsed
} else if firstChar != '+' {
if secondChar != '1' {
parsed = "+1" + parsed
} else {
parsed = "+1" + parsed
}
}
return parsed
}
*/