Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/PlaygroundFilterGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FilterGroup: FC<FilterGroupProps> = ({
<Space key={m.index} size={10} align="center">
<PlaygroundFilterSelect
availableMembers={availableMembers}
value={t(m.dimension!.title)}
value={m.dimension?.name}
onChange={(dimension) => {
trackEvent("Update Member", { memberName: addMemberName });
if (dimension) updateMethods.update(m, { ...m, dimension });
Expand All @@ -54,7 +54,7 @@ const FilterGroup: FC<FilterGroupProps> = ({
</Select>
<FilterInput
member={m}
key="filterInput"
key={`${m.index}-${m.dimension?.name}-${m.operator}`}
updateMethods={updateMethods}
addMemberName={addMemberName}
/>
Expand Down
13 changes: 13 additions & 0 deletions src/components/PlaygroundFilterInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ const filterInputs = {
value={(values && values[0]) || ""}
/>
),
boolean: ({ values, onChange }: PlaygroundFilterInputProps) => (
<Select
size="large"
key="input"
style={{ width: 300 }}
value={values?.[0] ?? "true"}
onChange={(value) => onChange([value])}
options={[
{ label: "True", value: "true" },
{ label: "False", value: "false" },
]}
/>
),
time: ({ values, onChange }: PlaygroundFilterInputProps) => (
<DatePicker
size="large"
Expand Down
12 changes: 9 additions & 3 deletions src/hooks/useAnalyticsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const defaultFilterValues = {
number: {
operator: "set",
},
boolean: {
operator: "equals",
values: ["true"],
},
};

interface Action {
Expand Down Expand Up @@ -68,11 +72,13 @@ const reducer: Reducer<PlaygroundState, Action> = (
return state;
}
} else {
const filterDefaults =
defaultFilterValues[
action.operatorType as keyof typeof defaultFilterValues
] ?? defaultFilterValues.string;
value = {
...action.value,
...defaultFilterValues[
action.operatorType as keyof typeof defaultFilterValues
],
...filterDefaults,
};
}

Expand Down
20 changes: 17 additions & 3 deletions src/hooks/useDataSourcesMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ const operators = {
{ name: "set", title: "is set" },
{ name: "notSet", title: "is not set" },
],
boolean: [
{ name: "equals", title: "equals" },
{ name: "notEquals", title: "does not equal" },
{ name: "set", title: "is set" },
{ name: "notSet", title: "is not set" },
],
geo: [
{ name: "contains", title: "contains" },
{ name: "notContains", title: "does not contain" },
{ name: "equals", title: "equals" },
{ name: "notEquals", title: "does not equal" },
{ name: "set", title: "is set" },
{ name: "notSet", title: "is not set" },
],
};

export const granularities = [
Expand Down Expand Up @@ -99,9 +113,9 @@ class Meta {

filterOperatorsForMember(memberName: string, memberType: string | string[]) {
const member = this.resolveMember(memberName, memberType);
return "type" in member
? operators[member.type as keyof typeof operators]
: operators.string;
if (!("type" in member)) return operators.string;
const key = member.type as keyof typeof operators;
return operators[key] ?? operators.string;
}
}

Expand Down