Skip to content

Commit

Permalink
Merge branch 'master' into chore/enable-rn-featureflags
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Dec 22, 2023
2 parents f03597b + 1ba9ba1 commit eabfc98
Show file tree
Hide file tree
Showing 58 changed files with 1,007 additions and 420 deletions.
4 changes: 2 additions & 2 deletions ee/billing/quota_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ def set_org_usage_summary(
new_usage = copy.deepcopy(new_usage)

for field in ["events", "recordings", "rows_synced"]:
resource_usage = new_usage[field] # type: ignore
resource_usage = new_usage.get(field, {"limit": None, "usage": 0, "todays_usage": 0})
if not resource_usage:
continue

if todays_usage:
resource_usage["todays_usage"] = todays_usage[field] # type: ignore
resource_usage["todays_usage"] = todays_usage.get(field, 0)
else:
# TRICKY: If we are not explictly setting todays_usage, we want to reset it to 0 IF the incoming new_usage is different
if (organization.usage or {}).get(field, {}).get("usage") != resource_usage.get("usage"):
Expand Down
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/queries/nodes/DataNode/LoadNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LemonButton } from 'lib/lemon-ui/LemonButton'

import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { DataNode } from '~/queries/schema'
import { isPersonsNode, isPersonsQuery } from '~/queries/utils'
import { isActorsQuery, isPersonsNode } from '~/queries/utils'

interface LoadNextProps {
query: DataNode
Expand All @@ -17,7 +17,7 @@ export function LoadNext({ query }: LoadNextProps): JSX.Element {
<LemonButton onClick={loadNextData} loading={nextDataLoading} fullWidth center disabled={!canLoadNextData}>
Showing {canLoadNextData || numberOfRows === 1 ? '' : 'all '}
{numberOfRows === 1 ? 'one' : numberOfRows}{' '}
{isPersonsNode(query) || isPersonsQuery(query)
{isPersonsNode(query) || isActorsQuery(query)
? numberOfRows === 1
? 'person'
: 'people'
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ import { userLogic } from 'scenes/userLogic'
import { removeExpressionComment } from '~/queries/nodes/DataTable/utils'
import { query } from '~/queries/query'
import {
ActorsQuery,
ActorsQueryResponse,
AnyResponseType,
DataNode,
EventsQuery,
EventsQueryResponse,
InsightVizNode,
NodeKind,
PersonsNode,
PersonsQuery,
PersonsQueryResponse,
QueryResponse,
QueryTiming,
} from '~/queries/schema'
import {
isActorsQuery,
isEventsQuery,
isInsightPersonsQuery,
isInsightActorsQuery,
isInsightQueryNode,
isLifecycleQuery,
isPersonsNode,
isPersonsQuery,
isTrendsQuery,
} from '~/queries/utils'

Expand Down Expand Up @@ -212,7 +212,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
}
// TODO: unify when we use the same backend endpoint for both
const now = performance.now()
if (isEventsQuery(props.query) || isPersonsQuery(props.query)) {
if (isEventsQuery(props.query) || isActorsQuery(props.query)) {
const newResponse = (await query(values.nextQuery)) ?? null
actions.setElapsedTime(performance.now() - now)
const queryResponse = values.response as QueryResponse
Expand Down Expand Up @@ -396,8 +396,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
return null
}

if ((isEventsQuery(query) || isPersonsQuery(query)) && !responseError && !dataLoading) {
if ((response as EventsQueryResponse | PersonsQueryResponse)?.hasMore) {
if ((isEventsQuery(query) || isActorsQuery(query)) && !responseError && !dataLoading) {
if ((response as EventsQueryResponse | ActorsQueryResponse)?.hasMore) {
const sortKey = query.orderBy?.[0] ?? 'timestamp DESC'
const typedResults = (response as QueryResponse)?.results
if (isEventsQuery(query) && sortKey === 'timestamp DESC') {
Expand All @@ -423,7 +423,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
...query,
offset: typedResults?.length || 0,
limit: Math.max(100, Math.min(2 * (typedResults?.length || 100), LOAD_MORE_ROWS_LIMIT)),
} as EventsQuery | PersonsQuery
} as EventsQuery | ActorsQuery
}
}
}
Expand All @@ -446,7 +446,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
backToSourceQuery: [
(s) => [s.query],
(query): InsightVizNode | null => {
if (isPersonsQuery(query) && isInsightPersonsQuery(query.source) && !!query.source.source) {
if (isActorsQuery(query) && isInsightActorsQuery(query.source) && !!query.source.source) {
const insightQuery = query.source.source
const insightVizNode: InsightVizNode = {
kind: NodeKind.InsightVizNode,
Expand Down
21 changes: 10 additions & 11 deletions frontend/src/queries/nodes/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ import { OpenEditorButton } from '~/queries/nodes/Node/OpenEditorButton'
import { PersonPropertyFilters } from '~/queries/nodes/PersonsNode/PersonPropertyFilters'
import { PersonsSearch } from '~/queries/nodes/PersonsNode/PersonsSearch'
import {
ActorsQuery,
AnyResponseType,
DataTableNode,
EventsNode,
EventsQuery,
HogQLQuery,
PersonsNode,
PersonsQuery,
} from '~/queries/schema'
import { QueryContext } from '~/queries/types'
import {
isActorsQuery,
isEventsQuery,
isHogQlAggregation,
isHogQLQuery,
isPersonsQuery,
taxonomicEventFilterToHogQL,
taxonomicPersonFilterToHogQL,
} from '~/queries/utils'
Expand Down Expand Up @@ -138,8 +138,8 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
? columnsInResponse ?? columnsInQuery
: columnsInQuery

const groupTypes = isPersonsQuery(query.source) ? personGroupTypes : eventGroupTypes
const hogQLTable = isPersonsQuery(query.source) ? 'persons' : 'events'
const groupTypes = isActorsQuery(query.source) ? personGroupTypes : eventGroupTypes
const hogQLTable = isActorsQuery(query.source) ? 'persons' : 'events'

const lemonColumns: LemonTableColumn<DataTableRow, any>[] = [
...columnsInLemonTable.map((key, index) => ({
Expand Down Expand Up @@ -182,7 +182,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
type="tertiary"
fullWidth
onChange={(v, g) => {
const hogQl = isPersonsQuery(query.source)
const hogQl = isActorsQuery(query.source)
? taxonomicPersonFilterToHogQL(g, v)
: taxonomicEventFilterToHogQL(g, v)
if (setQuery && hogQl && sourceFeatures.has(QueryFeature.selectAndOrderByColumns)) {
Expand Down Expand Up @@ -263,7 +263,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
type="tertiary"
fullWidth
onChange={(v, g) => {
const hogQl = isPersonsQuery(query.source)
const hogQl = isActorsQuery(query.source)
? taxonomicPersonFilterToHogQL(g, v)
: taxonomicEventFilterToHogQL(g, v)
if (setQuery && hogQl && sourceFeatures.has(QueryFeature.selectAndOrderByColumns)) {
Expand All @@ -277,7 +277,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
select: [...columns.slice(0, index), hogQl, ...columns.slice(index)].filter(
(c) => (isAggregation ? c !== '*' && c !== 'person.$delete' : true)
),
} as EventsQuery | PersonsQuery,
} as EventsQuery | ActorsQuery,
})
}
}}
Expand All @@ -292,7 +292,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
type="tertiary"
fullWidth
onChange={(v, g) => {
const hogQl = isPersonsQuery(query.source)
const hogQl = isActorsQuery(query.source)
? taxonomicPersonFilterToHogQL(g, v)
: taxonomicEventFilterToHogQL(g, v)
if (setQuery && hogQl && sourceFeatures.has(QueryFeature.selectAndOrderByColumns)) {
Expand All @@ -310,7 +310,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
].filter((c) =>
isAggregation ? c !== '*' && c !== 'person.$delete' : true
),
} as EventsQuery | PersonsQuery,
} as EventsQuery | ActorsQuery,
})
}
}}
Expand Down Expand Up @@ -370,8 +370,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
].filter((column) => !query.hiddenColumns?.includes(column.dataIndex) && column.dataIndex !== '*')

const setQuerySource = useCallback(
(source: EventsNode | EventsQuery | PersonsNode | PersonsQuery | HogQLQuery) =>
setQuery?.({ ...query, source }),
(source: EventsNode | EventsQuery | PersonsNode | ActorsQuery | HogQLQuery) => setQuery?.({ ...query, source }),
[setQuery]
)

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/queries/nodes/DataTable/queryFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Node } from '~/queries/schema'
import {
isActorsQuery,
isEventsQuery,
isHogQLQuery,
isPersonsNode,
isPersonsQuery,
isWebOverviewQuery,
isWebStatsTableQuery,
isWebTopClicksQuery,
Expand Down Expand Up @@ -43,11 +43,11 @@ export function getQueryFeatures(query: Node): Set<QueryFeature> {
features.add(QueryFeature.selectAndOrderByColumns)
}

if (isPersonsNode(query) || isPersonsQuery(query)) {
if (isPersonsNode(query) || isActorsQuery(query)) {
features.add(QueryFeature.personPropertyFilters)
features.add(QueryFeature.personsSearch)

if (isPersonsQuery(query)) {
if (isActorsQuery(query)) {
features.add(QueryFeature.selectAndOrderByColumns)
features.add(QueryFeature.columnsInResponse)
features.add(QueryFeature.resultIsArrayOfArrays)
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/queries/nodes/DataTable/renderColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { DeletePersonButton } from '~/queries/nodes/PersonsNode/DeletePersonButt
import { DataTableNode, EventsQueryPersonColumn, HasPropertiesNode } from '~/queries/schema'
import { QueryContext } from '~/queries/types'
import {
isActorsQuery,
isEventsQuery,
isHogQLQuery,
isPersonsNode,
isPersonsQuery,
isTimeToSeeDataSessionsQuery,
trimQuotes,
} from '~/queries/utils'
Expand Down Expand Up @@ -221,22 +221,22 @@ export function renderColumn(
displayProps.href = urls.personByDistinctId(personRecord.distinct_ids[0])
}

if (isPersonsQuery(query.source) && value) {
if (isActorsQuery(query.source) && value) {
displayProps.person = value
displayProps.href = value.id
? urls.personByUUID(value.id)
: urls.personByDistinctId(value.distinct_ids?.[0] ?? '-')
}

return <PersonDisplay {...displayProps} />
} else if (key === 'person.$delete' && (isPersonsNode(query.source) || isPersonsQuery(query.source))) {
} else if (key === 'person.$delete' && (isPersonsNode(query.source) || isActorsQuery(query.source))) {
const personRecord = record as PersonType
return <DeletePersonButton person={personRecord} />
} else if (key.startsWith('context.columns.')) {
const columnName = trimQuotes(key.substring(16)) // 16 = "context.columns.".length
const Component = context?.columns?.[columnName]?.render
return Component ? <Component record={record} columnName={columnName} value={value} query={query} /> : ''
} else if (key === 'id' && (isPersonsNode(query.source) || isPersonsQuery(query.source))) {
} else if (key === 'id' && (isPersonsNode(query.source) || isActorsQuery(query.source))) {
return (
<CopyToClipboardInline
explicitValue={String(value)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/nodes/DataTable/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const defaultDataTableEventColumns: HogQLExpression[] = [
export const defaultDataTablePersonColumns: HogQLExpression[] = ['person', 'id', 'created_at', 'person.$delete']

export function defaultDataTableColumns(kind: NodeKind): HogQLExpression[] {
return kind === NodeKind.PersonsNode || kind === NodeKind.PersonsQuery
return kind === NodeKind.PersonsNode || kind === NodeKind.ActorsQuery
? defaultDataTablePersonColumns
: kind === NodeKind.EventsQuery
? defaultDataTableEventColumns
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/queries/nodes/PersonsNode/PersonPropertyFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { useState } from 'react'

import { PersonsNode, PersonsQuery } from '~/queries/schema'
import { isPersonsQuery } from '~/queries/utils'
import { ActorsQuery, PersonsNode } from '~/queries/schema'
import { isActorsQuery } from '~/queries/utils'
import { PersonPropertyFilter } from '~/types'

interface PersonPropertyFiltersProps {
query: PersonsNode | PersonsQuery
setQuery?: (query: PersonsNode | PersonsQuery) => void
query: PersonsNode | ActorsQuery
setQuery?: (query: PersonsNode | ActorsQuery) => void
}

let uniqueNode = 0
Expand All @@ -25,7 +25,7 @@ export function PersonPropertyFilters({ query, setQuery }: PersonPropertyFilters
}}
pageKey={`PersonPropertyFilters.${id}`}
taxonomicGroupTypes={
isPersonsQuery(query)
isActorsQuery(query)
? [
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.Cohorts,
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/queries/nodes/PersonsNode/PersonsSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
import { Tooltip } from 'lib/lemon-ui/Tooltip'

import { useDebouncedQuery } from '~/queries/hooks/useDebouncedQuery'
import { PersonsNode, PersonsQuery } from '~/queries/schema'
import { ActorsQuery, PersonsNode } from '~/queries/schema'
import { isQueryForGroup } from '~/queries/utils'

type ActorType = 'person' | 'group'
interface PersonSearchProps {
query: PersonsNode | PersonsQuery
setQuery?: (query: PersonsNode | PersonsQuery) => void
query: PersonsNode | ActorsQuery
setQuery?: (query: PersonsNode | ActorsQuery) => void
}

interface LabelType {
Expand All @@ -31,7 +31,7 @@ const labels: Record<ActorType, LabelType> = {
}

export function PersonsSearch({ query, setQuery }: PersonSearchProps): JSX.Element {
const { value, onChange } = useDebouncedQuery<PersonsNode | PersonsQuery, string>(
const { value, onChange } = useDebouncedQuery<PersonsNode | ActorsQuery, string>(
query,
setQuery,
(query) => query.search || '',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { AnyPartialFilterType, OnlineExportContext, QueryExportContext } from '~
import { queryNodeToFilter } from './nodes/InsightQuery/utils/queryNodeToFilter'
import { DataNode, HogQLQuery, HogQLQueryResponse, NodeKind, PersonsNode } from './schema'
import {
isActorsQuery,
isDataTableNode,
isDataVisualizationNode,
isEventsQuery,
Expand All @@ -29,7 +30,6 @@ import {
isInsightVizNode,
isLifecycleQuery,
isPersonsNode,
isPersonsQuery,
isRetentionQuery,
isTimeToSeeDataQuery,
isTimeToSeeDataSessionsNode,
Expand All @@ -52,7 +52,7 @@ export function queryExportContext<N extends DataNode = DataNode>(
return queryExportContext(query.source, methodOptions, refresh)
} else if (isDataVisualizationNode(query)) {
return queryExportContext(query.source, methodOptions, refresh)
} else if (isEventsQuery(query) || isPersonsQuery(query)) {
} else if (isEventsQuery(query) || isActorsQuery(query)) {
return {
source: query,
}
Expand Down
Loading

0 comments on commit eabfc98

Please sign in to comment.