mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/components/common/Pager.module.css # src/lib/constants.ts # src/lib/yup.ts # src/pages/api/teams/[id]/users/index.ts # src/pages/api/websites/[id]/reports.ts
This commit is contained in:
commit
40cfcd41e9
19 changed files with 135 additions and 92 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { Prisma } from '@prisma/client';
|
||||
import cache from 'lib/cache';
|
||||
import { ROLES, USER_FILTER_TYPES } from 'lib/constants';
|
||||
import { ROLES } from 'lib/constants';
|
||||
import prisma from 'lib/prisma';
|
||||
import { FilterResult, Role, User, UserSearchFilter } from 'lib/types';
|
||||
import { getRandomChars } from 'next-basics';
|
||||
|
|
@ -37,10 +37,10 @@ export async function getUserByUsername(username: string, options: GetUserOption
|
|||
}
|
||||
|
||||
export async function getUsers(
|
||||
searchFilter: UserSearchFilter,
|
||||
params: UserSearchFilter,
|
||||
options?: { include?: Prisma.UserInclude },
|
||||
): Promise<FilterResult<User[]>> {
|
||||
const { teamId, filter, filterType = USER_FILTER_TYPES.all } = searchFilter;
|
||||
const { teamId, query } = params;
|
||||
const mode = prisma.getSearchMode();
|
||||
|
||||
const where: Prisma.UserWhereInput = {
|
||||
|
|
@ -51,17 +51,14 @@ export async function getUsers(
|
|||
},
|
||||
},
|
||||
}),
|
||||
...(filter && {
|
||||
...(query && {
|
||||
AND: {
|
||||
OR: [
|
||||
{
|
||||
...((filterType === USER_FILTER_TYPES.all ||
|
||||
filterType === USER_FILTER_TYPES.username) && {
|
||||
username: {
|
||||
startsWith: filter,
|
||||
...mode,
|
||||
},
|
||||
}),
|
||||
username: {
|
||||
contains: query,
|
||||
...mode,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -70,7 +67,7 @@ export async function getUsers(
|
|||
|
||||
const [pageFilters, getParameters] = prisma.getPageFilters({
|
||||
orderBy: 'username',
|
||||
...searchFilter,
|
||||
...params,
|
||||
});
|
||||
|
||||
const users = await prisma.client.user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue