File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Temporal } from "@js-temporal/polyfill" ; // TODO: Remove once bun ships temporal
2-
31import type { Snowflake , User } from "discord.js" ;
42
53import type { Boob } from "./db/model.js" ;
64
7- import { getStartAndEndDay } from "@/utils/dateUtils.js" ;
85import db from "@db" ;
96import 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
2826export 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}
You can’t perform that action at this time.
0 commit comments