Skip to content

Commit e682b2e

Browse files
committed
Actually fix bug
1 parent e01adf2 commit e682b2e

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/storage/boob.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once bun ships temporal
2-
31
import type { Snowflake, User } from "discord.js";
42

53
import type { Boob } from "./db/model.js";
64

7-
import { getStartAndEndDay } from "@/utils/dateUtils.js";
85
import db from "@db";
96
import log from "@log";
107

@@ -15,6 +12,7 @@ export function insertMeasurement(
1512
ctx = db(),
1613
): Promise<Boob> {
1714
log.debug(`Saving Boob Measurement for user ${user.id} with size ${size} from ${measuredAt}`);
15+
1816
return ctx
1917
.insertInto("boobs")
2018
.values({
@@ -26,14 +24,11 @@ export function insertMeasurement(
2624
}
2725

2826
export function fetchLastMeasurement(user: User, ctx = db()): Promise<Boob | undefined> {
29-
const now = Temporal.Now.instant();
30-
const { startOfToday, startOfTomorrow } = getStartAndEndDay(now);
31-
3227
return ctx
3328
.selectFrom("boobs")
3429
.where("userId", "=", user.id)
35-
.where("measuredAt", ">=", startOfToday.toString())
36-
.where("measuredAt", "<", startOfTomorrow.toString())
30+
.orderBy("id", "desc")
31+
.limit(1)
3732
.selectAll()
3833
.executeTakeFirst();
3934
}

0 commit comments

Comments
 (0)