Fix retrieval of tags for multiple cds

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/6/head
trivernis 3 years ago
parent 2bec24c387
commit 06e43bb77e
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -4,7 +4,7 @@ use mediarepo_core::error::RepoResult;
use mediarepo_database::entities::{namespace, tag}; use mediarepo_database::entities::{namespace, tag};
use sea_orm::prelude::*; use sea_orm::prelude::*;
use sea_orm::sea_query::Expr; use sea_orm::sea_query::Expr;
use sea_orm::Condition; use sea_orm::{Condition, QuerySelect};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct TagByNameQuery { pub struct TagByNameQuery {
@ -30,6 +30,7 @@ impl TagDao {
let tags = tag::Entity::find() let tags = tag::Entity::find()
.find_also_related(namespace::Entity) .find_also_related(namespace::Entity)
.filter(condition) .filter(condition)
.group_by(tag::Column::Id)
.all(&self.ctx.db) .all(&self.ctx.db)
.await? .await?
.into_iter() .into_iter()

@ -70,6 +70,7 @@ impl TagDao {
content_descriptor_tag::Relation::ContentDescriptorId.def(), content_descriptor_tag::Relation::ContentDescriptorId.def(),
) )
.filter(content_descriptor::Column::Descriptor.is_in(cds)) .filter(content_descriptor::Column::Descriptor.is_in(cds))
.group_by(tag::Column::Id)
.all(&self.ctx.db) .all(&self.ctx.db)
.await? .await?
.into_iter() .into_iter()

Loading…
Cancel
Save