Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytic events for time-over-time comparison #43589

Merged
merged 152 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
ab9ce2b
Sort functions
kamilmielnik May 23, 2024
edea336
Add boilerplate for aggregateOffset and tests
kamilmielnik May 23, 2024
03aceaf
Simplify assertion
kamilmielnik May 23, 2024
40a4a0d
Make basic case work
kamilmielnik May 23, 2024
78b746e
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 24, 2024
1e59082
Handle name generation
kamilmielnik May 24, 2024
bfdf5a7
Do not require "lib/uuid" attribute to be present since MLv2 will nor…
kamilmielnik May 24, 2024
19d88b3
Fix typing
kamilmielnik May 24, 2024
6cd3161
Group tests
kamilmielnik May 24, 2024
42bf50e
Refactor offsetClause to return a new clause instead of a new query
kamilmielnik May 24, 2024
ac5c9e0
Revert "Sort functions"
kamilmielnik May 24, 2024
e9140c0
Move tests
kamilmielnik May 24, 2024
85474a1
Handle names dynamically
kamilmielnik May 24, 2024
37b76aa
Shorten a test
kamilmielnik May 24, 2024
9a28136
Update comment
kamilmielnik May 24, 2024
4c47913
Add TODO
kamilmielnik May 24, 2024
caf9fc4
Update expression types
kamilmielnik May 24, 2024
d81bb77
Add diffOffsetClause & percentDiffOffsetClause
kamilmielnik May 24, 2024
e7af622
Add a test for diffOffsetClause
kamilmielnik May 24, 2024
8a160cb
Add TODOs
kamilmielnik May 24, 2024
6619d8d
Add tests for diffOffsetClause and percentDiffOffsetClause
kamilmielnik May 24, 2024
a6d9d4a
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 27, 2024
126a8e5
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 27, 2024
b7a586f
Unwrap tests
kamilmielnik May 27, 2024
0fffac3
Add skeleton for new tests
kamilmielnik May 27, 2024
2357c15
Refactor first offsetClause tests
kamilmielnik May 27, 2024
2e42403
Add tests for names
kamilmielnik May 27, 2024
0cb5ab4
Fix case of non-datetime columns
kamilmielnik May 27, 2024
f51a49d
Handle a case with offset < 1 and no breakouts
kamilmielnik May 27, 2024
ae25a8f
Handle a case with offset < 1 and breakouts on non-datetime column
kamilmielnik May 27, 2024
df99038
Handle a case with offset < 1 and breakouts binned datetime column
kamilmielnik May 27, 2024
a8aab2f
Handle a case with offset < 1 and breakout on non-binned datetime column
kamilmielnik May 27, 2024
b4067ac
Refactor
kamilmielnik May 27, 2024
ebc84c5
Refactor
kamilmielnik May 27, 2024
de4f5cf
Remove TODO
kamilmielnik May 27, 2024
af368b3
Add tests for diffOffsetClause
kamilmielnik May 27, 2024
907d1b1
Add tests for percentDiffOffsetClause
kamilmielnik May 27, 2024
e44588e
Move offset stuff to offset.ts and offset.unit.spec.ts
kamilmielnik May 27, 2024
2819414
Use template string for prefixes
kamilmielnik May 27, 2024
a457f8a
Use breakoutColumn + isDate to check column type
kamilmielnik May 27, 2024
c5e9869
Refactor
kamilmielnik May 27, 2024
ff8f068
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 27, 2024
398f32c
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 28, 2024
73f5334
Fix error message
kamilmielnik May 28, 2024
e545f24
Add boilerplate for CompareAggregations
kamilmielnik May 28, 2024
0346ef4
Fix title
kamilmielnik May 28, 2024
4579946
Render aggregations list
kamilmielnik May 28, 2024
f638752
Style AccordionList
kamilmielnik May 28, 2024
1bec0d3
Sort props
kamilmielnik May 28, 2024
054c473
Fix bucket name
kamilmielnik May 29, 2024
209fa5e
Use displayName instead shortName
kamilmielnik May 29, 2024
2fa0b0e
Merge branch 'master' into 43079-aggregation-helpers
kamilmielnik May 29, 2024
3af3e19
Merge branch '43079-aggregation-helpers' into 43070-previous-period-n…
kamilmielnik May 29, 2024
4fe7af6
Support parseValue prop in NumberInput
kamilmielnik May 29, 2024
cdec2b5
Add period input accepting integers only
kamilmielnik May 29, 2024
bca9bfb
Accept non-negative values only
kamilmielnik May 29, 2024
78d60fd
Do not accept zeros
kamilmielnik May 29, 2024
1d2fedd
Add state
kamilmielnik May 29, 2024
2dd85d4
Add submit button
kamilmielnik May 29, 2024
f1c3c28
Export offset functions via Lib
kamilmielnik May 29, 2024
113eeaf
Make it possible to skip rightSection
kamilmielnik May 29, 2024
0e58d2a
Add column picker
kamilmielnik May 29, 2024
f838909
Map offset user input to api input (negative value)
kamilmielnik May 29, 2024
2cf7983
Add label
kamilmielnik May 29, 2024
ad6229d
Fix crash
kamilmielnik May 29, 2024
1c5bfad
Extract shouldCreate
kamilmielnik May 29, 2024
730b70d
Make onSelect in AggregationPicker support multiple values
kamilmielnik May 29, 2024
2793dc7
Extract ReferenceAggregationPicker
kamilmielnik May 29, 2024
836a046
Extract ColumnPicker
kamilmielnik May 29, 2024
39b96e1
Extract getAggregations
kamilmielnik May 29, 2024
86b6875
Rename
kamilmielnik May 29, 2024
c6bd669
Add custom items
kamilmielnik May 29, 2024
cd3631f
Refactor item component
kamilmielnik May 29, 2024
fa65e7e
Extract OffsetInput
kamilmielnik May 29, 2024
0f49dc2
Remove unused data-testid
kamilmielnik May 29, 2024
ba99523
Style OffsetInput
kamilmielnik May 29, 2024
112274d
Generate titles according to specs
kamilmielnik May 29, 2024
9a22522
Generate label
kamilmielnik May 29, 2024
ed16848
Generate help
kamilmielnik May 29, 2024
80084df
Extract utils
kamilmielnik May 29, 2024
d829629
Use different width for the 1st step
kamilmielnik May 29, 2024
442a2c5
Merge branch 'master' into 43070-previous-period-notebook
kamilmielnik May 29, 2024
e57a275
Format code
kamilmielnik May 29, 2024
a519f5f
Merge branch 'master' into 43070-previous-period-notebook
kamilmielnik May 31, 2024
71e18de
Use MultiSelect directly
kamilmielnik May 31, 2024
3b0c5d0
Avoid custom parseValue
kamilmielnik May 31, 2024
93dd90c
Revert MultiaAutocomplete changes
kamilmielnik May 31, 2024
4e7d2ef
Improve typing in describeTemporalInterval and
kamilmielnik May 31, 2024
42397d0
Use describeTemporalUnit to pluralize
kamilmielnik May 31, 2024
8fda365
Use interface
kamilmielnik May 31, 2024
a5de0e3
Avoid setting value as DOM attribute
kamilmielnik May 31, 2024
082e8f9
Fix test
kamilmielnik May 31, 2024
07e0153
Add onAdd prop to AggregationPicker and revert the change to have onS…
kamilmielnik May 31, 2024
daec4e5
Reduce number of props
kamilmielnik May 31, 2024
c47821f
Merge branch 'master' into 43070-previous-period-notebook
kamilmielnik Jun 3, 2024
2fb8b1d
Render checkboxes in custom items
kamilmielnik Jun 3, 2024
20a507d
Introduce and use --mb-color-brand-lighter
kamilmielnik Jun 3, 2024
0b336ef
Avoid !important
kamilmielnik Jun 3, 2024
42fa59b
Remove redundant prop
kamilmielnik Jun 3, 2024
f1e003b
Rename ExtractColumn to ExtractColumnAction
kamilmielnik Jun 3, 2024
6eff21a
Add lines.svg
kamilmielnik Jun 3, 2024
edd529a
Fix positioning in case dir attribute is not present in any parent co…
kamilmielnik Jun 3, 2024
b880424
Add CompareAggregationsAction
kamilmielnik Jun 3, 2024
04ce10f
Fix warning about isSelected being used as DOM attribute
kamilmielnik Jun 3, 2024
25701f4
Fix positioning in case dir attribute is not present in any parent co…
kamilmielnik Jun 3, 2024
3d48151
Merge branch '43070-previous-period-notebook' into 43178-previous-per…
kamilmielnik Jun 3, 2024
639d9aa
Remove redundant Box
kamilmielnik Jun 3, 2024
abc8a65
Compute the title
kamilmielnik Jun 3, 2024
a040f26
Add compareAggregationsDrill boilerplate
kamilmielnik Jun 3, 2024
c153230
Add compare-aggregations drill stub
kamilmielnik Jun 3, 2024
b3c50fd
Update comment
kamilmielnik Jun 3, 2024
1f6588f
Compute title and aggregation
kamilmielnik Jun 3, 2024
d9c2d88
Add TODO
kamilmielnik Jun 3, 2024
e8a2c68
Use proper title when there's only 1 aggregation
kamilmielnik Jun 3, 2024
b96f8b8
Show visualization on submit
kamilmielnik Jun 3, 2024
1e2f106
Merge branch '43178-previous-period-plus-button' into 43071-previous-…
kamilmielnik Jun 3, 2024
d8f7f74
Limit aggregation choice to 1 in compare aggregations drill
kamilmielnik Jun 3, 2024
0a43961
Redirect to chart upon submission
kamilmielnik Jun 3, 2024
5cbb643
Do not navigate to chart view
kamilmielnik Jun 3, 2024
099cd68
Do not navigate to chart view
kamilmielnik Jun 3, 2024
94c88e0
Merge branch '43178-previous-period-plus-button' into 43071-previous-…
kamilmielnik Jun 3, 2024
7333059
Make drill-thru tests expect the new compare-aggregations drill
bshepherdson Jun 3, 2024
51e0023
Add type attribute to all ListItems
kamilmielnik Jun 4, 2024
3d14ec1
Merge branch 'master' into 43070-previous-period-notebook
kamilmielnik Jun 4, 2024
2e173a4
Merge branch '43070-previous-period-notebook' into 43178-previous-per…
kamilmielnik Jun 4, 2024
6f1b698
Merge branch '43178-previous-period-plus-button' into 43071-previous-…
kamilmielnik Jun 4, 2024
3c9bc73
Merge branch 'master' into 43178-previous-period-plus-button
kamilmielnik Jun 4, 2024
fb45b4d
Merge branch '43178-previous-period-plus-button' into 43071-previous-…
kamilmielnik Jun 4, 2024
7db467d
Merge branch 'master' into 43071-previous-period-column-headers
kamilmielnik Jun 4, 2024
f88a555
Add aggregationIndex to drillInfo
kamilmielnik Jun 4, 2024
d012855
Add aggregationDrillDetails and wire it up
bshepherdson Jun 4, 2024
0a83beb
Add tracking helpers
kamilmielnik Jun 4, 2024
3b56cf5
Add new schema
kamilmielnik Jun 4, 2024
06edab7
Add tracking in column header
kamilmielnik Jun 4, 2024
030a8ed
Add tracking in plus modal
kamilmielnik Jun 4, 2024
9f5d00a
Add tracking in aggregation picker
kamilmielnik Jun 4, 2024
d7abad6
Fix destructuring
kamilmielnik Jun 4, 2024
309bf21
Add functionsUsedByExpression
kamilmielnik Jun 4, 2024
c2dee9e
Merge branch '43071-previous-period-column-headers' into 43072-analyt…
kamilmielnik Jun 4, 2024
11f823f
Fix schema number
kamilmielnik Jun 4, 2024
1eb55d3
Merge branch 'master' into 43071-previous-period-column-headers
kamilmielnik Jun 5, 2024
7bb1091
Merge branch '43071-previous-period-column-headers' into 43072-analyt…
kamilmielnik Jun 5, 2024
d387269
Add tests boilerplate
kamilmielnik Jun 5, 2024
77cd3bb
Implement test for notebook editor
kamilmielnik Jun 5, 2024
66326bb
Add test for column header
kamilmielnik Jun 5, 2024
b999379
Add a test for summarize sidebar
kamilmielnik Jun 5, 2024
513b6f3
Add a test for the plus button
kamilmielnik Jun 5, 2024
95d53ef
Add expectNoBadSnowplowEvents call in afterEach
kamilmielnik Jun 5, 2024
34c914e
Format code
kamilmielnik Jun 5, 2024
865d3c1
Merge branch 'master' into 43072-analytic-events
kamilmielnik Jun 6, 2024
f35a0a5
Merge branch 'master' into 43072-analytic-events
kamilmielnik Jun 6, 2024
3d229c1
Add missing redux store state in tests
kamilmielnik Jun 6, 2024
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
Prev Previous commit
Next Next commit
Refactor offsetClause to return a new clause instead of a new query
- Move offsetClause to expressions.ts
- Add assertion
  • Loading branch information
kamilmielnik committed May 24, 2024
commit 42bf50e48cb8be246ba27b0cf579671f916c7c42
22 changes: 0 additions & 22 deletions frontend/src/metabase-lib/aggregation.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { t } from "ttag";

import * as ML from "cljs/metabase.lib.js";

import { expressionClause } from "./expression";
import { displayInfo } from "./metadata";
import type {
Aggregable,
AggregationClause,
AggregationOperator,
ColumnMetadata,
ExpressionClause,
FilterClause,
Query,
} from "./types";

Expand Down Expand Up @@ -79,20 +74,3 @@ export function aggregateByCount(query: Query): Query {
const aggregation = aggregationClause(countOperator);
return aggregate(query, stageIndex, aggregation);
}

// TODO: move to different file
export function offsetClause(
query: Query,
stageIndex: number,
clause: AggregationClause | ExpressionClause | FilterClause,
offset: number,
): Query {
const { displayName } = displayInfo(query, stageIndex, clause);
const newName = t`${displayName} (previous period)`;
const newClause = expressionClause("offset", [clause, offset], {
name: newName,
"display-name": newName,
});

return aggregate(query, stageIndex, newClause);
}
21 changes: 16 additions & 5 deletions frontend/src/metabase-lib/aggregation.unit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ORDERS_ID } from "metabase-types/api/mocks/presets";

import { offsetClause, aggregations } from "./aggregation";
import { aggregate, aggregations } from "./aggregation";
import { offsetClause } from "./expression";
import { displayInfo } from "./metadata";
import { toLegacyQuery } from "./query";
import { SAMPLE_DATABASE, createQueryWithClauses } from "./test-helpers";

Expand All @@ -14,13 +16,22 @@ describe("aggregation", () => {
aggregations: [{ operatorName: "count" }],
});
const [aggregationClause] = aggregations(query, stageIndex);

const finalQuery = offsetClause(
const ofsettedClause = offsetClause(
query,
stageIndex,
aggregationClause,
offset,
);
const finalQuery = aggregate(query, stageIndex, ofsettedClause);
const expectedOffsettedClauseName = "Count (previous period)";

expect(displayInfo(finalQuery, stageIndex, ofsettedClause)).toEqual({
displayName: expectedOffsettedClauseName,
effectiveType: "type/Integer",
isNamed: true,
longDisplayName: expectedOffsettedClauseName,
name: expectedOffsettedClauseName,
});

expect(toLegacyQuery(finalQuery)).toMatchObject({
database: SAMPLE_DATABASE.id,
Expand All @@ -30,8 +41,8 @@ describe("aggregation", () => {
[
"offset",
{
name: "Count (previous period)",
"display-name": "Count (previous period)",
name: expectedOffsettedClauseName,
"display-name": expectedOffsettedClauseName,
},
["count"],
offset,
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/metabase-lib/expression.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { t } from "ttag";

import * as ML from "cljs/metabase.lib.js";

import { displayInfo } from "./metadata";
import type {
AggregationClause,
ColumnMetadata,
Expand Down Expand Up @@ -100,3 +103,18 @@ export function diagnoseExpression(
expressionPosition,
);
}

export function offsetClause(
query: Query,
stageIndex: number,
clause: AggregationClause | ExpressionClause,
offset: number,
): ExpressionClause {
const { displayName } = displayInfo(query, stageIndex, clause);
const newName = t`${displayName} (previous period)`;
const newClause = expressionClause("offset", [clause, offset], {
name: newName,
"display-name": newName,
});
return newClause;
}
Loading