Skip to content

Commit

Permalink
Merge branch 'master' into fix-icon-opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Jul 26, 2024
2 parents c018336 + c261e15 commit ccf5520
Show file tree
Hide file tree
Showing 112 changed files with 2,687 additions and 2,853 deletions.
8 changes: 0 additions & 8 deletions bin/start-frontend-https

This file was deleted.

12 changes: 0 additions & 12 deletions bin/start-https

This file was deleted.

1 change: 0 additions & 1 deletion ee/clickhouse/materialized_columns/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def get_materialized_columns(
WHERE database = %(database)s
AND table = %(table)s
AND comment LIKE '%%column_materializer::%%'
AND comment not LIKE '%%column_materializer::elements_chain::%%'
""",
{"database": CLICKHOUSE_DATABASE, "table": table},
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,8 @@ const api = {
},

hogFunctions: {
async list(): Promise<PaginatedResponse<HogFunctionType>> {
return await new ApiRequest().hogFunctions().get()
async list(params?: { filters?: any }): Promise<PaginatedResponse<HogFunctionType>> {
return await new ApiRequest().hogFunctions().withQueryString(params).get()
},
async get(id: HogFunctionType['id']): Promise<HogFunctionType> {
return await new ApiRequest().hogFunction(id).get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
key(keyForInsightLogicProps('new')),
path((key) => ['lib', 'components', 'AddToDashboard', 'saveToDashboardModalLogic', key]),
connect((props: InsightLogicProps) => ({
values: [insightLogic(props), ['queryBasedInsight', 'legacyInsight']],
values: [insightLogic(props), ['queryBasedInsight']],
actions: [
insightLogic(props),
['updateInsight', 'updateInsightSuccess', 'updateInsightFailure'],
Expand Down Expand Up @@ -101,7 +101,9 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
// TODO be able to update not by patching `dashboards` against insight
// either patch dashboard_tiles on the insight or add a dashboard_tiles API
actions.updateInsight(
{ ...values.legacyInsight, dashboards: [...(values.legacyInsight.dashboards || []), dashboardId] },
{
dashboards: [...(values.queryBasedInsight.dashboards || []), dashboardId],
},
() => {
actions.reportSavedInsightToDashboard()
dashboardsModel.actions.tileAddedToDashboard(dashboardId)
Expand All @@ -117,9 +119,8 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
removeFromDashboard: async ({ dashboardId }): Promise<void> => {
actions.updateInsight(
{
...values.legacyInsight,
dashboards: (values.legacyInsight.dashboards || []).filter((d) => d !== dashboardId),
dashboard_tiles: (values.legacyInsight.dashboard_tiles || []).filter(
dashboards: (values.queryBasedInsight.dashboards || []).filter((d) => d !== dashboardId),
dashboard_tiles: (values.queryBasedInsight.dashboard_tiles || []).filter(
(dt) => dt.dashboard_id !== dashboardId
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const makeTextTile = (body: string, color: InsightColor | null = null): Dashboar

layouts: {},
color,
last_refresh: null,
next_allowed_client_refresh: null,
}
}

Expand Down
20 changes: 2 additions & 18 deletions frontend/src/models/dashboardsModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,10 @@ export const dashboardsModel = kea<dashboardsModelType>([
// can provide extra dashboard ids if not all listeners will choose to respond to this action
// not providing a dashboard id is a signal that only listeners in the item.dashboards array should respond
// specifying `number` not `Pick<DashboardType, 'id'> because kea typegen couldn't figure out the import in `savedInsightsLogic`
// if an update is made against an insight it will hold last_refresh, color, and filters_hash in dashboard context
updateDashboardInsight: (
insight: InsightModel,
extraDashboardIds?: number[],
updateTileOnDashboards?: [number]
) => ({
// if an update is made against an insight it will hold color in dashboard context
updateDashboardInsight: (insight: InsightModel, extraDashboardIds?: number[]) => ({
insight,
extraDashboardIds,
updateTileOnDashboards,
}),
// a side effect on this action exists in dashboardLogic so that individual refresh statuses can be bubbled up
// to dashboard items in dashboards
updateDashboardRefreshStatus: (
shortId: string | undefined | null,
refreshing: boolean | null,
last_refresh: string | null
) => ({
shortId,
refreshing,
last_refresh,
}),
pinDashboard: (id: number, source: DashboardEventSource) => ({ id, source }),
unpinDashboard: (id: number, source: DashboardEventSource) => ({ id, source }),
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/queries/nodes/HogQLX/render.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Link } from '@posthog/lemon-ui'
import { JSONViewer } from 'lib/components/JSONViewer'
import { Sparkline } from 'lib/components/Sparkline'

Expand Down Expand Up @@ -37,6 +38,29 @@ export function renderHogQLX(value: any): JSX.Element {
<Sparkline {...props} data={data ?? []} type={type} />
</ErrorBoundary>
)
} else if (tag === 'a') {
const { href, source, target } = rest
return (
<ErrorBoundary>
<Link to={href} target={target ?? '_self'}>
{source ? renderHogQLX(source) : href}
</Link>
</ErrorBoundary>
)
} else if (tag === 'strong') {
const { source } = rest
return (
<ErrorBoundary>
<strong>{renderHogQLX(source)}</strong>
</ErrorBoundary>
)
} else if (tag === 'em') {
const { source } = rest
return (
<ErrorBoundary>
<em>{renderHogQLX(source)}</em>
</ErrorBoundary>
)
}
return <div>Unknown tag: {String(tag)}</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,112 @@ describe('filtersToQueryNode', () => {
}
expect(result).toEqual(query)
})

it('converts multiple breakdowns', () => {
const filters: Partial<TrendsFilterType> = {
insight: InsightType.TRENDS,
breakdowns: [
{
type: 'event',
property: '$pathname',
normalize_url: true,
},
{
type: 'group',
property: '$num',
group_type_index: 0,
histogram_bin_count: 10,
},
],
}

const result = filtersToQueryNode(filters)

const query: TrendsQuery = {
kind: NodeKind.TrendsQuery,
breakdownFilter: {
breakdowns: [
{
type: 'event',
property: '$pathname',
normalize_url: true,
},
{
type: 'group',
property: '$num',
group_type_index: 0,
histogram_bin_count: 10,
},
],
},
series: [],
}
expect(result).toEqual(query)
})

it('converts legacy funnel breakdowns', () => {
const filters: Partial<TrendsFilterType> = {
insight: InsightType.TRENDS,
breakdowns: [
{
type: 'event',
property: '$current_url',
},
{
property: '$pathname',
} as any,
],
}

const result = filtersToQueryNode(filters)

const query: TrendsQuery = {
kind: NodeKind.TrendsQuery,
breakdownFilter: {
breakdowns: [
{
type: 'event',
property: '$current_url',
},
{
type: 'event',
property: '$pathname',
},
],
},
series: [],
}
expect(result).toEqual(query)
})

it('does not add breakdown_type for multiple breakdowns', () => {
const filters: Partial<TrendsFilterType> = {
insight: InsightType.TRENDS,
breakdowns: [
{
type: 'person',
property: '$browser',
},
],
}

const result = filtersToQueryNode(filters)

const query: TrendsQuery = {
kind: NodeKind.TrendsQuery,
breakdownFilter: {
breakdowns: [
{
type: 'person',
property: '$browser',
},
],
breakdown_type: undefined,
},
series: [],
}
expect(result).toEqual(query)
})
})

describe('funnels filter', () => {
Expand Down
36 changes: 24 additions & 12 deletions frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,34 @@ export const filtersToQueryNode = (filters: Partial<FilterType>): InsightQueryNo

// breakdown
if (isInsightQueryWithBreakdown(query)) {
/* handle multi-breakdowns */
// not undefined or null
if (filters.breakdowns != null) {
if (filters.breakdowns.length === 1) {
filters.breakdown_type = filters.breakdowns[0].type
filters.breakdown = filters.breakdowns[0].property as string
} else {
captureException(
'Could not convert multi-breakdown property `breakdowns` - found more than one breakdown'
)
/* handle multi-breakdowns for funnels */
if (isFunnelsFilter(filters)) {
if (filters.breakdowns.length === 1) {
filters.breakdown_type = filters.breakdowns[0].type || 'event'
filters.breakdown = filters.breakdowns[0].property as string
} else {
captureException(
'Could not convert multi-breakdown property `breakdowns` - found more than one breakdown'
)
}
}
}

/* handle missing breakdown_type */
// check for undefined and null values
if (filters.breakdown != null && filters.breakdown_type == null) {
/* handle multi-breakdowns for trends */
if (isTrendsFilter(filters)) {
filters.breakdowns = filters.breakdowns.map((b) => ({
...b,
// Compatibility with legacy funnel breakdowns when someone switches a view from funnels to trends
type: b.type || filters.breakdown_type || 'event',
}))
}
} else if (
/* handle missing breakdown_type */
// check for undefined and null values
filters.breakdown != null &&
filters.breakdown_type == null
) {
filters.breakdown_type = 'event'
}

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7669,6 +7669,7 @@
"type": "integer"
},
"end_time": {
"description": "When did the query execution task finish (whether successfully or not).",
"format": "date-time",
"type": "string"
},
Expand Down Expand Up @@ -7697,6 +7698,11 @@
},
"type": "array"
},
"pickup_time": {
"description": "When was the query execution task picked up by a worker.",
"format": "date-time",
"type": "string"
},
"query_async": {
"const": true,
"default": true,
Expand All @@ -7708,6 +7714,7 @@
},
"results": {},
"start_time": {
"description": "When was query execution task enqueued.",
"format": "date-time",
"type": "string"
},
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,11 @@ export type QueryStatus = {
/** @default null */
error_message: string | null
results?: any
/** @format date-time */
/** When was the query execution task picked up by a worker. @format date-time */
pickup_time?: string
/** When was query execution task enqueued. @format date-time */
start_time?: string
/** @format date-time */
/** When did the query execution task finish (whether successfully or not). @format date-time */
end_time?: string
/** @format date-time */
expiration_time?: string
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/actions/Action.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const meta: Meta = {
get: {
'/api/projects/:team_id/actions/': toPaginatedResponse([MOCK_ACTION]),
'/api/projects/:team_id/actions/1/': MOCK_ACTION,
'/api/projects/:team_id/actions/1/plugin_configs': toPaginatedResponse([]),
},
}),
],
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/actions/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NodeKind } from '~/queries/schema'
import { ActionType } from '~/types'

import { ActionEdit } from './ActionEdit'
import { ActionHogFunctions } from './ActionHogFunctions'

export const scene: SceneExport = {
logic: actionLogic,
Expand Down Expand Up @@ -44,6 +45,7 @@ export function Action({ id }: { id?: ActionType['id'] } = {}): JSX.Element {
return (
<>
<ActionEdit id={id} action={action} />
<ActionHogFunctions />
{id && (
<>
{isComplete ? (
Expand Down
Loading

0 comments on commit ccf5520

Please sign in to comment.