More project type validators (#383)

This commit is contained in:
Geometrically
2022-06-26 10:39:38 -07:00
committed by GitHub
parent 134c43ad9e
commit 4e97a3b3d5
9 changed files with 111 additions and 33 deletions

View File

@@ -679,7 +679,7 @@ impl Project {
.donations
.unwrap_or_default()
.split(" ~~~~ ")
.map(|d| {
.flat_map(|d| {
let strings: Vec<&str> = d.split(" |||| ").collect();
if strings.len() >= 3 {
@@ -696,13 +696,12 @@ impl Project {
None
}
})
.flatten()
.collect(),
gallery_items: m
.gallery
.unwrap_or_default()
.split(" ~~~~ ")
.map(|d| {
.flat_map(|d| {
let strings: Vec<&str> = d.split(" |||| ").collect();
if strings.len() >= 5 {
@@ -726,7 +725,6 @@ impl Project {
None
}
})
.flatten()
.collect(),
status: crate::models::projects::ProjectStatus::from_str(
&m.status_name,
@@ -822,7 +820,7 @@ impl Project {
.gallery
.unwrap_or_default()
.split(" ~~~~ ")
.map(|d| {
.flat_map(|d| {
let strings: Vec<&str> = d.split(" |||| ").collect();
if strings.len() >= 5 {
@@ -838,13 +836,12 @@ impl Project {
None
}
})
.flatten()
.collect(),
donation_urls: m
.donations
.unwrap_or_default()
.split(" ~~~~ ")
.map(|d| {
.flat_map(|d| {
let strings: Vec<&str> = d.split(" |||| ").collect();
if strings.len() >= 3 {
@@ -859,7 +856,6 @@ impl Project {
None
}
})
.flatten()
.collect(),
status: crate::models::projects::ProjectStatus::from_str(&m.status_name),
license_id: m.short,

View File

@@ -650,7 +650,7 @@ impl Version {
.hashes
.unwrap_or_default()
.split(" ~~~~ ")
.map(|f| {
.flat_map(|f| {
let hash: Vec<&str> = f.split(" |||| ").collect();
if hash.len() >= 3 {
@@ -663,13 +663,12 @@ impl Version {
None
}
})
.flatten()
.collect();
v.files
.unwrap_or_default()
.split(" ~~~~ ")
.map(|f| {
.flat_map(|f| {
let file: Vec<&str> = f.split(" |||| ").collect();
if file.len() >= 5 {
@@ -698,7 +697,6 @@ impl Version {
None
}
})
.flatten()
.collect()
},
game_versions: {
@@ -737,7 +735,7 @@ impl Version {
.dependencies
.unwrap_or_default()
.split(" ~~~~ ")
.map(|f| {
.flat_map(|f| {
let dependency: Vec<&str> = f.split(" |||| ").collect();
if dependency.len() >= 4 {
@@ -767,7 +765,6 @@ impl Version {
None
}
})
.flatten()
.collect(),
version_type: v.version_type,
}))
@@ -824,7 +821,7 @@ impl Version {
date_published: v.date_published,
downloads: v.downloads,
files: {
let hashes: Vec<(FileId, String, Vec<u8>)> = v.hashes.unwrap_or_default().split(" ~~~~ ").map(|f| {
let hashes: Vec<(FileId, String, Vec<u8>)> = v.hashes.unwrap_or_default().split(" ~~~~ ").flat_map(|f| {
let hash: Vec<&str> = f.split(" |||| ").collect();
if hash.len() >= 3 {
@@ -836,9 +833,9 @@ impl Version {
} else {
None
}
}).flatten().collect();
}).collect();
v.files.unwrap_or_default().split(" ~~~~ ").map(|f| {
v.files.unwrap_or_default().split(" ~~~~ ").flat_map(|f| {
let file: Vec<&str> = f.split(" |||| ").collect();
if file.len() >= 5 {
@@ -862,7 +859,7 @@ impl Version {
} else {
None
}
}).flatten().collect()
}).collect()
},
game_versions: {
let game_versions = v
@@ -893,7 +890,7 @@ impl Version {
dependencies: v.dependencies
.unwrap_or_default()
.split(" ~~~~ ")
.map(|f| {
.flat_map(|f| {
let dependency: Vec<&str> = f.split(" |||| ").collect();
if dependency.len() >= 4 {
@@ -922,7 +919,7 @@ impl Version {
} else {
None
}
}).flatten().collect(),
}).collect(),
version_type: v.version_type
}
))