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 */ /* eslint-disable no-unused-vars */
export namespace UmamiApi { export namespace UmamiApi {
enum EventType { export enum EventType {
Pageview = 1, Pageview = 1,
Event = 2, Event = 2,
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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