Fix panic on requesting projects (#223)

This commit is contained in:
Geometrically
2021-07-19 14:47:14 -07:00
committed by GitHub
parent 9ee92fb9e9
commit b2f8bb9990
5 changed files with 348 additions and 299 deletions

View File

@@ -650,14 +650,20 @@ impl Project {
.split(" ,")
.map(|d| {
let strings: Vec<&str> = d.split(", ").collect();
DonationUrl {
project_id: id,
platform_id: DonationPlatformId(strings[0].parse().unwrap_or(0)),
platform_short: strings[2].to_string(),
platform_name: strings[3].to_string(),
url: strings[1].to_string(),
if strings.len() >= 3 {
Some(DonationUrl {
project_id: id,
platform_id: DonationPlatformId(strings[0].parse().unwrap_or(0)),
platform_short: strings[2].to_string(),
platform_name: strings[3].to_string(),
url: strings[1].to_string(),
})
} else {
None
}
})
.flatten()
.collect(),
gallery_items: m
.gallery
@@ -755,14 +761,20 @@ impl Project {
.split(" ,")
.map(|d| {
let strings: Vec<&str> = d.split(", ").collect();
DonationUrl {
project_id: ProjectId(id),
platform_id: DonationPlatformId(strings[0].parse().unwrap_or(0)),
platform_short: strings[2].to_string(),
platform_name: strings[3].to_string(),
url: strings[1].to_string(),
if strings.len() >= 3 {
Some(DonationUrl {
project_id: ProjectId(id),
platform_id: DonationPlatformId(strings[0].parse().unwrap_or(0)),
platform_short: strings[2].to_string(),
platform_name: strings[3].to_string(),
url: strings[1].to_string(),
})
} else {
None
}
})
.flatten()
.collect(),
gallery_items: m.gallery.iter().map(|x| GalleryItem {
project_id: ProjectId(id),