Skip to content

Commit d387fa5

Browse files
committed
Code review feedback
1 parent e1553a6 commit d387fa5

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

lib/importer/nunjucks/views/error-handling/server-error.njk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
{% endblock %}
4646

4747

48+
{% block footer %}
49+
{{ govukFooter({}) }}
50+
{% endblock %}
51+
52+
4853
{% block pageScripts %}
4954
<script>
5055
;(() => {

lib/importer/src/dudk/backend.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ exports.SessionGetColumnsNeedingFormats = (sid) => {
130130

131131
let columnsNeedingFormats = new Array();
132132

133-
Object.entries(mappings).forEach((entry) => {
134-
const [colIdx, columnAttribute] = entry;
133+
Object.entries(mappings).forEach((colIdx, columnAttribute) => {
135134
if(columnAttribute != "") {
136135
const columnDef = attributes.find((attr) => attr.name == columnAttribute);
137136
const columnTypeName = columnDef.type;

lib/importer/src/dudk/types/guesser.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,17 @@ exports.ListPossibleTypes = (field) => {
7777
// Either way, we can't narrow the set of possible types, but it's a blank cell
7878
return [false, true];
7979
case "d": // Date or time or both
80-
if(isDateFormat(field.z)) {
81-
possibleTypes.set("date", ["native"]);
80+
if(field.z) {
81+
if(isDateFormat(field.z)) {
82+
possibleTypes.set("date", ["native"]);
83+
}
84+
// FIXME: Add cases for time formats, eg "h:mm", when we support them
85+
return [possibleTypes, isBlank];
86+
} else {
87+
// Field format code in field.z should always be present, but let's fail
88+
// quietly if not rather than ruining the whole import
89+
return [possibleTypes, isBlank];
8290
}
83-
// FIXME: Add cases for time formats, eg "h:mm", when we support them
84-
return [possibleTypes, isBlank];
8591
break;
8692
case "s":
8793
// String

lib/importer/src/functions.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ const importerPossibleColumnFormats = (data) => {
9898
const dataRange = backend_lib.SessionSuggestDataRange(session.backendSid, hRange, fRange);
9999
const typeGuesses = backend_lib.SessionGuessTypes(session.backendSid, dataRange);
100100

101-
return Object.entries(mappings).map((entry) => {
102-
const [colIndex, columnField] = entry;
101+
return Object.entries(mappings).map((colIndex, columnField) => {
103102
if (!columnField) return false; // Skip unmapped columns
104103
const columnGuesses = typeGuesses[colIndex];
105104
const columnDef = session.fields.find((field) => field.name == columnField);
@@ -109,9 +108,7 @@ const importerPossibleColumnFormats = (data) => {
109108
if (columnGuesses.types && columnGuesses.types.has(columnTypeName)) {
110109
const guessedFormats = columnGuesses.types.get(columnTypeName);
111110
if(guessedFormats && columnType.formats) {
112-
likelyFormats = new Set(Array.from(columnType.formats.keys()).filter((fmtName) => {
113-
return guessedFormats.includes(fmtName);
114-
}));
111+
likelyFormats = new Set(Array.from(columnType.formats.keys()).filter((fmtName) => guessedFormats.includes(fmtName)));
115112
}
116113
}
117114

0 commit comments

Comments
 (0)