Skip to content

Commit 2c33d5f

Browse files
author
Tom Jones
committed
EES-5373: Update frontend to provide boundary level as separate argument in requests.
1 parent dbfd93d commit 2c33d5f

File tree

15 files changed

+50
-9
lines changed

15 files changed

+50
-9
lines changed

src/explore-education-statistics-admin/src/pages/bau/BoundaryDataPage.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import Link from '@admin/components/Link';
88
import { useQuery } from '@tanstack/react-query';
99
import boundaryDataQueries from '@admin/queries/boundaryDataQueries';
1010
import boundaryTypesMap from '@common/utils/boundaryTypesMap';
11-
import locationLevelsMap, {
12-
LocationLevelKey,
13-
} from '@common/utils/locationLevelsMap';
11+
import locationLevelsMap from '@common/utils/locationLevelsMap';
1412
import InsetText from '@common/components/InsetText';
1513
import classNames from 'classnames';
1614
import styles from './BoundaryDataPage.module.scss';

src/explore-education-statistics-admin/src/pages/release/content/components/ReleasePreviewTableTool.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const ReleasePreviewTableTool = ({
4848
...query,
4949
},
5050
releaseId,
51+
query.boundaryLevel,
5152
),
5253
]);
5354

src/explore-education-statistics-admin/src/pages/release/datablocks/__tests__/ReleaseDataBlockEditPage.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ describe('ReleaseDataBlockEditPage', () => {
119119
dataSets: [],
120120
},
121121
},
122+
boundaryLevel: undefined,
122123
legend: {
123124
position: 'top',
124125
items: [],

src/explore-education-statistics-admin/src/pages/release/datablocks/components/DataBlockPageReadOnlyTabs.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const DataBlockPageReadOnlyTabs = ({ releaseId, dataBlock }: Props) => {
3232
const tableData = await tableBuilderService.getTableData(
3333
dataBlock.query,
3434
releaseId,
35+
dataBlock.charts[0].boundaryLevel,
3536
);
3637
const table = mapFullTable(tableData);
3738

src/explore-education-statistics-admin/src/pages/release/datablocks/components/DataBlockPageTabs.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ const DataBlockPageTabs = ({
7878
releaseId,
7979
};
8080

81-
const tableData = await tableBuilderService.getTableData(query, releaseId);
81+
const boundaryLevel = dataBlock.charts[0]?.boundaryLevel ?? undefined;
82+
const tableData = await tableBuilderService.getTableData(
83+
query,
84+
releaseId,
85+
boundaryLevel,
86+
);
8287
const { initialStep, subjectMeta } = await getInitialStepSubjectMeta(
8388
query,
8489
tableData,

src/explore-education-statistics-admin/src/pages/release/datablocks/components/chart/ChartBuilderTabSection.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const ChartBuilderTabSection = ({
101101
const tableData = await tableBuilderService.getTableData(
102102
nextQuery,
103103
releaseId,
104+
nextQuery.boundaryLevel,
104105
);
105106

106107
onTableUpdate({

src/explore-education-statistics-admin/src/pages/release/datablocks/components/chart/reducers/__tests__/chartBuilderReducer.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ describe('chartBuilderReducer', () => {
604604
},
605605
},
606606
},
607+
boundaryLevel: undefined,
607608
type: 'line',
608609
height: 300,
609610
title: 'Table title',
@@ -717,6 +718,7 @@ describe('chartBuilderReducer', () => {
717718
visible: true,
718719
},
719720
},
721+
boundaryLevel: undefined,
720722
type: 'line',
721723
height: 300,
722724
title: 'Table title',
@@ -815,6 +817,7 @@ describe('chartBuilderReducer', () => {
815817
visible: true,
816818
},
817819
},
820+
boundaryLevel: undefined,
818821
type: 'line',
819822
height: 300,
820823
title: '',
@@ -889,6 +892,7 @@ describe('chartBuilderReducer', () => {
889892
},
890893
},
891894
},
895+
boundaryLevel: undefined,
892896
type: 'line',
893897
height: 300,
894898
title: 'Chart title',

src/explore-education-statistics-admin/src/pages/release/pre-release/PreReleaseTableToolPage.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const PreReleaseTableToolPage = ({
5555
...query,
5656
},
5757
releaseId,
58+
query.boundaryLevel,
5859
),
5960
]);
6061

src/explore-education-statistics-common/src/modules/charts/components/__tests__/__data__/testChartData.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const testChartConfiguration: Chart = {
8787
tickConfig: 'default',
8888
},
8989
},
90+
boundaryLevel: undefined,
9091
type: 'line',
9192
title: 'Aggregated results chart',
9293
alt: 'Some alt text',

src/explore-education-statistics-common/src/modules/charts/components/__tests__/__data__/testMapBlockData.ts

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const testMapConfiguration: Chart = {
6969
},
7070
],
7171
},
72+
boundaryLevel: 1,
7273
type: 'map',
7374
title: '',
7475
alt: '',

src/explore-education-statistics-common/src/modules/find-statistics/components/DataBlockTabs.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ const DataBlockTabs = ({
4444
value: fullTable,
4545
isLoading,
4646
error,
47-
} = useTableQuery(releaseId, dataBlock.dataBlockParentId);
47+
} = useTableQuery(
48+
releaseId,
49+
dataBlock.dataBlockParentId,
50+
dataBlock.charts[0]?.boundaryLevel,
51+
);
4852

4953
const errorMessage = <WarningMessage>Could not load content</WarningMessage>;
5054

src/explore-education-statistics-common/src/modules/find-statistics/components/__tests__/DataBlockTabs.test.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ describe('DataBlockTabs', () => {
161161
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
162162
'release-1',
163163
'block-1-parent',
164+
undefined,
164165
);
165166

166167
expect(screen.getAllByText('Could not load content')).toHaveLength(2);
@@ -194,6 +195,7 @@ describe('DataBlockTabs', () => {
194195
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
195196
'release-1',
196197
'block-1-parent',
198+
undefined,
197199
);
198200

199201
expect(
@@ -225,6 +227,7 @@ describe('DataBlockTabs', () => {
225227
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
226228
'release-1',
227229
'block-1-parent',
230+
undefined,
228231
);
229232

230233
expect(screen.getAllByRole('tab')).toHaveLength(2);
@@ -260,6 +263,7 @@ describe('DataBlockTabs', () => {
260263
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
261264
'release-1',
262265
'block-1-parent',
266+
undefined,
263267
);
264268

265269
expect(screen.getAllByRole('tab')).toHaveLength(2);
@@ -294,6 +298,7 @@ describe('DataBlockTabs', () => {
294298
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
295299
'release-1',
296300
'block-1-parent',
301+
undefined,
297302
);
298303

299304
expect(screen.getAllByRole('tab')).toHaveLength(2);
@@ -334,6 +339,7 @@ describe('DataBlockTabs', () => {
334339
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
335340
'release-1',
336341
'block-1-parent',
342+
undefined,
337343
);
338344

339345
expect(screen.getByRole('table')).toBeInTheDocument();
@@ -362,6 +368,7 @@ describe('DataBlockTabs', () => {
362368
expect(tableBuilderService.getDataBlockTableData).toBeCalledWith(
363369
'release-1',
364370
'block-1-parent',
371+
1,
365372
);
366373

367374
expect(container.querySelector('.leaflet-container')).toBeInTheDocument();

src/explore-education-statistics-common/src/modules/find-statistics/hooks/useTableQuery.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import tableBuilderService from '@common/services/tableBuilderService';
66
export default function useTableQuery(
77
releaseId: string,
88
dataBlockParentId: string,
9+
boundaryLevelId?: number | undefined,
910
): AsyncRetryState<FullTable> {
1011
return useAsyncRetry(async () => {
1112
const response = await tableBuilderService.getDataBlockTableData(
1213
releaseId,
1314
dataBlockParentId,
15+
boundaryLevelId,
1416
);
1517

1618
return mapFullTable(response);

src/explore-education-statistics-common/src/services/tableBuilderService.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,16 @@ const tableBuilderService = {
244244
async getTableData(
245245
query: FullTableQuery,
246246
releaseId?: string,
247+
boundaryLevelId?: number | undefined,
247248
): Promise<TableDataResponse> {
248-
return releaseId
249+
if (releaseId && boundaryLevelId) {
250+
return dataApi.post(
251+
`/tablebuilder/release/${releaseId}/${boundaryLevelId}`,
252+
query,
253+
);
254+
}
255+
256+
return releaseId && !boundaryLevelId
249257
? dataApi.post(`/tablebuilder/release/${releaseId}`, query)
250258
: dataApi.post('/tablebuilder', query);
251259
},
@@ -267,10 +275,15 @@ const tableBuilderService = {
267275
async getDataBlockTableData(
268276
releaseId: string,
269277
dataBlockParentId: string,
278+
boundaryLevelId?: number | undefined,
270279
): Promise<TableDataResponse> {
271-
return dataApi.get(
272-
`/tablebuilder/release/${releaseId}/data-block/${dataBlockParentId}`,
273-
);
280+
return boundaryLevelId
281+
? dataApi.get(
282+
`/tablebuilder/release/${releaseId}/data-block/${dataBlockParentId}/${boundaryLevelId}`,
283+
)
284+
: dataApi.get(
285+
`/tablebuilder/release/${releaseId}/data-block/${dataBlockParentId}`,
286+
);
274287
},
275288
getFastTrackTableAndReleaseMeta(
276289
dataBlockParentId: string,

src/explore-education-statistics-common/src/services/types/blocks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type ChartAxesConfiguration = {
2525
*/
2626
export type Chart = OmitStrict<ChartRendererProps, 'data' | 'meta' | 'axes'> & {
2727
axes: ChartAxesConfiguration;
28+
boundaryLevel: number | undefined;
2829
};
2930

3031
export interface Table {

0 commit comments

Comments
 (0)