diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 251522e..f47d275 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -225,26 +225,8 @@ fn search_learnset(index: i64) -> Vec { #[tauri::command] fn search(index: i64) -> SearchResult { let connection = sqlite::open("./pokemon.db").unwrap(); - let mut learnset: Vec = 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"; - for row in connection - .prepare(move_query) - .unwrap() - .into_iter() - .bind((1, index)) - .unwrap() - .map(|row| row.unwrap()) - { - let row_result = PokemonDataLearnset { - id: row.read::("id"), - learnset_id: row.read::("learnset_id"), - name: row.read::<&str, _>("name").to_string(), - types: serde_json::from_str(row.read::<&str, _>("types")).unwrap_or(vec![0]), - power: row.read::("power"), - category: row.read::("category"), - }; - learnset.push(row_result) - } + let learnset = search_learnset(index.clone()); + let query = "SELECT * FROM pokemon WHERE id = ?"; for row in connection .prepare(query) diff --git a/src-tauri/src/model.rs b/src-tauri/src/model.rs index 60bf8a9..2f6696a 100644 --- a/src-tauri/src/model.rs +++ b/src-tauri/src/model.rs @@ -163,7 +163,7 @@ impl From<(PokemonDataToSave, SearchResult)> for PokemonDataToLoad { special_defense_buff: 0, speed_buff: 0, item: value.0.item, - learnset: vec![], + learnset: value.1.learnset, terastype: vec![0] } }