Make sorting/limit more resilient in repository
This commit is contained in:
@@ -207,7 +207,7 @@ export const pull = async ({context, ...options}: PullOptions) => {
|
||||
await Promise.all(
|
||||
Array.from(idsByRelay.entries()).map(([relay, allIds]) => {
|
||||
return Promise.all(
|
||||
chunk(500, allIds).map(
|
||||
chunk(100, allIds).map(
|
||||
ids =>
|
||||
new Promise<void>(resolve =>
|
||||
requestOne({
|
||||
|
||||
@@ -154,15 +154,11 @@ export class Repository extends Emitter {
|
||||
) => {
|
||||
const result: TrustedEvent[][] = []
|
||||
for (const originalFilter of filters) {
|
||||
if (originalFilter.limit !== undefined && !shouldSort) {
|
||||
throw new Error("Unable to skip sorting if limit is defined")
|
||||
}
|
||||
|
||||
// Attempt to fulfill the query using one of our indexes. Fall back to all events.
|
||||
const applied = this._applyAnyFilter(originalFilter)
|
||||
const filter = applied?.filter || originalFilter
|
||||
const events = applied ? this._getEvents(applied!.ids) : this.dump()
|
||||
const sorted = this._sortEvents(shouldSort && Boolean(filter.limit), events)
|
||||
const sorted = this._sortEvents(shouldSort || Boolean(filter.limit), events)
|
||||
|
||||
const chunk: TrustedEvent[] = []
|
||||
for (const event of sorted) {
|
||||
|
||||
Reference in New Issue
Block a user