Added the ability to get tags from the database.

Also fixed the way the example was compiling so it didn't act weird on
other features.
This commit is contained in:
2025-09-07 17:46:18 -04:00
parent 6bf4aa4bdb
commit 80e0fba845
3 changed files with 41 additions and 4 deletions

View File

@ -274,6 +274,27 @@ impl Database
Ok(())
}
#[cfg(any(not(feature = "publisher"), feature = "tester"))]
pub async fn get_all_tags(&self) -> Result<Vec<String>>
{
let mut tx = self.pool.begin().await?;
let rows = sqlx::query!(
"SELECT name FROM tags ORDER BY name ASC"
)
.fetch_all(&mut *tx)
.await?;
tx.commit().await?;
let tags = rows
.into_iter()
.filter_map(|row| Some(row.name))
.collect();
Ok(tags)
}
#[cfg(any(not(feature = "publisher"), feature = "tester"))]
pub async fn get_tales_summary(&self, categories: &[String])
-> Result<Vec<Lore>>