diff --git a/apps/web/src/server/api/routers/chart.formula.ts b/apps/web/src/server/api/routers/chart.helpers.ts similarity index 99% rename from apps/web/src/server/api/routers/chart.formula.ts rename to apps/web/src/server/api/routers/chart.helpers.ts index 57171ec3..1d9d9e65 100644 --- a/apps/web/src/server/api/routers/chart.formula.ts +++ b/apps/web/src/server/api/routers/chart.helpers.ts @@ -6,7 +6,7 @@ import type { IInterval, } from '@/types'; import { alphabetIds } from '@/utils/constants'; -import { average, max, min, round, sum } from '@/utils/math'; +import { round } from '@/utils/math'; import * as mathjs from 'mathjs'; import { sort } from 'ramda'; diff --git a/apps/web/src/server/api/routers/chart.ts b/apps/web/src/server/api/routers/chart.ts index 5c5204f0..66bc7134 100644 --- a/apps/web/src/server/api/routers/chart.ts +++ b/apps/web/src/server/api/routers/chart.ts @@ -3,12 +3,12 @@ import type { IChartEvent, IChartInput, IChartRange } from '@/types'; import { getDaysOldDate } from '@/utils/date'; import { average, max, min, round, sum } from '@/utils/math'; import { zChartInput } from '@/utils/validation'; -import { flatten, map, pathOr, pipe, prop, sort, uniq } from 'ramda'; +import { flatten, map, pipe, prop, sort, uniq } from 'ramda'; import { z } from 'zod'; import { chQuery } from '@mixan/db'; -import { getChartData, withFormula } from './chart.formula'; +import { getChartData, withFormula } from './chart.helpers'; type PreviousValue = { value: number; @@ -176,16 +176,6 @@ export const chartRouter = createTRPCRouter({ const promises = [getSeriesFromEvents(input)]; if (input.previous) { - console.log('------->P R E V I O U S'); - console.log({ - startDate: new Date( - new Date(current.startDate).getTime() - diff - ).toISOString(), - endDate: new Date( - new Date(current.endDate).getTime() - diff - ).toISOString(), - }); - promises.push( getSeriesFromEvents({ ...input, @@ -396,20 +386,21 @@ async function getSeriesFromEvents(input: IChartInput) { function getDatesFromRange(range: IChartRange) { if (range === 'today') { const startDate = new Date(); - const endDate = new Date().toISOString(); - startDate.setHours(0, 0, 0, 0); + const endDate = new Date(); + startDate.setUTCHours(0, 0, 0, 0); + endDate.setUTCHours(23, 59, 59, 999); return { - startDate: startDate.toISOString(), - endDate: endDate, + startDate: startDate.toUTCString(), + endDate: endDate.toUTCString(), }; } if (range === '30min' || range === '1h') { const startDate = new Date( Date.now() - 1000 * 60 * (range === '30min' ? 30 : 60) - ).toISOString(); - const endDate = new Date().toISOString(); + ).toUTCString(); + const endDate = new Date().toUTCString(); return { startDate, @@ -440,7 +431,7 @@ function getDatesFromRange(range: IChartRange) { const endDate = new Date(); endDate.setUTCHours(23, 59, 59, 999); return { - startDate: startDate.toISOString(), - endDate: endDate.toISOString(), + startDate: startDate.toUTCString(), + endDate: endDate.toUTCString(), }; } diff --git a/apps/web/src/server/api/routers/user.ts b/apps/web/src/server/api/routers/user.ts index 6c18fc3a..647fce63 100644 --- a/apps/web/src/server/api/routers/user.ts +++ b/apps/web/src/server/api/routers/user.ts @@ -1,18 +1,9 @@ import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc'; -import { db } from '@/server/db'; -import { hashPassword, verifyPassword } from '@/server/services/hash.service'; import { transformUser } from '@/server/services/user.service'; import { clerkClient } from '@clerk/nextjs'; import { z } from 'zod'; export const userRouter = createTRPCRouter({ - current: protectedProcedure.query(({ ctx }) => { - return db.user.findUniqueOrThrow({ - where: { - id: ctx.session.user.id, - }, - }); - }), update: protectedProcedure .input( z.object({