Merge branch 'feat/um-23-new-schema' into dev

This commit is contained in:
Brian Cao 2022-11-18 11:22:10 -08:00
commit 90fbe9abee
8 changed files with 18 additions and 24 deletions

View File

@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */
export namespace UmamiApi {
enum EventType {
export enum EventType {
Pageview = 1,
Event = 2,
}

View File

@ -1,5 +1,5 @@
import { Prisma } from '@prisma/client';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
import cache from 'lib/cache';
import prisma from 'lib/prisma';
@ -82,22 +82,16 @@ export async function updateUser(
data: Prisma.UserUpdateInput,
where: Prisma.UserWhereUniqueInput,
): Promise<User> {
return prisma.client.user
.update({
where,
data,
select: {
id: true,
username: true,
createdAt: true,
userRole: true,
},
})
.then(user => {
const { userRole, ...rest } = user;
return { ...rest, isAdmin: userRole.some(a => a.roleId === UmamiApi.SystemRole.Admin) };
});
return prisma.client.user.update({
where,
data,
select: {
id: true,
username: true,
createdAt: true,
userRole: true,
},
});
}
export async function deleteUser(

View File

@ -3,7 +3,7 @@ import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import prisma from 'lib/prisma';
import cache from 'lib/cache';
import { WebsiteMetric } from 'interface/api/models';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function getEventData(
...args: [

View File

@ -3,7 +3,7 @@ import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import cache from 'lib/cache';
import { WebsiteEventMetric } from 'interface/api/models';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function getEventMetrics(
...args: [

View File

@ -4,7 +4,7 @@ import kafka from 'lib/kafka';
import prisma from 'lib/prisma';
import { uuid } from 'lib/crypto';
import cache from 'lib/cache';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function saveEvent(args: {
id: string;

View File

@ -3,7 +3,7 @@ import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import cache from 'lib/cache';
import { Prisma } from '@prisma/client';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function getPageviewMetrics(
...args: [

View File

@ -2,7 +2,7 @@ import cache from 'lib/cache';
import clickhouse from 'lib/clickhouse';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import prisma from 'lib/prisma';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function getPageviewStats(
...args: [

View File

@ -4,7 +4,7 @@ import kafka from 'lib/kafka';
import prisma from 'lib/prisma';
import cache from 'lib/cache';
import { uuid } from 'lib/crypto';
import { UmamiApi } from 'interface/enum';
import { UmamiApi } from 'lib/enum';
export async function savePageView(args: {
id: string;