Fix multitag issue
This commit is contained in:
parent
96e781cd85
commit
8c6c1a8385
|
@ -940,20 +940,28 @@ impl NostrSqlite {
|
||||||
query = query.limit(limit as u64).to_owned();
|
query = query.limit(limit as u64).to_owned();
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.generic_tags.iter().for_each(|(tag, values)| {
|
if !filter.generic_tags.is_empty() {
|
||||||
let values = values.iter().map(|val| val.to_string());
|
|
||||||
query = query
|
query = query
|
||||||
.left_join(
|
.left_join(
|
||||||
TagsTable::Table,
|
TagsTable::Table,
|
||||||
sea_query::Expr::col((TagsTable::Table, TagsTable::EventId))
|
sea_query::Expr::col((TagsTable::Table, TagsTable::EventId))
|
||||||
.equals((EventsTable::Table, EventsTable::EventId)),
|
.equals((EventsTable::Table, EventsTable::EventId)),
|
||||||
)
|
)
|
||||||
|
.to_owned();
|
||||||
|
|
||||||
|
filter.generic_tags.iter().for_each(|(tag, values)| {
|
||||||
|
let values = values.iter().map(|val| val.to_string());
|
||||||
|
query = query
|
||||||
.and_where(
|
.and_where(
|
||||||
sea_query::Expr::col((TagsTable::Table, TagsTable::Tag)).eq(tag.to_string()),
|
sea_query::Expr::col((TagsTable::Table, TagsTable::Tag))
|
||||||
|
.eq(tag.to_string()),
|
||||||
|
)
|
||||||
|
.and_where(
|
||||||
|
sea_query::Expr::col((TagsTable::Table, TagsTable::Value)).is_in(values),
|
||||||
)
|
)
|
||||||
.and_where(sea_query::Expr::col((TagsTable::Table, TagsTable::Value)).is_in(values))
|
|
||||||
.to_owned();
|
.to_owned();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(search) = &filter.search {
|
if let Some(search) = &filter.search {
|
||||||
query = query
|
query = query
|
||||||
|
@ -990,7 +998,6 @@ impl NostrSqlite {
|
||||||
self.get_filter_query(filter),
|
self.get_filter_query(filter),
|
||||||
sea_query::Alias::new("events"),
|
sea_query::Alias::new("events"),
|
||||||
)
|
)
|
||||||
// .order_by(EventsTable::CreatedAt, order.to_owned())
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
})
|
})
|
||||||
.reduce(|mut result, query| result.union(sea_query::UnionType::All, query).to_owned())
|
.reduce(|mut result, query| result.union(sea_query::UnionType::All, query).to_owned())
|
||||||
|
@ -1266,10 +1273,12 @@ impl Noose for NostrSqlite {
|
||||||
Err(e) => Command::ServiceError(e),
|
Err(e) => Command::ServiceError(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::DbReqDeleteEvents(client_id, event) => match self.admin_delete_events(&event).await {
|
Command::DbReqDeleteEvents(client_id, event) => {
|
||||||
|
match self.admin_delete_events(&event).await {
|
||||||
Ok(status) => Command::DbResOkWithStatus(client_id, status),
|
Ok(status) => Command::DbResOkWithStatus(client_id, status),
|
||||||
Err(e) => Command::ServiceError(e),
|
Err(e) => Command::ServiceError(e),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Command::DbReqEventCounts(client_id, subscriptioin) => {
|
Command::DbReqEventCounts(client_id, subscriptioin) => {
|
||||||
match self.counts(subscriptioin).await {
|
match self.counts(subscriptioin).await {
|
||||||
Ok(relay_message) => Command::DbResEventCounts(client_id, relay_message),
|
Ok(relay_message) => Command::DbResEventCounts(client_id, relay_message),
|
||||||
|
|
Loading…
Reference in a new issue