Make mod category nullable

This commit is contained in:
Tyler Hallada 2021-08-08 19:09:34 -06:00
parent b2d17f6217
commit 6136ac18fa
3 changed files with 7 additions and 7 deletions

View File

@ -0,0 +1 @@
ALTER TABLE "mods" ALTER COLUMN "category" DROP NOT NULL;

View File

@ -12,7 +12,7 @@ pub struct Mod {
pub name: String, pub name: String,
pub nexus_mod_id: i32, pub nexus_mod_id: i32,
pub author: String, pub author: String,
pub category: String, pub category: Option<String>,
pub description: Option<String>, pub description: Option<String>,
pub game_id: i32, pub game_id: i32,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
@ -25,7 +25,7 @@ pub struct UnsavedMod<'a> {
pub name: &'a str, pub name: &'a str,
pub nexus_mod_id: i32, pub nexus_mod_id: i32,
pub author: &'a str, pub author: &'a str,
pub category: &'a str, pub category: Option<&'a str>,
pub description: Option<&'a str>, pub description: Option<&'a str>,
pub game_id: i32, pub game_id: i32,
} }
@ -68,7 +68,7 @@ pub async fn insert(
name: &str, name: &str,
nexus_mod_id: i32, nexus_mod_id: i32,
author: &str, author: &str,
category: &str, category: Option<&str>,
description: Option<&str>, description: Option<&str>,
game_id: i32, game_id: i32,
) -> Result<Mod> { ) -> Result<Mod> {
@ -103,7 +103,7 @@ pub async fn batched_insert<'a>(
let mut names: Vec<&str> = vec![]; let mut names: Vec<&str> = vec![];
let mut nexus_mod_ids: Vec<i32> = vec![]; let mut nexus_mod_ids: Vec<i32> = vec![];
let mut authors: Vec<&str> = vec![]; let mut authors: Vec<&str> = vec![];
let mut categories: Vec<&str> = vec![]; let mut categories: Vec<Option<&str>> = vec![];
let mut descriptions: Vec<Option<&str>> = vec![]; let mut descriptions: Vec<Option<&str>> = vec![];
let mut game_ids: Vec<i32> = vec![]; let mut game_ids: Vec<i32> = vec![];
batch.into_iter().for_each(|unsaved_mod| { batch.into_iter().for_each(|unsaved_mod| {

View File

@ -11,7 +11,7 @@ pub struct ModListResponse {
pub struct ScrapedMod<'a> { pub struct ScrapedMod<'a> {
pub nexus_mod_id: i32, pub nexus_mod_id: i32,
pub name: &'a str, pub name: &'a str,
pub category: &'a str, pub category: Option<&'a str>,
pub author: &'a str, pub author: &'a str,
pub desc: Option<&'a str>, pub desc: Option<&'a str>,
} }
@ -89,8 +89,7 @@ impl ModListResponse {
.expect("Missing category link for mod"); .expect("Missing category link for mod");
let category = category_elem let category = category_elem
.text() .text()
.next() .next();
.expect("Missing category text for mod");
let author_elem = right let author_elem = right
.select(&author_select) .select(&author_select)
.next() .next()