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