sdk changes
This commit is contained in:
@@ -5,7 +5,7 @@ import type {
|
||||
IGetChartDataInput,
|
||||
IInterval,
|
||||
} from '@/types';
|
||||
import { alphabetIds } from '@/utils/constants';
|
||||
import { alphabetIds, NOT_SET_VALUE } from '@/utils/constants';
|
||||
import { round } from '@/utils/math';
|
||||
import * as mathjs from 'mathjs';
|
||||
import { sort } from 'ramda';
|
||||
@@ -207,7 +207,7 @@ export async function getChartData(payload: IGetChartDataInput) {
|
||||
(acc, item) => {
|
||||
// item.label can be null when using breakdowns on a property
|
||||
// that doesn't exist on all events
|
||||
const label = item.label?.trim() || '(not set)';
|
||||
const label = item.label?.trim() || NOT_SET_VALUE;
|
||||
if (label) {
|
||||
if (acc[label]) {
|
||||
acc[label]?.push(item);
|
||||
|
||||
@@ -29,19 +29,21 @@ interface Metrics {
|
||||
};
|
||||
}
|
||||
|
||||
interface FinalChart {
|
||||
events: IChartInput['events'];
|
||||
series: {
|
||||
name: string;
|
||||
event: IChartEvent;
|
||||
metrics: Metrics;
|
||||
data: {
|
||||
date: string;
|
||||
count: number;
|
||||
label: string | null;
|
||||
previous: PreviousValue;
|
||||
}[];
|
||||
export interface IChartSerie {
|
||||
name: string;
|
||||
event: IChartEvent;
|
||||
metrics: Metrics;
|
||||
data: {
|
||||
date: string;
|
||||
count: number;
|
||||
label: string | null;
|
||||
previous: PreviousValue;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface FinalChart {
|
||||
events: IChartInput['events'];
|
||||
series: IChartSerie[];
|
||||
metrics: Metrics;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { randomUUID } from 'crypto';
|
||||
import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc';
|
||||
import { db } from '@/server/db';
|
||||
import { hashPassword } from '@/server/services/hash.service';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword } from '@mixan/common';
|
||||
|
||||
export const clientRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
.input(
|
||||
|
||||
@@ -29,6 +29,8 @@ export const eventRouter = createTRPCRouter({
|
||||
sb.where.name = `name IN (${events.map((e) => `'${e}'`).join(',')})`;
|
||||
}
|
||||
|
||||
sb.orderBy.created_at = 'created_at DESC';
|
||||
|
||||
return (await chQuery<IDBEvent>(getSql())).map(transformEvent);
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user