Fix: SELECT SQL
This commit is contained in:
+12
-20
@@ -464,35 +464,26 @@ impl Filter {
|
||||
"#);
|
||||
|
||||
if let Some(ids) = &self.ids {
|
||||
if !&self.ids.is_none() {
|
||||
sql.push(" AND id in (");
|
||||
let mut separated = sql.separated(",");
|
||||
for id in ids {
|
||||
separated.push_bind(id);
|
||||
}
|
||||
separated.push_unseparated(")");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(pubkeys) = &self.authors {
|
||||
if !pubkeys.is_empty() {
|
||||
if let Some(pubkey) = &self.authors {
|
||||
sql.push(" AND pubkey in (");
|
||||
let mut separated = sql.separated(",");
|
||||
for pubkey in pubkeys {
|
||||
for pubkey in pubkey {
|
||||
separated.push_bind(pubkey);
|
||||
}
|
||||
separated.push_unseparated(")");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(kinds) = &self.kinds {
|
||||
if !kinds.is_empty() {
|
||||
sql.push(" AND kind in (");
|
||||
let mut separated = sql.separated(",");
|
||||
for kind in kinds {
|
||||
separated.push_bind(kind);
|
||||
if let Some(pubkeys) = &self.authors {
|
||||
if let Some(kinds) = &self.kinds {
|
||||
if !kinds.is_empty() {
|
||||
sql.push(" AND kind in (");
|
||||
let mut separated = sql.separated(",");
|
||||
for kind in kinds {
|
||||
separated.push_bind(kind);
|
||||
}
|
||||
separated.push_unseparated(")");
|
||||
}
|
||||
separated.push_unseparated(")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,6 +493,7 @@ impl Filter {
|
||||
let query = sql.build();
|
||||
debug!("SQL: {}", query.sql());
|
||||
let result = query.fetch_all(pool).await?;
|
||||
debug!("Selected {} events", result.len());
|
||||
let events: Vec<NostrEvent> = result
|
||||
.iter()
|
||||
.map(|row| NostrEvent {
|
||||
|
||||
Reference in New Issue
Block a user