summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 3e821c2..3e66f9a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -101,6 +101,21 @@ impl TagBase {
)?;
Ok(())
}
+
+ fn tags_for_image(&self, image_id: i64) -> Result<Vec<String>> {
+ Ok(self
+ .conn
+ .prepare(
+ "SELECT tags.name, COUNT(mapping.tag) as tag_count
+ FROM mapping
+ INNER JOIN images ON images.id = ?
+ INNER JOIN tags
+ GROUP BY tags.name",
+ )?
+ .query_map(params![image_id], |row| row.get(0))?
+ .filter_map(|tag| tag.ok())
+ .collect())
+ }
}
fn main() {