Skip to content

Commit 3bc1ad7

Browse files
authored
Merge pull request #2015 from trendscenter/fix/2014-covariates-automap-missing-issue
Fix/2014 covariates automap missing issue
2 parents 9e9f9c1 + 538b5cb commit 3bc1ad7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/coinstac-desktop-app/app/render/utils/csv-column-auto-map.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,21 @@ function findMatchInVariables(variables, column) {
5050
}
5151

5252
function mapVariablesToColumns(variables, columns) {
53-
const map = [];
53+
const map = {};
5454

5555
columns.forEach((column) => {
5656
const match = findMatchInVariables(variables, column);
5757

58-
if (match) {
59-
map.push({ variable: match, column });
58+
if (match && !map[match]) {
59+
map[match] = column;
6060
}
6161
});
6262

63-
return map.length > 0 ? map : null;
63+
if (Object.keys(map).length > 0) {
64+
return Object.keys(map).map(variable => ({ variable, column: map[variable] }));
65+
}
66+
67+
return null;
6468
}
6569

6670
export default mapVariablesToColumns;

0 commit comments

Comments
 (0)