aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database.ts7
-rw-r--r--src/hypixel.ts2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/database.ts b/src/database.ts
index f3b8175..2392332 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -152,6 +152,8 @@ export interface ItemAuctionsSchemaBson {
/** The id of the item */
_id: string
auctions: SimpleAuctionSchemaBson[]
+ /** This is here so it can be indexed by Mongo, it can easily be figured out by getting the first item in auctions */
+ oldestDate: number
}
let memberLeaderboardsCollection: Collection<DatabaseMemberLeaderboardItem>
@@ -1111,7 +1113,7 @@ export async function updateAccount(discordId: string, schema: AccountSchema) {
}, { $set: schema }, { upsert: true })
}
-function toItemAuctionsSchema(i: ItemAuctionsSchemaBson) {
+function toItemAuctionsSchema(i: ItemAuctionsSchemaBson): ItemAuctionsSchema {
return {
id: i._id,
auctions: i.auctions.map(a => {
@@ -1123,7 +1125,7 @@ function toItemAuctionsSchema(i: ItemAuctionsSchemaBson) {
}
}
-function toItemAuctionsSchemaBson(i: ItemAuctionsSchema) {
+function toItemAuctionsSchemaBson(i: ItemAuctionsSchema): ItemAuctionsSchemaBson {
return {
_id: i.id,
auctions: i.auctions.map(a => {
@@ -1132,6 +1134,7 @@ function toItemAuctionsSchemaBson(i: ItemAuctionsSchema) {
id: createUuid(a.id)
}
}),
+ oldestDate: i.auctions[0]?.ts ?? 0
}
}
diff --git a/src/hypixel.ts b/src/hypixel.ts
index a2a8749..a29a7b1 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -416,7 +416,7 @@ export async function periodicallyFetchRecentlyEndedAuctions() {
bin: auction.bin,
}
// make sure the auction isn't already in there
- if (auctions.find((a) => a.id === simpleAuction.id)) {
+ if (!auctions.find((a) => a.id === simpleAuction.id)) {
auctions.push(simpleAuction)
// keep only the last 100 items
if (auctions.length > 100)