Skip to content

Commit a1f8992

Browse files
committed
EES-4856 Move Variables to DataSetFileFileViewModel and update frontend interfaces
1 parent fb93322 commit a1f8992

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

src/GovUk.Education.ExploreEducationStatistics.Content.Api.Tests/Controllers/DataSetFilesControllerTests.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2187,21 +2187,21 @@ await publicBlobStorageService.UploadFile(
21872187
var response = await client.GetAsync(uri);
21882188
var viewModel = response.AssertOk<DataSetFileViewModel>();
21892189

2190-
Assert.Equal(7, viewModel.Variables.Count);
2191-
Assert.Equal("A_filter_1", viewModel.Variables[0].Value);
2192-
Assert.Equal("Filter 1 - hint", viewModel.Variables[0].Label);
2193-
Assert.Equal("B_indicator_3", viewModel.Variables[1].Value);
2194-
Assert.Equal("Indicator 3", viewModel.Variables[1].Label);
2195-
Assert.Equal("C_filter_3", viewModel.Variables[2].Value);
2196-
Assert.Equal("Filter 3 - Another hint", viewModel.Variables[2].Label);
2197-
Assert.Equal("D_indicator_1", viewModel.Variables[3].Value);
2198-
Assert.Equal("Indicator 1", viewModel.Variables[3].Label);
2199-
Assert.Equal("E_indicator_2", viewModel.Variables[4].Value);
2200-
Assert.Equal("Indicator 2", viewModel.Variables[4].Label);
2201-
Assert.Equal("F_indicator_4", viewModel.Variables[5].Value);
2202-
Assert.Equal("Indicator 4", viewModel.Variables[5].Label);
2203-
Assert.Equal("G_filter_2", viewModel.Variables[6].Value);
2204-
Assert.Equal("Filter 2", viewModel.Variables[6].Label);
2190+
Assert.Equal(7, viewModel.File.Variables.Count);
2191+
Assert.Equal("A_filter_1", viewModel.File.Variables[0].Value);
2192+
Assert.Equal("Filter 1 - hint", viewModel.File.Variables[0].Label);
2193+
Assert.Equal("B_indicator_3", viewModel.File.Variables[1].Value);
2194+
Assert.Equal("Indicator 3", viewModel.File.Variables[1].Label);
2195+
Assert.Equal("C_filter_3", viewModel.File.Variables[2].Value);
2196+
Assert.Equal("Filter 3 - Another hint", viewModel.File.Variables[2].Label);
2197+
Assert.Equal("D_indicator_1", viewModel.File.Variables[3].Value);
2198+
Assert.Equal("Indicator 1", viewModel.File.Variables[3].Label);
2199+
Assert.Equal("E_indicator_2", viewModel.File.Variables[4].Value);
2200+
Assert.Equal("Indicator 2", viewModel.File.Variables[4].Label);
2201+
Assert.Equal("F_indicator_4", viewModel.File.Variables[5].Value);
2202+
Assert.Equal("Indicator 4", viewModel.File.Variables[5].Label);
2203+
Assert.Equal("G_filter_2", viewModel.File.Variables[6].Value);
2204+
Assert.Equal("Filter 2", viewModel.File.Variables[6].Label);
22052205
}
22062206

22072207
[Fact]

src/GovUk.Education.ExploreEducationStatistics.Content.Services/DataSetFileService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ public async Task<Either<ActionResult, DataSetFileViewModel>> GetDataSetFile(
208208
Name = releaseFile.File.Filename,
209209
Size = releaseFile.File.DisplaySize(),
210210
DataCsvPreview = dataCsvPreview,
211+
Variables = variables,
211212
},
212213
Meta = BuildDataSetFileMetaViewModel(
213214
releaseFile.File.DataSetFileMeta,
214215
releaseFile.FilterSequence,
215216
releaseFile.IndicatorSequence),
216-
Variables = variables,
217217
Footnotes = FootnotesViewModelBuilder.BuildFootnotes(footnotes),
218218
Api = BuildDataSetFileApiViewModel(releaseFile.File)
219219
};

src/GovUk.Education.ExploreEducationStatistics.Content.ViewModels/DataSetFileViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public record DataSetFileViewModel
2222

2323
public required List<FootnoteViewModel> Footnotes { get; init; } = [];
2424

25-
public required List<LabelValue> Variables { get; init; } = [];
26-
2725
public DataSetFileApiViewModel? Api { get; set; }
2826
}
2927

@@ -65,4 +63,6 @@ public record DataSetFileFileViewModel
6563
public required string Size { get; init; } = string.Empty;
6664

6765
public required DataSetFileCsvPreviewViewModel DataCsvPreview { get; init; } = new();
66+
67+
public required List<LabelValue> Variables { get; init; } = [];
6868
}

src/explore-education-statistics-frontend/src/modules/data-catalogue/__data__/testDataSets.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ export const testDataSetFileSummaries: DataSetFileSummary[] = [
111111

112112
export const testDataSet: DataSetFile = {
113113
id: 'datasetfile-id',
114-
file: { id: 'file-id', name: 'file name', size: 'file size' },
114+
file: {
115+
id: 'file-id',
116+
name: 'file name',
117+
size: 'file size',
118+
dataCsvPreview: { headers: ['column_1'], rows: [['1']] },
119+
variables: [{ value: 'column_1', label: 'Column 1 is for something' }],
120+
},
115121
release: {
116122
id: 'release-id',
117123
isLatestPublishedRelease: true,
@@ -138,4 +144,5 @@ export const testDataSet: DataSetFile = {
138144
geographicLevels: ['Local authority', 'National'],
139145
indicators: ['Indicator 1', 'Indicator 2'],
140146
},
147+
footnotes: [{ id: 'footnote-1', label: 'Footnote 1' }],
141148
};

src/explore-education-statistics-frontend/src/services/dataSetFileService.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ export interface DataSetFile {
77
id: string;
88
title: string;
99
summary: string;
10-
file: { id: string; name: string; size: string };
10+
file: {
11+
id: string;
12+
name: string;
13+
size: string;
14+
dataCsvPreview: {
15+
headers: string[];
16+
rows: string[][];
17+
};
18+
variables: { label: string; value: string }[];
19+
};
1120
release: {
1221
id: string;
1322
isLatestPublishedRelease: boolean;
@@ -22,7 +31,6 @@ export interface DataSetFile {
2231
title: string;
2332
type: ReleaseType;
2433
};
25-
api?: DataSetFileApi;
2634
meta: {
2735
geographicLevels: string[];
2836
timePeriod: {
@@ -33,6 +41,8 @@ export interface DataSetFile {
3341
filters: string[];
3442
indicators: string[];
3543
};
44+
footnotes: { id: string; label: string }[];
45+
api?: DataSetFileApi;
3646
}
3747

3848
export interface DataSetFileSummary {

0 commit comments

Comments
 (0)