@altertable/data-app-examples 0.77.0 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/templates/starter-data-app/index.tsx +76 -138
- package/templates/starter-finding-data-app/index.tsx +379 -117
- package/templates/starter-local-data-app/AGENTS.md +9 -9
- package/templates/starter-local-data-app/README.md +11 -5
- package/templates/starter-local-data-app/app.ts +25 -21
- package/templates/starter-local-data-app/package.json +5 -5
- package/templates/starter-local-data-app/src/App.tsx +54 -4
- package/templates/starter-local-data-app/src/data-context.ts +8 -13
- package/templates/starter-local-data-app/src/filters.ts +14 -0
- package/templates/starter-local-data-app/src/main.tsx +3 -3
- package/templates/starter-local-data-app/src/operations.ts +14 -5
- package/templates/starter-local-data-app/src/server.ts +1 -2
- package/templates/starter-local-finding-data-app/AGENTS.md +1 -1
- package/templates/starter-local-finding-data-app/README.md +3 -4
- package/templates/starter-local-finding-data-app/app.ts +29 -11
- package/templates/starter-local-finding-data-app/package.json +5 -5
- package/templates/starter-local-finding-data-app/src/App.tsx +237 -56
- package/templates/starter-local-finding-data-app/src/data-context.ts +14 -11
- package/templates/starter-local-finding-data-app/src/filters.ts +29 -11
- package/templates/starter-local-finding-data-app/src/main.tsx +3 -3
- package/templates/starter-local-finding-data-app/src/operations.ts +80 -34
- package/templates/starter-local-finding-data-app/src/server.ts +4 -2
- package/templates/starter-local-metric-data-app/AGENTS.md +1 -1
- package/templates/starter-local-metric-data-app/README.md +3 -4
- package/templates/starter-local-metric-data-app/app.ts +9 -6
- package/templates/starter-local-metric-data-app/package.json +5 -5
- package/templates/starter-local-metric-data-app/src/App.tsx +25 -30
- package/templates/starter-local-metric-data-app/src/data-context.ts +9 -9
- package/templates/starter-local-metric-data-app/src/filters.ts +2 -3
- package/templates/starter-local-metric-data-app/src/main.tsx +3 -3
- package/templates/starter-local-metric-data-app/src/operations.ts +6 -14
- package/templates/starter-local-metric-data-app/src/server.ts +4 -2
- package/templates/starter-metric-data-app/index.tsx +49 -63
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Read `node_modules/@altertable/data-app/docs/app-authoring.md` and use this project
|
|
4
4
|
as the selected scaffold. If dependencies are unavailable, read the
|
|
5
|
-
[version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.
|
|
5
|
+
[version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->
|
|
6
6
|
|
|
7
|
-
| Task | App-owned files
|
|
8
|
-
| ------------------------------------------ |
|
|
9
|
-
| Define queries, filters, and operations | `app.ts`, `src/
|
|
10
|
-
| Compose app content and supported features | `src/App.tsx`
|
|
11
|
-
| Bind definitions and source evidence | `src/data-context.ts`
|
|
12
|
-
| Change identity and appearance | `app.ts`
|
|
13
|
-
| Inject styles and mount React | `src/main.tsx`
|
|
14
|
-
| Configure local serving | `src/server.ts`
|
|
7
|
+
| Task | App-owned files |
|
|
8
|
+
| ------------------------------------------ | ----------------------------------------------- |
|
|
9
|
+
| Define queries, filters, and operations | `app.ts`, `src/filters.ts`, `src/operations.ts` |
|
|
10
|
+
| Compose app content and supported features | `src/App.tsx` |
|
|
11
|
+
| Bind definitions and source evidence | `src/data-context.ts` |
|
|
12
|
+
| Change identity and appearance | `app.ts` |
|
|
13
|
+
| Inject styles and mount React | `src/main.tsx` |
|
|
14
|
+
| Configure local serving | `src/server.ts` |
|
|
15
15
|
|
|
16
16
|
See [README.md](README.md) for setup and checks.
|
|
17
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Local data app starter
|
|
2
2
|
|
|
3
3
|
Use `node_modules/@altertable/data-app/docs/app-authoring.md` for this SDK version.
|
|
4
|
-
Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.
|
|
4
|
+
Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->
|
|
5
5
|
See [AGENTS.md](AGENTS.md) for app-owned files.
|
|
6
6
|
|
|
7
7
|
## Run the app
|
|
@@ -21,17 +21,23 @@ Open <http://127.0.0.1:25837>. Alternatively, configure
|
|
|
21
21
|
`ALTERTABLE_DATA_PROXY_URL` and `ALTERTABLE_DATA_PROXY_TOKEN` for an existing
|
|
22
22
|
CLI proxy. Missing credentials stop startup.
|
|
23
23
|
|
|
24
|
+
## Explore the example
|
|
25
|
+
|
|
26
|
+
Choose a group to narrow the fictional sample counts. The chart, its inspected
|
|
27
|
+
rows, and the CSV export share one query, operation, view, and dataset. Widget
|
|
28
|
+
inspection exposes the registered query, selected parameters, and the sample
|
|
29
|
+
count definition. Gamma demonstrates a recorded zero.
|
|
30
|
+
|
|
24
31
|
## Build the app
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
Use inspected source data to answer the app brief. Replace the sample queries
|
|
34
|
+
and views, and set identity and appearance in `app.ts`.
|
|
28
35
|
|
|
29
36
|
```fish
|
|
30
37
|
bun run check
|
|
31
38
|
```
|
|
32
39
|
|
|
33
|
-
`bun run check` includes the build, which writes browser assets to `dist/`.
|
|
34
|
-
`/api/data` backend; the local adapter does not authenticate hosted viewers.
|
|
40
|
+
`bun run check` includes the build, which writes browser assets to `dist/`. Hosted apps require an authorized query bridge; the local adapter does not authenticate hosted viewers.
|
|
35
41
|
|
|
36
42
|
## License
|
|
37
43
|
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { defineDataApp } from '@altertable/data-app';
|
|
2
2
|
|
|
3
3
|
export const dataApp = defineDataApp({
|
|
4
|
-
title
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
appearance: {
|
|
11
|
-
theme: 'light',
|
|
12
|
-
baseColor: 'neutral',
|
|
13
|
-
density: 'comfortable',
|
|
14
|
-
cornerRadius: 'medium',
|
|
15
|
-
elevation: 'subtle',
|
|
16
|
-
typography: {
|
|
17
|
-
body: 'system',
|
|
18
|
-
heading: 'system',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
4
|
+
// Replace the demo title, description, and scope labels with the app's identity.
|
|
5
|
+
title: 'Sample counts',
|
|
6
|
+
description: 'Compare fictional sample counts across groups.',
|
|
7
|
+
scope: { organization: 'demo', environment: 'sample' },
|
|
8
|
+
appearance: { theme: 'system' },
|
|
21
9
|
queries: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
statement:
|
|
25
|
-
|
|
10
|
+
sampleCountsByGroup: {
|
|
11
|
+
// Fictional rows. Replace the CTE with an inspected source.
|
|
12
|
+
statement: `
|
|
13
|
+
WITH sample_counts(group_name, sample_count) AS (
|
|
14
|
+
VALUES ('Alpha', 1200), ('Alpha', 800), ('Beta', 450), ('Gamma', 0)
|
|
15
|
+
)
|
|
16
|
+
SELECT group_name, CAST(SUM(sample_count) AS BIGINT) AS sample_count
|
|
17
|
+
FROM sample_counts
|
|
18
|
+
WHERE $groupName = 'all' OR group_name = $groupName
|
|
19
|
+
GROUP BY group_name
|
|
20
|
+
ORDER BY sample_count DESC, group_name
|
|
21
|
+
LIMIT $limit`,
|
|
22
|
+
params: {
|
|
23
|
+
groupName: { type: 'string', defaultValue: 'all' },
|
|
24
|
+
limit: { type: 'number', defaultValue: 10 },
|
|
25
|
+
},
|
|
26
|
+
projections: {
|
|
27
|
+
group_name: { type: 'string' },
|
|
28
|
+
sample_count: { type: 'number' },
|
|
29
|
+
},
|
|
26
30
|
},
|
|
27
31
|
},
|
|
28
32
|
});
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
|
-
"lint": "oxlint --type-aware src",
|
|
11
|
+
"lint": "oxlint --type-aware src app.ts",
|
|
12
12
|
"format": "oxfmt src app.ts",
|
|
13
13
|
"format:check": "oxfmt --check src app.ts",
|
|
14
14
|
"dev": "bun --hot src/server.ts",
|
|
15
15
|
"build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
|
|
16
16
|
"check": "bun run lint && bun run format:check && bun run build",
|
|
17
|
-
"lint:fix": "oxlint --type-aware --fix src"
|
|
17
|
+
"lint:fix": "oxlint --type-aware --fix src app.ts"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@altertable/data-app": "0.
|
|
21
|
-
"@altertable/data-app-bun": "0.
|
|
22
|
-
"@altertable/data-app-react": "0.
|
|
20
|
+
"@altertable/data-app": "0.79.0",
|
|
21
|
+
"@altertable/data-app-bun": "0.79.0",
|
|
22
|
+
"@altertable/data-app-react": "0.79.0",
|
|
23
23
|
"react": "19.3.1",
|
|
24
24
|
"react-dom": "19.3.1"
|
|
25
25
|
},
|
|
@@ -1,9 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createDataHooks,
|
|
3
|
+
DataApp,
|
|
4
|
+
DataSection,
|
|
5
|
+
VisualizationWidget,
|
|
6
|
+
} from '@altertable/data-app-react';
|
|
7
|
+
import { BarChart } from '@altertable/data-app-react/ui';
|
|
2
8
|
|
|
3
9
|
import { dataContext } from '#app/data-context.ts';
|
|
10
|
+
import { operations } from '#app/operations.ts';
|
|
11
|
+
|
|
12
|
+
const { defineView } = createDataHooks(operations.createDataClient());
|
|
13
|
+
const sampleCountsView = defineView({
|
|
14
|
+
dataContext,
|
|
15
|
+
operation: 'sampleCountsByGroup',
|
|
16
|
+
emptyFallback: {
|
|
17
|
+
title: 'No matching groups',
|
|
18
|
+
description: 'Choose another group.',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const sampleCounts = sampleCountsView.dataset({
|
|
22
|
+
name: 'Sample counts',
|
|
23
|
+
rowKey: row => row.groupName,
|
|
24
|
+
columns: {
|
|
25
|
+
groupName: { label: 'Group' },
|
|
26
|
+
sampleCount: { format: { kind: 'count' } },
|
|
27
|
+
},
|
|
28
|
+
evidence: { id: 'counts-by-group', glossaryIds: ['sampleCount'] },
|
|
29
|
+
});
|
|
30
|
+
const countsContent = sampleCountsView.content(result => (
|
|
31
|
+
<VisualizationWidget
|
|
32
|
+
dataset={sampleCounts}
|
|
33
|
+
source={result}
|
|
34
|
+
title="Samples by group"
|
|
35
|
+
>
|
|
36
|
+
{rows => (
|
|
37
|
+
<BarChart
|
|
38
|
+
ariaLabel="Sample counts by group"
|
|
39
|
+
unit="samples"
|
|
40
|
+
valueFormat={{ kind: 'count' }}
|
|
41
|
+
showYAxis
|
|
42
|
+
scrollToEnd={false}
|
|
43
|
+
items={rows.map(row => ({
|
|
44
|
+
id: row.groupName,
|
|
45
|
+
label: row.groupName,
|
|
46
|
+
value: row.sampleCount,
|
|
47
|
+
}))}
|
|
48
|
+
/>
|
|
49
|
+
)}
|
|
50
|
+
</VisualizationWidget>
|
|
51
|
+
));
|
|
4
52
|
|
|
5
|
-
/** Connectivity-only screen. Investigate the requested question, then replace this with a view
|
|
6
|
-
* that leads with a supported finding and explores the useful angles behind it. */
|
|
7
53
|
export function App() {
|
|
8
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
<DataApp view={sampleCountsView} datasets={[sampleCounts]}>
|
|
56
|
+
<DataSection content={countsContent} />
|
|
57
|
+
</DataApp>
|
|
58
|
+
);
|
|
9
59
|
}
|
|
@@ -2,21 +2,16 @@ import { createDataContext } from '@altertable/data-app-react';
|
|
|
2
2
|
|
|
3
3
|
import { dataApp } from '#config';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
keyof typeof dataApp.queries
|
|
8
|
-
>;
|
|
9
|
-
|
|
10
|
-
/** Setup context only. Replace it with the exploration's scope, exact definitions, limitations,
|
|
11
|
-
* and query evidence after inspecting the source data. */
|
|
12
|
-
export const dataContext = createDataContext(connectionQueryNames)({
|
|
5
|
+
// Replace the description and definitions with verified source metadata.
|
|
6
|
+
export const dataContext = createDataContext(dataApp.queryNames)({
|
|
13
7
|
description:
|
|
14
|
-
'
|
|
8
|
+
'Fictional sample counts by group. Gamma has a recorded count of zero.',
|
|
15
9
|
glossary: {
|
|
16
|
-
|
|
17
|
-
term: '
|
|
18
|
-
definition:
|
|
19
|
-
|
|
10
|
+
sampleCount: {
|
|
11
|
+
term: 'Sample count',
|
|
12
|
+
definition:
|
|
13
|
+
'Sum of recorded samples in the selected group scope. Additive across groups.',
|
|
14
|
+
queryNames: [dataApp.queryNames.sampleCountsByGroup],
|
|
20
15
|
},
|
|
21
16
|
},
|
|
22
17
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { choiceFilter } from '@altertable/data-app/contract';
|
|
2
|
+
|
|
3
|
+
// The options match the fictional rows; the query treats 'all' as every group.
|
|
4
|
+
export const groupName = choiceFilter({
|
|
5
|
+
key: 'group',
|
|
6
|
+
label: 'Group',
|
|
7
|
+
defaultValue: 'all',
|
|
8
|
+
options: [
|
|
9
|
+
{ id: 'all', label: 'All groups' },
|
|
10
|
+
{ id: 'Alpha', label: 'Alpha' },
|
|
11
|
+
{ id: 'Beta', label: 'Beta' },
|
|
12
|
+
{ id: 'Gamma', label: 'Gamma' },
|
|
13
|
+
],
|
|
14
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mountDataApp } from '@altertable/data-app-react';
|
|
2
|
+
import { installLocalQueryLakehouse } from '@altertable/data-app/client';
|
|
2
3
|
|
|
3
4
|
import { App } from '#app/App.tsx';
|
|
4
5
|
import { dataApp } from '#config';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
installLocalQueryLakehouse();
|
|
8
8
|
mountDataApp({ app: dataApp, component: App });
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { groupName } from '#app/filters.ts';
|
|
3
2
|
import { dataApp } from '#config';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const operations = dataApp.defineOperations({
|
|
5
|
+
sampleCountsByGroup: dataApp.defineOperation({
|
|
6
|
+
filters: { groupName },
|
|
7
|
+
policy: { maxQueryRows: 10 },
|
|
8
|
+
async run({ query }, { groupName }) {
|
|
9
|
+
const { rows } = await query('sampleCountsByGroup', { groupName });
|
|
10
|
+
return rows.map(row => ({
|
|
11
|
+
groupName: row.group_name,
|
|
12
|
+
sampleCount: row.sample_count,
|
|
13
|
+
}));
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { serveLocalApp } from '@altertable/data-app-bun';
|
|
2
2
|
|
|
3
3
|
import page from '#app/index.html';
|
|
4
|
-
import { operations } from '#app/operations.ts';
|
|
5
4
|
import { dataApp } from '#config';
|
|
6
5
|
|
|
7
|
-
serveLocalApp({ page,
|
|
6
|
+
serveLocalApp({ page, app: dataApp });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Read `node_modules/@altertable/data-app/docs/app-authoring.md` and use this project
|
|
4
4
|
as the selected scaffold. If dependencies are unavailable, read the
|
|
5
|
-
[version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.
|
|
5
|
+
[version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->
|
|
6
6
|
|
|
7
7
|
| Task | App-owned files |
|
|
8
8
|
| ------------------------------------------ | ------------------------------------------------------ |
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Local finding data app starter
|
|
2
2
|
|
|
3
3
|
Use `node_modules/@altertable/data-app/docs/app-authoring.md` for this SDK version.
|
|
4
|
-
Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.
|
|
4
|
+
Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->
|
|
5
5
|
See [AGENTS.md](AGENTS.md) for app-owned files.
|
|
6
6
|
|
|
7
7
|
The example queries require the seeded sample data described in the
|
|
8
|
-
[local preview guide](https://github.com/altertable-ai/data-app/blob/v0.
|
|
8
|
+
[local preview guide](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/local-data-apps.md#preview-the-starters). <!-- x-release-please-version -->
|
|
9
9
|
Use that mock for development, or replace the example queries with verified data
|
|
10
10
|
in your lakehouse. The starter does not install a mock or create demo tables.
|
|
11
11
|
|
|
@@ -35,8 +35,7 @@ specified by the app brief. Change identity, appearance, and queries in `app.ts`
|
|
|
35
35
|
bun run check
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
`bun run check` includes the build, which writes browser assets to `dist/`.
|
|
39
|
-
`/api/data` backend; the local adapter does not authenticate hosted viewers.
|
|
38
|
+
`bun run check` includes the build, which writes browser assets to `dist/`. Hosted apps require an authorized query bridge; the local adapter does not authenticate hosted viewers.
|
|
40
39
|
|
|
41
40
|
## License
|
|
42
41
|
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { defineDataApp } from '@altertable/data-app';
|
|
2
2
|
|
|
3
3
|
export const dataApp = defineDataApp({
|
|
4
|
+
// Replace the demo title, description, and scope labels with the app's identity.
|
|
4
5
|
title: 'Sample finding',
|
|
5
6
|
description:
|
|
6
|
-
'
|
|
7
|
+
'Explore sample volume over time and across groups and segments.',
|
|
7
8
|
scope: { organization: 'demo', environment: 'sample' },
|
|
8
9
|
appearance: { theme: 'system' },
|
|
10
|
+
// starter_demo.daily_samples contains seeded fictional observations.
|
|
11
|
+
// Replace these queries with verified sources before publishing.
|
|
9
12
|
queries: {
|
|
10
|
-
|
|
13
|
+
sampleTotals: {
|
|
11
14
|
projections: { sample_count: { type: 'number' } },
|
|
12
15
|
statement: `
|
|
13
|
-
SELECT
|
|
16
|
+
SELECT SUM(sample_count) AS sample_count
|
|
14
17
|
FROM starter_demo.daily_samples
|
|
15
|
-
WHERE sample_date >= $
|
|
16
|
-
|
|
18
|
+
WHERE sample_date >= CAST($period_from AS TIMESTAMP) AND sample_date < CAST($period_to AS TIMESTAMP)
|
|
19
|
+
AND ($groupName = 'all' OR group_name = $groupName)
|
|
20
|
+
HAVING COUNT(*) > 0`,
|
|
21
|
+
params: {
|
|
22
|
+
groupName: { type: 'string', defaultValue: 'Alpha' },
|
|
23
|
+
period_from: { type: 'string' },
|
|
24
|
+
period_to: { type: 'string' },
|
|
25
|
+
},
|
|
17
26
|
},
|
|
18
27
|
samplesOverTime: {
|
|
19
28
|
projections: {
|
|
@@ -24,10 +33,13 @@ WHERE sample_date >= $period.from AND sample_date < $period.to`,
|
|
|
24
33
|
SELECT strftime(date_trunc($grain, sample_date), '%Y-%m-%d') AS period_start,
|
|
25
34
|
SUM(sample_count) AS sample_count
|
|
26
35
|
FROM starter_demo.daily_samples
|
|
27
|
-
WHERE sample_date >= $
|
|
36
|
+
WHERE sample_date >= CAST($period_from AS TIMESTAMP) AND sample_date < CAST($period_to AS TIMESTAMP)
|
|
37
|
+
AND ($groupName = 'all' OR group_name = $groupName)
|
|
28
38
|
GROUP BY ALL ORDER BY period_start LIMIT 200`,
|
|
29
39
|
params: {
|
|
30
|
-
|
|
40
|
+
groupName: { type: 'string', defaultValue: 'Alpha' },
|
|
41
|
+
period_from: { type: 'string' },
|
|
42
|
+
period_to: { type: 'string' },
|
|
31
43
|
grain: { type: 'string', defaultValue: 'day' },
|
|
32
44
|
},
|
|
33
45
|
},
|
|
@@ -40,10 +52,13 @@ GROUP BY ALL ORDER BY period_start LIMIT 200`,
|
|
|
40
52
|
SELECT CASE WHEN $breakdown = 'group' THEN group_name ELSE segment_name END AS member,
|
|
41
53
|
SUM(sample_count) AS sample_count
|
|
42
54
|
FROM starter_demo.daily_samples
|
|
43
|
-
WHERE sample_date >= $
|
|
55
|
+
WHERE sample_date >= CAST($period_from AS TIMESTAMP) AND sample_date < CAST($period_to AS TIMESTAMP)
|
|
56
|
+
AND ($groupName = 'all' OR group_name = $groupName)
|
|
44
57
|
GROUP BY ALL ORDER BY sample_count DESC LIMIT 50`,
|
|
45
58
|
params: {
|
|
46
|
-
|
|
59
|
+
groupName: { type: 'string', defaultValue: 'Alpha' },
|
|
60
|
+
period_from: { type: 'string' },
|
|
61
|
+
period_to: { type: 'string' },
|
|
47
62
|
breakdown: { type: 'string', defaultValue: 'segment' },
|
|
48
63
|
},
|
|
49
64
|
},
|
|
@@ -58,10 +73,13 @@ SELECT strftime(date_trunc($grain, sample_date), '%Y-%m-%d') AS period_start,
|
|
|
58
73
|
CASE WHEN $breakdown = 'group' THEN group_name ELSE segment_name END AS member,
|
|
59
74
|
SUM(sample_count) AS sample_count
|
|
60
75
|
FROM starter_demo.daily_samples
|
|
61
|
-
WHERE sample_date >= $
|
|
76
|
+
WHERE sample_date >= CAST($period_from AS TIMESTAMP) AND sample_date < CAST($period_to AS TIMESTAMP)
|
|
77
|
+
AND ($groupName = 'all' OR group_name = $groupName)
|
|
62
78
|
GROUP BY ALL ORDER BY period_start, member LIMIT 500`,
|
|
63
79
|
params: {
|
|
64
|
-
|
|
80
|
+
groupName: { type: 'string', defaultValue: 'Alpha' },
|
|
81
|
+
period_from: { type: 'string' },
|
|
82
|
+
period_to: { type: 'string' },
|
|
65
83
|
grain: { type: 'string', defaultValue: 'day' },
|
|
66
84
|
breakdown: { type: 'string', defaultValue: 'segment' },
|
|
67
85
|
},
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
|
-
"lint": "oxlint --type-aware src",
|
|
11
|
+
"lint": "oxlint --type-aware src app.ts",
|
|
12
12
|
"format": "oxfmt src app.ts",
|
|
13
13
|
"format:check": "oxfmt --check src app.ts",
|
|
14
14
|
"dev": "bun --hot src/server.ts",
|
|
15
15
|
"build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
|
|
16
16
|
"check": "bun run lint && bun run format:check && bun run build",
|
|
17
|
-
"lint:fix": "oxlint --type-aware --fix src"
|
|
17
|
+
"lint:fix": "oxlint --type-aware --fix src app.ts"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@altertable/data-app": "0.
|
|
21
|
-
"@altertable/data-app-bun": "0.
|
|
22
|
-
"@altertable/data-app-react": "0.
|
|
20
|
+
"@altertable/data-app": "0.79.0",
|
|
21
|
+
"@altertable/data-app-bun": "0.79.0",
|
|
22
|
+
"@altertable/data-app-react": "0.79.0",
|
|
23
23
|
"react": "19.3.1",
|
|
24
24
|
"react-dom": "19.3.1"
|
|
25
25
|
},
|