mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Convert /api/users.
This commit is contained in:
parent
090abcff81
commit
baa3851fb4
61 changed files with 1064 additions and 70 deletions
|
|
@ -15,7 +15,7 @@ async function relationalQuery(websiteId: string) {
|
|||
|
||||
const result = await rawQuery(
|
||||
`
|
||||
select count(distinct session_id) x
|
||||
select count(distinct session_id) as visitors
|
||||
from website_event
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at >= {{startDate}}
|
||||
|
|
@ -32,7 +32,7 @@ async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {
|
|||
const result = await rawQuery(
|
||||
`
|
||||
select
|
||||
count(distinct session_id) x
|
||||
count(distinct session_id) as "visitors"
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at >= {startDate:DateTime64}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@ import prisma from 'lib/prisma';
|
|||
import { QueryFilters } from 'lib/types';
|
||||
|
||||
export async function getPageviewMetrics(
|
||||
...args: [websiteId: string, type: string, filters: QueryFilters, limit?: number, offset?: number]
|
||||
...args: [
|
||||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit?: number | string,
|
||||
offset?: number | string,
|
||||
]
|
||||
) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -17,8 +23,8 @@ async function relationalQuery(
|
|||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit: number = 500,
|
||||
offset: number = 0,
|
||||
limit: number | string = 500,
|
||||
offset: number | string = 0,
|
||||
) {
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const { rawQuery, parseFilters } = prisma;
|
||||
|
|
@ -80,8 +86,8 @@ async function clickhouseQuery(
|
|||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit: number = 500,
|
||||
offset: number = 0,
|
||||
limit: number | string = 500,
|
||||
offset: number | string = 0,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const { rawQuery, parseFilters } = clickhouse;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@ import prisma from 'lib/prisma';
|
|||
import { QueryFilters } from 'lib/types';
|
||||
|
||||
export async function getSessionMetrics(
|
||||
...args: [websiteId: string, type: string, filters: QueryFilters, limit?: number, offset?: number]
|
||||
...args: [
|
||||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit?: number | string,
|
||||
offset?: number | string,
|
||||
]
|
||||
) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
|
|
@ -17,8 +23,8 @@ async function relationalQuery(
|
|||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit: number = 500,
|
||||
offset: number = 0,
|
||||
limit: number | string = 500,
|
||||
offset: number | string = 0,
|
||||
) {
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const { parseFilters, rawQuery } = prisma;
|
||||
|
|
@ -60,8 +66,8 @@ async function clickhouseQuery(
|
|||
websiteId: string,
|
||||
type: string,
|
||||
filters: QueryFilters,
|
||||
limit: number = 500,
|
||||
offset: number = 0,
|
||||
limit: number | string = 500,
|
||||
offset: number | string = 0,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ export async function getReports(
|
|||
criteria: ReportFindManyArgs,
|
||||
pageParams: PageParams = {},
|
||||
): Promise<PageResult<Report[]>> {
|
||||
const { query } = pageParams;
|
||||
const { search } = pageParams;
|
||||
|
||||
const where: Prisma.ReportWhereInput = {
|
||||
...criteria.where,
|
||||
...prisma.getSearchParameters(query, [
|
||||
...prisma.getSearchParameters(search, [
|
||||
{ name: 'contains' },
|
||||
{ description: 'contains' },
|
||||
{ type: 'contains' },
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ export async function getWebsites(
|
|||
criteria: WebsiteFindManyArgs,
|
||||
pageParams: PageParams,
|
||||
): Promise<PageResult<Website[]>> {
|
||||
const { query } = pageParams;
|
||||
const { search } = pageParams;
|
||||
|
||||
const where: Prisma.WebsiteWhereInput = {
|
||||
...criteria.where,
|
||||
...prisma.getSearchParameters(query, [
|
||||
...prisma.getSearchParameters(search, [
|
||||
{
|
||||
name: 'contains',
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue