Moaaarrr
All checks were successful
Cargo Build & Test / Rust project - latest (1.86) (push) Successful in 4m26s
Cargo Build & Test / Rust project - latest (1.87) (push) Successful in 4m42s
Cargo Build & Test / Rust project - latest (1.85.1) (push) Successful in 5m15s
Cargo Build & Test / Rust project - latest (1.88) (push) Successful in 11m40s
All checks were successful
Cargo Build & Test / Rust project - latest (1.86) (push) Successful in 4m26s
Cargo Build & Test / Rust project - latest (1.87) (push) Successful in 4m42s
Cargo Build & Test / Rust project - latest (1.85.1) (push) Successful in 5m15s
Cargo Build & Test / Rust project - latest (1.88) (push) Successful in 11m40s
This commit is contained in:
@@ -32,7 +32,7 @@ pub fn parse_size_and_quantity(item_id: i64, title: &str) -> ParsedStorage {
|
||||
let upper_title = title.to_uppercase();
|
||||
let mut total_gb = 0i64;
|
||||
let mut quantity = 1i64;
|
||||
let mut needed_description_check = false;
|
||||
let mut failed_reason = String::new();
|
||||
let mut individual_size_gb = 0i64;
|
||||
|
||||
for pattern in EXPLICIT_QTY_PATTERNS.iter() {
|
||||
@@ -68,36 +68,35 @@ pub fn parse_size_and_quantity(item_id: i64, title: &str) -> ParsedStorage {
|
||||
if !unique_sizes_gb.is_empty() {
|
||||
individual_size_gb = unique_sizes_gb[0];
|
||||
if unique_sizes_gb.len() > 1 {
|
||||
needed_description_check = true;
|
||||
failed_reason = "Mixed Sizes".to_owned();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if SIZE_RANGE_REGEX.is_match(&upper_title) {
|
||||
needed_description_check = true;
|
||||
failed_reason = "No Size Given".to_owned();
|
||||
}
|
||||
if quantity > 1 && upper_title.contains("MIXED") {
|
||||
needed_description_check = true;
|
||||
failed_reason = "Mixed Sizes".to_owned();
|
||||
}
|
||||
if upper_title.contains("CHECK THE DESCRIPTION")
|
||||
|| upper_title.contains("CHECK DESCRIPTION")
|
||||
|| upper_title.contains("SEE DESCRIPTION")
|
||||
{
|
||||
if quantity > 1 || size_matches.is_empty() || size_matches.len() > 1 {
|
||||
needed_description_check = true;
|
||||
failed_reason = "Mixed Sizes".to_owned();
|
||||
}
|
||||
}
|
||||
if upper_title.contains("READ") {
|
||||
failed_reason = "Mixed Sizes".to_owned();
|
||||
}
|
||||
|
||||
if individual_size_gb > 0 {
|
||||
total_gb = individual_size_gb * quantity;
|
||||
}
|
||||
|
||||
if quantity > 1 && total_gb == 0 && !size_matches.is_empty() {
|
||||
needed_description_check = true;
|
||||
}
|
||||
|
||||
if quantity == 1 && size_matches.len() == 1 && !needed_description_check {
|
||||
// This condition is implicitly handled
|
||||
failed_reason = "No size given".to_owned();
|
||||
}
|
||||
|
||||
ParsedStorage {
|
||||
@@ -106,8 +105,8 @@ pub fn parse_size_and_quantity(item_id: i64, title: &str) -> ParsedStorage {
|
||||
total_gigabytes: total_gb,
|
||||
quantity,
|
||||
individual_size_gigabytes: individual_size_gb,
|
||||
needed_description_check,
|
||||
parse_engine: 0,
|
||||
failed_reason: failed_reason,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +124,8 @@ mod tests {
|
||||
total_gigabytes: 512 * 3,
|
||||
quantity: 3,
|
||||
individual_size_gigabytes: 512,
|
||||
parse_engine: 0,
|
||||
needed_description_check: false,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
true,
|
||||
),
|
||||
@@ -138,8 +137,8 @@ mod tests {
|
||||
total_gigabytes: 240,
|
||||
quantity: 1,
|
||||
individual_size_gigabytes: 240,
|
||||
parse_engine: 0,
|
||||
needed_description_check: false,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
true,
|
||||
),
|
||||
@@ -151,8 +150,8 @@ mod tests {
|
||||
total_gigabytes: 1024,
|
||||
quantity: 1,
|
||||
individual_size_gigabytes: 1024,
|
||||
parse_engine: 0,
|
||||
needed_description_check: true,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
false, // Sadly this one fails :/
|
||||
),
|
||||
@@ -164,8 +163,8 @@ mod tests {
|
||||
total_gigabytes: 7 * 1024,
|
||||
quantity: 1,
|
||||
individual_size_gigabytes: 7 * 1024,
|
||||
parse_engine: 0,
|
||||
needed_description_check: false,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
true,
|
||||
),
|
||||
@@ -177,8 +176,8 @@ mod tests {
|
||||
total_gigabytes: 6 * 256,
|
||||
quantity: 6,
|
||||
individual_size_gigabytes: 256,
|
||||
parse_engine: 0,
|
||||
needed_description_check: false,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
true,
|
||||
),
|
||||
@@ -190,8 +189,8 @@ mod tests {
|
||||
total_gigabytes: 1966,
|
||||
quantity: 1,
|
||||
individual_size_gigabytes: 1966,
|
||||
parse_engine: 0,
|
||||
needed_description_check: false,
|
||||
parse_engine: crate::db::StorageParsingEngineVersion::Regex,
|
||||
failed_reason: String::new(),
|
||||
},
|
||||
true,
|
||||
),
|
||||
|
Reference in New Issue
Block a user