File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.metrics.$dashboardKey Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import { QueuesFilter } from "~/components/metrics/QueuesFilter";
3030import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route" ;
3131import { useSearchParams } from "~/hooks/useSearchParam" ;
3232import { type WidgetData } from "~/components/metrics/QueryWidget" ;
33- import type { QueryScope } from "~/services/queryService.server " ;
33+ import { QueryScopeSchema } from "~/v3/querySchemas " ;
3434
3535const ParamSchema = EnvironmentParamSchema . extend ( {
3636 dashboardKey : z . string ( ) ,
@@ -145,7 +145,8 @@ export function MetricDashboard({
145145 const period = value ( "period" ) ;
146146 const from = value ( "from" ) ;
147147 const to = value ( "to" ) ;
148- const scope = ( value ( "scope" ) as QueryScope ) ?? "environment" ;
148+ const parsedScope = QueryScopeSchema . safeParse ( value ( "scope" ) ?? "environment" ) ;
149+ const scope = parsedScope . success ? parsedScope . data : "environment" ;
149150 const tasks = values ( "tasks" ) . filter ( ( v ) => v !== "" ) ;
150151 const queues = values ( "queues" ) . filter ( ( v ) => v !== "" ) ;
151152
Original file line number Diff line number Diff line change @@ -20,11 +20,10 @@ import {
2020import { getLimit } from "./platform.v3.server" ;
2121import { timeFilters , timeFilterFromTo } from "~/components/runs/v3/SharedFilters" ;
2222import parse from "parse-duration" ;
23- import { querySchemas } from "~/v3/querySchemas" ;
23+ import { querySchemas , QueryScopeSchema , type QueryScope } from "~/v3/querySchemas" ;
2424
25- export type { TableSchema , TSQLQueryResult } ;
26-
27- export type QueryScope = "organization" | "project" | "environment" ;
25+ export { QueryScopeSchema } ;
26+ export type { TableSchema , TSQLQueryResult , QueryScope } ;
2827
2928const scopeToEnum = {
3029 organization : "ORGANIZATION" ,
Original file line number Diff line number Diff line change 11import { column , type TableSchema } from "@internal/tsql" ;
2+ import { z } from "zod" ;
23import { autoFormatSQL } from "~/components/code/TSQLEditor" ;
34import { runFriendlyStatus , runStatusTitleFromStatus } from "~/components/runs/v3/TaskRunStatus" ;
45import { logger } from "~/services/logger.server" ;
56
7+ export const QueryScopeSchema = z . enum ( [ "organization" , "project" , "environment" ] ) ;
8+ export type QueryScope = z . infer < typeof QueryScopeSchema > ;
9+
610/**
711 * Environment type values
812 */
You can’t perform that action at this time.
0 commit comments