Skip to content

Commit

Permalink
feat(data-management): add filters to count links (#20498)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Feb 22, 2024
1 parent c88988c commit 27105a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ export function EventDefinitionsTable(): JSX.Element {
to={urls.insightNewHogQL(
'SELECT event, count()\n' +
'FROM events\n' +
'WHERE timestamp > now() - interval 1 month\n' +
'WHERE {filters}\n' +
(filters.event_type === 'event_custom'
? "AND event NOT LIKE '$%'\n"
: filters.event_type === 'event_posthog'
? "AND event LIKE '$%'\n"
: '') +
'GROUP BY event\n' +
'ORDER BY count() DESC'
'ORDER BY count() DESC',
{ dateRange: { date_from: '-24h' } }
)}
>
Click here!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export function PropertyDefinitionsTable(): JSX.Element {
to={urls.insightNewHogQL(
'SELECT arrayJoin(JSONExtractKeys(properties)) AS property_key, count()\n' +
(filters.type === 'person' ? 'FROM persons\n' : 'FROM events\n') +
(filters.type === 'person' ? '' : 'WHERE timestamp > now() - interval 1 month\n') +
(filters.type === 'person' ? '' : 'WHERE {filters}\n') +
'GROUP BY property_key\n' +
'ORDER BY count() DESC'
'ORDER BY count() DESC',
{ dateRange: { date_from: '-24h' } }
)}
>
Click here!
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { combineUrl } from 'kea-router'
import { toParams } from 'lib/utils'

import { ExportOptions } from '~/exporter/types'
import { HogQLFilters } from '~/queries/schema'
import {
ActionType,
AnnotationType,
Expand Down Expand Up @@ -76,14 +77,14 @@ export const urls = {
...(filters ? { filters } : {}),
...(query ? { q: typeof query === 'string' ? query : JSON.stringify(query) } : {}),
}).url,
insightNewHogQL: (query: string): string =>
insightNewHogQL: (query: string, filters?: HogQLFilters): string =>
urls.insightNew(
undefined,
undefined,
JSON.stringify({
kind: 'DataTableNode',
full: true,
source: { kind: 'HogQLQuery', query },
source: { kind: 'HogQLQuery', query, filters },
})
),
insightEdit: (id: InsightShortId): string => `/insights/${id}/edit`,
Expand Down

0 comments on commit 27105a1

Please sign in to comment.