Skip to content

Commit

Permalink
remove extra sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Dec 1, 2023
1 parent 8726177 commit f1886bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/store-indexer/src/postgres/getLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ export async function getLogs(
.from(tables.recordsTable)
.where(or(...conditions))
.orderBy(
asc(tables.recordsTable.lastUpdatedBlockNumber),
// TODO: add logIndex and use that to sort instead of address/tableId? (https://github.com/latticexyz/mud/issues/1979)
asc(tables.recordsTable.address),
asc(tables.recordsTable.tableId)
asc(tables.recordsTable.lastUpdatedBlockNumber)
// TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979)
);

const blockNumber = records.reduce(
Expand Down
5 changes: 4 additions & 1 deletion packages/store-indexer/src/sqlite/getTablesWithRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export function getTablesWithRecords(
.select()
.from(sqliteTable)
.where(eq(sqliteTable.__isDeleted, false))
.orderBy(asc(sqliteTable.__lastUpdatedBlockNumber))
.orderBy(
asc(sqliteTable.__lastUpdatedBlockNumber)
// TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979)
)
.all();
const filteredRecords = !filters.length
? records
Expand Down
6 changes: 4 additions & 2 deletions packages/store-sync/src/sqlite/getTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export function getTables(
.select()
.from(mudStoreTables)
.where(ids.length ? inArray(mudStoreTables.id, ids) : undefined)
// TODO: add logIndex and use that to sort instead of address/tableId? (https://github.com/latticexyz/mud/issues/1979)
.orderBy(asc(mudStoreTables.lastUpdatedBlockNumber), asc(mudStoreTables.address), asc(mudStoreTables.tableId))
.orderBy(
asc(mudStoreTables.lastUpdatedBlockNumber)
// TODO: add logIndex (https://github.com/latticexyz/mud/issues/1979)
)
.all();

return tables;
Expand Down

0 comments on commit f1886bc

Please sign in to comment.