some more additions related to move usage

This commit is contained in:
2023-02-20 03:00:29 +09:00
parent d1c62f3bb7
commit e5067a1b39
4 changed files with 20 additions and 6 deletions

View File

@@ -202,7 +202,7 @@ fn increase_attack_usage(index: i64) {
fn search_learnset(index: i64) -> Vec<PokemonDataLearnset> {
let connection = sqlite::open("./pokemon.db").unwrap();
let mut learnset: Vec<PokemonDataLearnset> = vec![];
let move_query = "SELECT pl.id, pl.learnset_id, l.name, l.types, l.power, l.category FROM pokemon__learnset pl JOIN learnset l on pl.learnset_id = l.id WHERE pl.pokemon_id = ? ORDER BY usage DESC";
let move_query = "SELECT pl.id, pl.learnset_id, l.name, l.types, l.power, l.category, pl.usage FROM pokemon__learnset pl JOIN learnset l on pl.learnset_id = l.id WHERE pl.pokemon_id = ? ORDER BY usage DESC";
for row in connection
.prepare(move_query)
.unwrap()
@@ -218,6 +218,7 @@ fn search_learnset(index: i64) -> Vec<PokemonDataLearnset> {
types: serde_json::from_str(row.read::<&str, _>("types")).unwrap_or(vec![0]),
power: row.read::<i64, _>("power"),
category: row.read::<i64, _>("category"),
usage: row.read::<i64, _>("usage"),
};
learnset.push(row_result)
}

View File

@@ -26,6 +26,7 @@ pub struct PokemonDataLearnset {
pub types: Vec<i64>,
pub power: i64,
pub category: i64,
pub usage: i64,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MoveSearchResult {