Skip to content

Commit fa4aa9e

Browse files
fixing linting errors (#54)
1 parent 2ea1494 commit fa4aa9e

5 files changed

Lines changed: 125 additions & 91 deletions

File tree

agency-indexes/DoE/magpie.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
22
"contact": {
3-
"email": "christopher.kowalczyk@inl.gov"
3+
"email": "holdensanchez2@llnl.gov"
44
},
55
"date": {
6-
"created": "2018-04-24",
7-
"metadataLastUpdated": "2023-03-15"
6+
"created": "2018-07-30",
7+
"metadataLastUpdated": "2020-02-05"
88
},
9-
"description": "Mesoscale Atomistic Glue Program for Integrated Execution",
10-
"laborHours": 14333.6,
9+
"description": "Magpie contains a number of scripts for running Big Data software in HPC environments, including Hadoop and Spark. There is support for Lustre, Slurm, Moab, Torque. and LSF.\n",
10+
"laborHours": 52607.2,
1111
"languages": [],
12-
"name": "magpie",
13-
"organization": "Idaho National Laboratory (INL)",
12+
"name": "Magpie",
13+
"organization": "Lawrence Livermore National Laboratory (LLNL)",
1414
"permissions": {
1515
"exemptionText": null,
1616
"licenses": [
1717
{
18-
"URL": "https://api.github.com/licenses/lgpl-2.1",
19-
"name": "LGPL-2.1"
18+
"URL": "https://api.github.com/licenses/gpl-2.0",
19+
"name": "GPL-2.0"
2020
}
2121
],
2222
"usageType": "openSource"
2323
},
24-
"repositoryURL": "https://github.com/idaholab/magpie",
24+
"repositoryURL": "https://github.com/LLNL/magpie",
2525
"status": "Production",
2626
"tags": [
2727
"DOE CODE",
28-
"Idaho National Laboratory (INL)"
28+
"Lawrence Livermore National Laboratory (LLNL)"
2929
],
3030
"vcs": "git"
3131
}

assets/_common/js/filters.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ const applySelectFilters = (data, filters, targetType) => Object.entries(filters
5959

6060
switch (key) {
6161
case 'language':
62-
actualKey = 'languages'
62+
actualKey = 'languages';
6363
break;
6464
case 'category':
65-
actualKey = 'categories'
65+
actualKey = 'categories';
6666
break;
6767
case 'platform':
68-
actualKey = 'platforms'
68+
actualKey = 'platforms';
6969
break;
7070
case 'agency':
71-
actualKey = 'agencyName'
71+
actualKey = 'agencyName';
72+
break;
73+
default:
7274
break;
7375
}
7476

@@ -107,10 +109,15 @@ const sortData = (data, sortBy) => {
107109
return 0;
108110
}
109111

112+
if (aVal === bVal) {
113+
return 0;
114+
}
115+
110116
if (direction === 'desc') {
111-
return aVal < bVal ? 1 : aVal > bVal ? -1 : 0;
117+
return aVal < bVal ? 1 : -1;
112118
}
113-
return aVal > bVal ? 1 : aVal < bVal ? -1 : 0;
119+
120+
return aVal > bVal ? 1 : -1;
114121
});
115122
};
116123

@@ -165,7 +172,7 @@ const createProjectCardHTML = (project) => {
165172
if (Array.isArray(value)) return value;
166173
if (typeof value === 'string') return [value];
167174
return [];
168-
}
175+
};
169176

170177
return `
171178
<div class="project-card">
@@ -213,7 +220,7 @@ const createCard = (item, targetType) => {
213220
const cardElement = document.createElement('div');
214221
cardElement.innerHTML = targetType === 'agencies'
215222
? createAgencyCardHTML(item)
216-
: createProjectCardHTML(item)
223+
: createProjectCardHTML(item);
217224

218225
return cardElement.firstElementChild;
219226
};
@@ -229,7 +236,7 @@ const updateDisplay = (state) => {
229236

230237
state.filteredData.forEach(item => {
231238
const card = createCard(item, state.targetType);
232-
container.appendChild(card)
239+
container.appendChild(card);
233240
});
234241
};
235242

@@ -353,4 +360,4 @@ document.addEventListener('DOMContentLoaded', () => {
353360
}
354361
}
355362
}
356-
});
363+
});

assets/_common/js/issue-filters.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ const sortData = (data, sortBy) => {
8181
return 0;
8282
}
8383

84+
if (aVal === bVal) {
85+
return 0;
86+
}
87+
8488
if (direction === 'desc') {
85-
return aVal < bVal ? 1 : aVal > bVal ? -1 : 0;
89+
return aVal < bVal ? 1 : -1;
8690
}
87-
return aVal > bVal ? 1 : aVal < bVal ? -1 : 0;
91+
92+
return aVal > bVal ? 1 : -1;
8893
});
8994
};
9095

@@ -159,7 +164,7 @@ const createIssueCardHTML = (issue) => {
159164
`;
160165
};
161166

162-
const createCard = (item, targetType) => {
167+
const createCard = (item) => {
163168
const cardElement = document.createElement('div');
164169
cardElement.innerHTML = createIssueCardHTML(item);
165170
return cardElement.firstElementChild;
@@ -176,7 +181,7 @@ const updateDisplay = (state) => {
176181

177182
container.innerHTML = '';
178183
state.filteredData.forEach(item => {
179-
const card = createCard(item, state.targetType);
184+
const card = createCard(item);
180185
container.appendChild(card);
181186
});
182187
};
@@ -342,4 +347,4 @@ document.addEventListener('DOMContentLoaded', () => {
342347
}
343348
}
344349
}
345-
});
350+
});

config/updateCodeGov.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,38 @@ async function updateCodeGov() {
1919

2020
// read all files in the directory
2121
const filenames = await fs.readdir(CONFIG.agencyDirectory)
22-
23-
// we know that the directory will only contain json files so dont need to check for non jsons
24-
for (const file of filenames) {
25-
const filePath = path.join(CONFIG.agencyDirectory, file)
26-
27-
try {
28-
const content = await fs.readFile(filePath, 'utf-8')
29-
const jsonData = JSON.parse(content)
30-
31-
// store the agency name only for readability in codegov.json
32-
const matches = file.match(CONFIG.regex)
33-
const agencyName = matches[1]
3422

23+
const processedFiles = await Promise.all(
24+
filenames.map(async (file) => {
25+
const filePath = path.join(CONFIG.agencyDirectory, file)
26+
27+
try {
28+
const content = await fs.readFile(filePath, 'utf-8')
29+
const jsonData = JSON.parse(content)
30+
31+
// store the agency name only for readability in codegov.json
32+
const matches = file.match(CONFIG.regex)
33+
const agencyName = matches ? matches[1] : null
34+
35+
if (!agencyName) {
36+
return null
37+
}
38+
39+
console.log(`✅ Successfully processed: ${file}`)
40+
return [agencyName, jsonData]
41+
} catch (error) {
42+
console.error(`❌ Error processing file: ${file}`, error)
43+
return null
44+
}
45+
})
46+
)
47+
48+
processedFiles.forEach((entry) => {
49+
if (entry) {
50+
const [agencyName, jsonData] = entry
3551
updatedJSON[agencyName] = jsonData
36-
console.log(`✅ Successfully processed: ${file}`)
37-
} catch (error) {
38-
console.error(`❌ Error processing file: ${file}`, error)
3952
}
40-
}
53+
})
4154

4255
// actually update the codegov.json file
4356
const jsonString = JSON.stringify(updatedJSON, null, 2)
@@ -46,7 +59,8 @@ async function updateCodeGov() {
4659
return updatedJSON
4760
} catch (error) {
4861
console.error('❌ Failed to update codegov.json:', error)
62+
return null
4963
}
5064
}
5165

52-
updateCodeGov()
66+
updateCodeGov()

0 commit comments

Comments
 (0)