refactor: Remove duplicated functions from list.rs
This commit is contained in:
@@ -178,41 +178,3 @@ pub fn mode_list(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These helper functions are needed for the mode_list function
|
// These helper functions are needed for the mode_list function
|
||||||
pub fn get_item_tags(conn: &Connection, item: &Item) -> Result<Vec<Tag>> {
|
|
||||||
debug!("DB: Getting tags for item: {:?}", item);
|
|
||||||
let mut statement = conn
|
|
||||||
.prepare_cached("SELECT id, name FROM tags WHERE id=?1 ORDER BY name ASC")
|
|
||||||
.context("Problem preparing SQL statement")?;
|
|
||||||
let mut rows = statement.query([item.id])?;
|
|
||||||
|
|
||||||
let mut tags = Vec::new();
|
|
||||||
|
|
||||||
while let Some(row) = rows.next()? {
|
|
||||||
tags.push(Tag {
|
|
||||||
id: row.get(0)?,
|
|
||||||
name: row.get(1)?,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(tags)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_item_meta(conn: &Connection, item: &Item) -> Result<Vec<Meta>> {
|
|
||||||
debug!("DB: Getting item meta: {:?}", item);
|
|
||||||
let mut statement = conn
|
|
||||||
.prepare_cached("SELECT id, name, value FROM metas WHERE id=?1 ORDER BY name ASC")
|
|
||||||
.context("Problem preparing SQL statement")?;
|
|
||||||
let mut rows = statement.query([item.id])?;
|
|
||||||
|
|
||||||
let mut metas = Vec::new();
|
|
||||||
|
|
||||||
while let Some(row) = rows.next()? {
|
|
||||||
metas.push(Meta {
|
|
||||||
id: row.get(0)?,
|
|
||||||
name: row.get(1)?,
|
|
||||||
value: row.get(2)?,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(metas)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user