Skip to content

Commit

Permalink
Merge pull request #994 from visualize-admin/abbrev
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne authored Mar 3, 2023
2 parents b10b42b + 00f1417 commit 8e946af
Show file tree
Hide file tree
Showing 9 changed files with 1,147 additions and 1,743 deletions.
17 changes: 1 addition & 16 deletions app/charts/shared/chart-data-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
HierarchyValue,
TemporalDimension,
TimeUnit,
useDimensionHierarchyQuery,
useDimensionValuesQuery,
} from "@/graphql/query-hooks";
import { Icon } from "@/icons";
Expand Down Expand Up @@ -154,21 +153,7 @@ const DataFilter = ({
},
});

const dimension = data?.dataCubeByIri?.dimensionByIri;

const [hierarchyResp] = useDimensionHierarchyQuery({
variables: {
cubeIri: dataSetIri,
dimensionIri: dimension?.iri!,
sourceType: dataSource.type,
sourceUrl: dataSource.url,
locale: locale,
},
pause: !dimension,
});

const hierarchy =
hierarchyResp.data?.dataCubeByIri?.dimensionByIri?.hierarchy;
const hierarchy = data?.dataCubeByIri?.dimensionByIri?.hierarchy;

const setDataFilter = (
e: SelectChangeEvent<unknown> | { target: { value: string } }
Expand Down
18 changes: 8 additions & 10 deletions app/charts/shared/legend-color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
import { Observation } from "@/domain/data";
import {
DimensionMetadataFragment,
useDataCubeMetadataWithComponentValuesQuery,
useDimensionHierarchyQuery,
useDimensionValuesQuery,
} from "@/graphql/query-hooks";
import SvgIcChevronRight from "@/icons/components/IcChevronRight";
import { useLocale } from "@/src";
Expand Down Expand Up @@ -108,20 +107,19 @@ const useDimension = ({
locale: string;
dimensionIri?: string;
}) => {
const [{ data: cubeMetadata }] = useDataCubeMetadataWithComponentValuesQuery({
const [{ data: cubeMetadata }] = useDimensionValuesQuery({
variables: {
iri: dataset,
dataCubeIri: dataset,
dimensionIri: dimensionIri!,
sourceType: dataSource.type,
sourceUrl: dataSource.url,
locale: locale,
},
pause: !dimensionIri,
});
return useMemo(() => {
return cubeMetadata?.dataCubeByIri?.dimensions.find(
(d) => d.iri === dimensionIri
);
}, [cubeMetadata?.dataCubeByIri?.dimensions, dimensionIri]);
return cubeMetadata?.dataCubeByIri?.dimensionByIri;
}, [cubeMetadata?.dataCubeByIri?.dimensionByIri]);
};

const emptyObj = {};
Expand Down Expand Up @@ -168,9 +166,9 @@ const useLegendGroups = ({
dimensionIri: segmentField?.componentIri,
});

const [hierarchyResp] = useDimensionHierarchyQuery({
const [hierarchyResp] = useDimensionValuesQuery({
variables: {
cubeIri: dataset,
dataCubeIri: dataset,
dimensionIri: segmentDimension?.iri!,
sourceType: dataSource.type,
sourceUrl: dataSource.url,
Expand Down
30 changes: 17 additions & 13 deletions app/configurator/components/chart-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { makeStyles } from "@mui/styles";
import isEmpty from "lodash/isEmpty";
import isEqual from "lodash/isEqual";
import omitBy from "lodash/omitBy";
import sortBy from "lodash/sortBy";
import { useEffect, useRef, useState, useMemo } from "react";
import {
Expand Down Expand Up @@ -283,27 +284,30 @@ const useFilterReorder = ({
return getFiltersByMappingStatus(state.chartConfig);
}, [state.chartConfig]);

const variables = useMemo(
() => ({
const variables = useMemo(() => {
const hasUnmappedFilters = Object.keys(unmappedFilters).length > 0;
const vars = {
iri: state.dataSet,
sourceType: state.dataSource.type,
sourceUrl: state.dataSource.url,
locale,
filters: unmappedFilters,
filters: hasUnmappedFilters ? unmappedFilters : undefined,
// This is important for urql not to think that filters
// are the same while the order of the keys has changed.
// If this is not present, we'll have outdated dimension
// values after we change the filter order
filterKeys: Object.keys(unmappedFilters).join(", "),
}),
[
state.dataSet,
state.dataSource.type,
state.dataSource.url,
locale,
unmappedFilters,
]
);
filterKeys: hasUnmappedFilters
? Object.keys(unmappedFilters).join(", ")
: undefined,
};
return omitBy(vars, (x) => x === undefined) as typeof vars;
}, [
state.dataSet,
state.dataSource.type,
state.dataSource.url,
locale,
unmappedFilters,
]);

const [{ data, fetching: dataFetching }, executeQuery] =
useDataCubeMetadataWithComponentValuesQuery({
Expand Down
14 changes: 7 additions & 7 deletions app/gql-flamegraph/devtool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ const CopyLink = ({ toCopy, ...props }: { toCopy: string } & LinkProps) => {
);
};

const getOperationQueryName = (operation: Operation) => {
return operation.query.definitions.find(
(d): d is OperationDefinitionNode => d.kind === "OperationDefinition"
)?.name?.value;
};

/**
* Collapsible according showing for each request that has been made
* a accordion with name
Expand Down Expand Up @@ -208,13 +214,7 @@ const AccordionOperation = ({
}}
>
<Typography variant="body2" sx={{ mb: 0 }}>
{operation.key}{" "}
{
operation.query.definitions.find(
(d): d is OperationDefinitionNode =>
d.kind === "OperationDefinition"
)?.name?.value
}
{operation.key} {getOperationQueryName(operation)}
<Box component="span" sx={{ ml: 2 }}>
{result ? "✅" : "🔄"}
</Box>
Expand Down
1 change: 1 addition & 0 deletions app/graphql/queries/data-cubes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ query DimensionValues(
sourceUrl: $sourceUrl
) {
...dimensionMetadata
...hierarchyMetadata
}
}
}
Expand Down
Loading

1 comment on commit 8e946af

@vercel
Copy link

@vercel vercel bot commented on 8e946af Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

visualization-tool – ./

visualization-tool-ixt1.vercel.app
visualization-tool-alpha.vercel.app
visualization-tool-git-main-ixt1.vercel.app

Please sign in to comment.