Skip to content

Commit 9635492

Browse files
authored
move everything to joins page, update search/default page, etc (#82)
## Summary I have moved everything from `/models/model_name` to `/joins/join_name`. I also created a shared entity object and show groupbys and joins in search results. PR walkthrough video [here](https://drive.google.com/file/d/10lnso4MGXuXlmr5F-aLzDBwWncGBuEmt/view?usp=sharing) Limitations: - You can't click on a model or groupby from search - Backend search only queries models (so matches to joins or groupbys do not come up) ([details](https://github.com/zipline-ai/chronon/pull/82/files#r1855120136)) Future: - Removing anything not related to joins (model performance, skew, etc) ## Checklist - [x] Added Unit Tests - [x] Covered by existing CI - [ ] Integration tested - [ ] Documentation update <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Enhanced navigation with dynamic filtering of entities in the NavigationBar. - Introduced a detailed table view for "Joins" displaying relevant model information. - **Bug Fixes** - Updated redirection from the root URL to the "Joins" page. - **Removals** - Removed outdated placeholder components for "GroupBys" and "Models" pages. These updates improve user navigation and provide a more informative interface for managing joins and models. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 673c232 commit 9635492

File tree

12 files changed

+134
-82
lines changed

12 files changed

+134
-82
lines changed

frontend/src/lib/components/NavigationBar/NavigationBar.svelte

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
AdjustmentsHorizontal,
3131
ArrowsUpDown
3232
} from 'svelte-hero-icons';
33-
import type { IconSource } from 'svelte-hero-icons';
3433
import { goto } from '$app/navigation';
3534
import { isMacOS } from '$lib/util/browser';
3635
import { Badge } from '$lib/components/ui/badge';
36+
import { getEntity, type Entity } from '$lib/types/Entity/Entity';
3737
3838
type Props = {
39-
navItems: { label: string; href: string; icon: IconSource }[];
39+
navItems: Entity[];
4040
user: { name: string; avatar: string };
4141
};
4242
@@ -130,16 +130,16 @@
130130
{#each navItems as item}
131131
<li>
132132
<Button
133-
variant={isActiveRoute(item.href) ? 'default' : 'ghost'}
133+
variant={isActiveRoute(item.path) ? 'default' : 'ghost'}
134134
size="nav"
135-
href={item.href}
135+
href={item.path}
136136
icon="leading"
137137
>
138138
<Icon
139139
src={item.icon}
140140
micro
141141
size="16"
142-
class={isActiveRoute(item.href) ? 'text-muted-icon-primary' : 'text-muted-icon-neutral'}
142+
class={isActiveRoute(item.path) ? 'text-muted-icon-primary' : 'text-muted-icon-neutral'}
143143
/>
144144
{item.label}
145145
</Button>
@@ -202,9 +202,31 @@
202202
{:else}
203203
<CommandGroup heading={`Search for "${input}"`}>
204204
{#each searchResults as model}
205-
<CommandItem onSelect={() => handleSelect(`/models/${encodeURIComponent(model.name)}`)}>
205+
<CommandItem
206+
disabled
207+
onSelect={() =>
208+
handleSelect(`${getEntity('models').path}/${encodeURIComponent(model.name)}`)}
209+
>
210+
<Icon src={getEntity('models').icon} micro size="16" />
206211
{model.name}
207212
</CommandItem>
213+
<CommandItem
214+
onSelect={() =>
215+
handleSelect(`${getEntity('joins').path}/${encodeURIComponent(model.join.name)}`)}
216+
>
217+
<Icon src={getEntity('joins').icon} micro size="16" />
218+
{model.join.name}
219+
</CommandItem>
220+
{#each model.join.groupBys as groupBy}
221+
<CommandItem
222+
disabled
223+
onSelect={() =>
224+
handleSelect(`${getEntity('groupbys').path}/${encodeURIComponent(groupBy.name)}`)}
225+
>
226+
<Icon src={getEntity('groupbys').icon} micro size="16" />
227+
{groupBy.name}
228+
</CommandItem>
229+
{/each}
208230
{/each}
209231
</CommandGroup>
210232
{/if}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Cube, PuzzlePiece, Square3Stack3d } from 'svelte-hero-icons';
2+
3+
export const entityConfig = [
4+
{
5+
label: 'Models',
6+
path: '/models',
7+
icon: Cube,
8+
id: 'models'
9+
},
10+
{
11+
label: 'GroupBys',
12+
path: '/groupbys',
13+
icon: PuzzlePiece,
14+
id: 'groupbys'
15+
},
16+
{
17+
label: 'Joins',
18+
path: '/joins',
19+
icon: Square3Stack3d,
20+
id: 'joins'
21+
}
22+
] as const;
23+
24+
export type Entity = (typeof entityConfig)[number];
25+
export type EntityId = Entity['id'];
26+
27+
// Helper function to get entity by ID
28+
export function getEntity(id: EntityId): Entity {
29+
const entity = entityConfig.find((entity) => entity.id === id);
30+
if (!entity) throw new Error(`Entity with id "${id}" not found`);
31+
return entity;
32+
}

frontend/src/lib/types/Model/Model.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('Model types', () => {
7171

7272
if (timeseriesResult.items.length > 0) {
7373
const item = timeseriesResult.items[0];
74-
const expectedItemKeys = ['value', 'ts', 'label'];
74+
const expectedItemKeys = ['value', 'ts', 'label', 'nullValue'];
7575
expect(Object.keys(item)).toEqual(expect.arrayContaining(expectedItemKeys));
7676

7777
// Log a warning if there are additional fields
@@ -184,7 +184,7 @@ describe('Model types', () => {
184184

185185
if (subItem.points.length > 0) {
186186
const point = subItem.points[0];
187-
const expectedPointKeys = ['value', 'ts', 'label'];
187+
const expectedPointKeys = ['value', 'ts', 'label', 'nullValue'];
188188
expect(Object.keys(point)).toEqual(expect.arrayContaining(expectedPointKeys));
189189

190190
// Log a warning if there are additional fields

frontend/src/lib/types/Model/Model.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type Model = {
44
production: boolean;
55
team: string;
66
modelType: string;
7-
join: JoinTimeSeriesResponse; // todo: this type needs to be updated to match the actual response once that WIP is finished
7+
join: Join;
88
};
99

1010
export type ModelsResponse = {
@@ -23,6 +23,16 @@ export type TimeSeriesResponse = {
2323
id: string;
2424
items: TimeSeriesItem[];
2525
};
26+
export type Join = {
27+
name: string;
28+
joinFeatures: string[];
29+
groupBys: GroupBy[];
30+
};
31+
32+
export type GroupBy = {
33+
name: string;
34+
features: string[];
35+
};
2636

2737
export type JoinTimeSeriesResponse = {
2838
name: string; // todo: rename to joinName

frontend/src/routes/+layout.svelte

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import NavigationBar from '$lib/components/NavigationBar/NavigationBar.svelte';
77
import BreadcrumbNav from '$lib/components/BreadcrumbNav/BreadcrumbNav.svelte';
88
import { ScrollArea } from '$lib/components/ui/scroll-area';
9-
import { Cube, PuzzlePiece, Square3Stack3d } from 'svelte-hero-icons';
9+
import { entityConfig } from '$lib/types/Entity/Entity';
1010
1111
let { children }: { children: Snippet } = $props();
1212
@@ -16,20 +16,14 @@
1616
avatar: '/path/to/avatar.jpg'
1717
};
1818
19-
const navItems = [
20-
{ label: 'Models', href: '/models', icon: Cube },
21-
{ label: 'GroupBys', href: '/groupbys', icon: PuzzlePiece },
22-
{ label: 'Joins', href: '/joins', icon: Square3Stack3d }
23-
];
24-
2519
const breadcrumbs = $derived($page.url.pathname.split('/').filter(Boolean));
2620
</script>
2721

2822
<div class="flex h-screen">
2923
<NavigationSlider />
3024

3125
<!-- Left navigation -->
32-
<NavigationBar {navItems} {user} />
26+
<NavigationBar navItems={entityConfig.filter((entity) => entity.id === 'joins')} {user} />
3327

3428
<!-- Main content -->
3529
<main

frontend/src/routes/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { redirect } from '@sveltejs/kit';
22

33
export function load({ url }) {
44
if (url.pathname === '/') {
5-
throw redirect(307, '/models');
5+
throw redirect(307, '/joins');
66
}
77
}

frontend/src/routes/groupbys/+page.svelte

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
1-
<script>
2-
import ComingSoonPage from '$lib/components/ComingSoonPage/ComingSoonPage.svelte';
1+
<script lang="ts">
2+
import type { Model } from '$lib/types/Model/Model';
3+
import {
4+
Table,
5+
TableBody,
6+
TableCell,
7+
TableHead,
8+
TableHeader,
9+
TableRow
10+
} from '$lib/components/ui/table';
11+
import TrueFalseBadge from '$lib/components/TrueFalseBadge/TrueFalseBadge.svelte';
12+
import Separator from '$lib/components/ui/separator/separator.svelte';
13+
import PageHeader from '$lib/components/PageHeader/PageHeader.svelte';
14+
import ActionButtons from '$lib/components/ActionButtons/ActionButtons.svelte';
15+
16+
const { data } = $props();
17+
const models: Model[] = $state(data.models.items);
318
</script>
419

5-
<ComingSoonPage />
20+
<PageHeader title="Joins"></PageHeader>
21+
22+
<div class="w-full">
23+
<ActionButtons class="mb-4" />
24+
</div>
25+
<Separator fullWidthExtend={true} />
26+
<Table>
27+
<TableHeader>
28+
<TableRow>
29+
<TableHead>Join</TableHead>
30+
<TableHead>Model</TableHead>
31+
<TableHead>Team</TableHead>
32+
<TableHead>Type</TableHead>
33+
<TableHead>Online</TableHead>
34+
<TableHead>Production</TableHead>
35+
</TableRow>
36+
</TableHeader>
37+
<TableBody>
38+
{#each models as model}
39+
<TableRow>
40+
<TableCell>
41+
<a href={'/joins/' + encodeURIComponent(model.join.name)} class="hover:underline">
42+
{model.join.name}
43+
</a>
44+
</TableCell>
45+
<TableCell>
46+
{model.name}
47+
</TableCell>
48+
<TableCell>{model.team}</TableCell>
49+
<TableCell>{model.modelType}</TableCell>
50+
<TableCell>
51+
<TrueFalseBadge isTrue={model.online} />
52+
</TableCell>
53+
<TableCell>
54+
<TrueFalseBadge isTrue={model.production} />
55+
</TableCell>
56+
</TableRow>
57+
{/each}
58+
</TableBody>
59+
</Table>
60+
<Separator fullWidthExtend={true} />

frontend/src/routes/models/+page.svelte

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)