fix compaction sorting and missing live lookups

This commit is contained in:
Charlotte Som 2024-11-28 06:08:02 +02:00
parent c539a4dc5a
commit 1e0ff83f8b

View file

@ -10,7 +10,9 @@ export const getOperations = async (did: string) => {
const compactedEntries = await Array.fromAsync(
Deno.readDir("./data/plc/compacted")
);
compactedEntries.sort();
compactedEntries.sort((a, b) =>
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
);
for (const entry of compactedEntries) {
const process = new Deno.Command("zstd", {
args: [
@ -37,6 +39,7 @@ export const getOperations = async (did: string) => {
await process.status;
}
try {
const f = await Deno.open(`./data/plc/live/${prefix}`, { read: true });
const lines = f.readable
.pipeThrough(new TextDecoderStream())
@ -46,6 +49,9 @@ export const getOperations = async (did: string) => {
if (entry.did !== did) continue;
operations.push(entry);
}
} catch (_err) {
// ignore
}
return operations;
};