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

Refac: Svelte-check and svelte 4 upgrade changes #3664

Merged
merged 1 commit into from
Dec 8, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { StateManagers } from "@rilldata/web-common/features/dashboards/sta
import { memoizeMetricsStore } from "../state-managers/memoize-metrics-store";
import { useMetaQuery } from "@rilldata/web-common/features/dashboards/selectors/index";
import { useTimeControlStore } from "@rilldata/web-common/features/dashboards/time-controls/time-control-store";
import { derived, type Readable } from "svelte/store";
import { derived, writable, type Readable, Writable } from "svelte/store";
import {
V1MetricsViewAggregationResponse,
V1MetricsViewAggregationResponseDataItem,
Expand Down Expand Up @@ -92,9 +92,9 @@ export function createTimeSeriesDataStore(ctx: StateManagers) {
const interval =
timeControls.selectedTimeRange?.interval ?? timeControls.minTimeGrain;

const allMeasures = metricsView.data?.measures.map(
(measure) => measure.name
);
const allMeasures =
metricsView.data?.measures?.map((measure) => measure.name as string) ||
[];
let measures = allMeasures;
if (dashboardStore?.expandedMeasureName) {
measures = allMeasures.filter(
Expand All @@ -118,21 +118,20 @@ export function createTimeSeriesDataStore(ctx: StateManagers) {
true
);

let comparisonTimeSeries: CreateQueryResult<
V1MetricsViewTimeSeriesResponse,
unknown
>;
let comparisonTotals: CreateQueryResult<
V1MetricsViewAggregationResponse,
unknown
>;
let comparisonTimeSeries:
| CreateQueryResult<V1MetricsViewTimeSeriesResponse, unknown>
| Writable<null> = writable(null);
let comparisonTotals:
| CreateQueryResult<V1MetricsViewAggregationResponse, unknown>
| Writable<null> = writable(null);
if (showComparison) {
comparisonTimeSeries = createMetricsViewTimeSeries(ctx, measures, true);
comparisonTotals = createTotalsForMeasure(ctx, measures, true);
}

let dimensionTimeSeriesCharts;
let dimensionTimeSeriesTable;
let dimensionTimeSeriesCharts:
| Readable<DimensionDataItem[]>
| Writable<null> = writable(null);
if (dashboardStore?.selectedComparisonDimension) {
dimensionTimeSeriesCharts = getDimensionValueTimeSeries(
ctx,
Expand All @@ -149,7 +148,6 @@ export function createTimeSeriesDataStore(ctx: StateManagers) {
unfilteredTotals,
comparisonTotals,
dimensionTimeSeriesCharts,
dimensionTimeSeriesTable,
],
([
primary,
Expand All @@ -171,21 +169,21 @@ export function createTimeSeriesDataStore(ctx: StateManagers) {
};
}

if (!primary.isFetching) {
if (!primary.isFetching && interval) {
timeSeriesData = prepareTimeSeries(
primary?.data?.data,
comparison?.data?.data,
TIME_GRAIN[interval]?.duration,
dashboardStore.selectedTimezone
dashboardStore.selectedTimezone || "Etc/UTC"
);
}
return {
isFetching: primaryTotal?.isFetching || metricsView?.isFetching,
isError: false, // FIXME Handle errors
timeSeriesData,
total: primaryTotal?.data?.data[0],
unfilteredTotal: unfilteredTotal?.data?.data[0],
comparisonTotal: comparisonTotal?.data?.data[0],
total: primaryTotal?.data?.data?.[0],
unfilteredTotal: unfilteredTotal?.data?.data?.[0],
comparisonTotal: comparisonTotal?.data?.data?.[0],
dimensionChartData: (dimensionChart as DimensionDataItem[]) || [],
};
}
Expand Down
Loading