rename propertyName parameter
This commit is contained in:
@@ -20,7 +20,7 @@ export function SessionProperties({ websiteId }: { websiteId: string }) {
|
||||
const { data, isLoading, isFetching, error } = usePropertyFieldsQuery('session', websiteId);
|
||||
const { data: scopedData } = useSessionDataPropertiesQuery(
|
||||
websiteId,
|
||||
propertyName ? { selectedPropertyName: propertyName, propertyFilters } : undefined,
|
||||
propertyName ? { propertyName, propertyFilters } : undefined,
|
||||
{ enabled: !!propertyName },
|
||||
);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export async function GET(
|
||||
const schema = z.object({
|
||||
startAt: z.coerce.number().int(),
|
||||
endAt: z.coerce.number().int(),
|
||||
selectedPropertyName: z.string().optional(),
|
||||
propertyName: z.string().optional(),
|
||||
...filterParams,
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function GET(
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const { selectedPropertyName, ...rest } = query;
|
||||
const { propertyName, ...rest } = query;
|
||||
const filters = await getQueryFilters(rest, websiteId);
|
||||
const propertyFilters = parsePropertyFilters(query);
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function GET(
|
||||
websiteId,
|
||||
filters,
|
||||
propertyFilters,
|
||||
selectedPropertyName,
|
||||
propertyName,
|
||||
);
|
||||
|
||||
return json(data);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useFilterParameters } from '../useFilterParameters';
|
||||
export function useSessionDataPropertiesQuery(
|
||||
websiteId: string,
|
||||
params?: {
|
||||
selectedPropertyName?: string;
|
||||
propertyName?: string;
|
||||
propertyFilters?: PropertyFilter[];
|
||||
},
|
||||
options?: ReactQueryOptions,
|
||||
@@ -16,14 +16,14 @@ export function useSessionDataPropertiesQuery(
|
||||
const { get, useQuery } = useApi();
|
||||
const { startAt, endAt, unit, timezone } = useDateParameters();
|
||||
const filters = useFilterParameters({ includePagination: false });
|
||||
const { selectedPropertyName, propertyFilters = [] } = params || {};
|
||||
const { propertyName, propertyFilters = [] } = params || {};
|
||||
|
||||
return useQuery<any>({
|
||||
queryKey: [
|
||||
'websites:session-data:properties',
|
||||
{
|
||||
websiteId,
|
||||
selectedPropertyName,
|
||||
propertyName,
|
||||
propertyFilters,
|
||||
startAt,
|
||||
endAt,
|
||||
@@ -38,7 +38,7 @@ export function useSessionDataPropertiesQuery(
|
||||
endAt,
|
||||
unit,
|
||||
timezone,
|
||||
selectedPropertyName,
|
||||
propertyName,
|
||||
...serializePropertyFilters(propertyFilters),
|
||||
...filters,
|
||||
}),
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function getSessionDataProperties(
|
||||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
propertyFilters?: PropertyFilter[],
|
||||
selectedPropertyName?: string,
|
||||
propertyName?: string,
|
||||
]
|
||||
) {
|
||||
return runQuery({
|
||||
@@ -23,7 +23,7 @@ async function relationalQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
propertyFilters: PropertyFilter[] = [],
|
||||
selectedPropertyName?: string,
|
||||
propertyName?: string,
|
||||
) {
|
||||
const { timezone = 'utc' } = filters;
|
||||
const { rawQuery, parseFilters, getPropertyFilterQuery } = prisma;
|
||||
@@ -56,7 +56,7 @@ async function relationalQuery(
|
||||
join filtered_sessions
|
||||
on filtered_sessions.session_id = session_data.session_id
|
||||
and filtered_sessions.website_id = session_data.website_id
|
||||
${selectedPropertyName ? 'where session_data.data_key = {{selectedPropertyName}}' : ''}
|
||||
${propertyName ? 'where session_data.data_key = {{propertyName}}' : ''}
|
||||
)
|
||||
select
|
||||
data_key as "propertyName",
|
||||
@@ -70,7 +70,7 @@ async function relationalQuery(
|
||||
order by 3 desc, 1 asc
|
||||
limit 500
|
||||
`,
|
||||
{ ...queryParams, websiteId, selectedPropertyName, ...pfParams },
|
||||
{ ...queryParams, websiteId, propertyName, ...pfParams },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ async function clickhouseQuery(
|
||||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
propertyFilters: PropertyFilter[] = [],
|
||||
selectedPropertyName?: string,
|
||||
propertyName?: string,
|
||||
): Promise<{ propertyName: string; dataType: number; total: number }[]> {
|
||||
const { timezone = 'UTC' } = filters;
|
||||
const { rawQuery, parseFilters, getPropertyFilterQuery } = clickhouse;
|
||||
@@ -107,7 +107,7 @@ async function clickhouseQuery(
|
||||
join filtered_sessions
|
||||
on filtered_sessions.session_id = session_data.session_id
|
||||
and filtered_sessions.website_id = session_data.website_id
|
||||
${selectedPropertyName ? 'where session_data.data_key = {selectedPropertyName:String}' : ''}
|
||||
${propertyName ? 'where session_data.data_key = {propertyName:String}' : ''}
|
||||
)
|
||||
select
|
||||
data_key as propertyName,
|
||||
@@ -123,7 +123,7 @@ async function clickhouseQuery(
|
||||
order by 3 desc, 1 asc
|
||||
limit 500
|
||||
`,
|
||||
{ ...queryParams, websiteId, selectedPropertyName, ...pfParams },
|
||||
{ ...queryParams, websiteId, propertyName, ...pfParams },
|
||||
FUNCTION_NAME,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user