Try to filter event types/state keys at the database level instead of in Go

This commit is contained in:
Neil Alexander 2021-04-16 12:52:46 +01:00
parent 6900e0f495
commit 45bcca2cb6
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 47 additions and 43 deletions

View file

@ -126,16 +126,16 @@ func (d *Database) StateEntriesForTuples(
}
lists := []types.StateEntryList{}
for i, entry := range entries {
entries, err := d.EventsTable.BulkSelectStateEventByNID(ctx, entry)
entries, err := d.EventsTable.BulkSelectStateEventByNID(ctx, entry, stateKeyTuples)
if err != nil {
return nil, fmt.Errorf("d.EventsTable.BulkSelectStateEventByNID: %w", err)
}
if len(stateKeyTuples) == 0 {
lists = append(lists, types.StateEntryList{
StateBlockNID: stateBlockNIDs[i],
StateEntries: entries,
})
} else {
//if len(stateKeyTuples) == 0 {
lists = append(lists, types.StateEntryList{
StateBlockNID: stateBlockNIDs[i],
StateEntries: entries,
})
/*} else {
eventTypes := map[types.EventTypeNID]struct{}{}
stateKeys := map[types.EventStateKeyNID]struct{}{}
for _, t := range stateKeyTuples {
@ -154,7 +154,7 @@ func (d *Database) StateEntriesForTuples(
StateBlockNID: stateBlockNIDs[i],
StateEntries: filteredEntries,
})
}
}*/
}
return lists, nil
}
@ -281,7 +281,7 @@ func (d *Database) StateEntries(
}
lists := []types.StateEntryList{}
for i, entry := range entries {
eventNIDs, err := d.EventsTable.BulkSelectStateEventByNID(ctx, entry)
eventNIDs, err := d.EventsTable.BulkSelectStateEventByNID(ctx, entry, nil)
if err != nil {
return nil, fmt.Errorf("d.EventsTable.BulkSelectStateEventByNID: %w", err)
}