From aff11215ac2587d36f92b80c26a5f5d56f9c9b5e Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 2 Jul 2022 15:06:02 -0500 Subject: Minor database optimization for bin --- src/database.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/database.ts') diff --git a/src/database.ts b/src/database.ts index e3affc4..e7a7bad 100644 --- a/src/database.ts +++ b/src/database.ts @@ -128,7 +128,8 @@ export interface SimpleAuctionSchemaBson { ts: number /** Whether the auction was successfully bought or simply expired. */ s: boolean - bin: boolean + /** If this is missing, it's false. */ + bin?: true } export interface SimpleAuctionSchema { /** The UUID of the auction so we can look it up later. */ @@ -1124,6 +1125,7 @@ function toItemAuctionsSchema(i: ItemAuctionsSchemaBson): ItemAuctionsSchema { return { ...a, id: a.id.toString('hex'), + bin: a.bin ?? false } }), } @@ -1136,7 +1138,8 @@ function toItemAuctionsSchemaBson(i: ItemAuctionsSchema): ItemAuctionsSchemaBson auctions: i.auctions.map(a => { return { ...a, - id: createUuid(a.id) + id: createUuid(a.id), + bin: a.bin ? true : undefined } }), // we sort by oldestDate to get the volume sold, but we don't want brand new items with like no data having a high frequency -- cgit