Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/enums/days.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module.exports.dayFromIndex = (i) => (Number.isInteger(i) && DAYS[i]) || null;
*/
module.exports.indexFromDay = (s) => {
const n = normalizeDay(s);
if (!n) return null;
if (!n) {
return null;
}
const i = DAYS.indexOf(n);
return i === -1 ? null : i;
};
Expand Down
29 changes: 15 additions & 14 deletions backend/schedule/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('dotenv').config;
* @returns {Promise<Array<string>} Team IDs
*/
async function getTeams(db) {
const response = await db
return db
.collection('team')
.find({})
.toArray()
Expand All @@ -17,7 +17,6 @@ async function getTeams(db) {
clustersPerDay: data.clusters_per_day
}))
);
return response;
}

async function getTeamsOrderedByEffectiveCapacity(db) {
Expand Down Expand Up @@ -77,7 +76,7 @@ async function isWorkingDay(db, date) {
if (isWeekend) {
return false;
}
const response = await db.collection('closedDay').findOne({ day: day });
const response = await db.collection('closedDay').findOne({ day });

return !response;
}
Expand All @@ -91,8 +90,8 @@ async function isWorkingDay(db, date) {
async function generateScheduleForDay(db, date) {
const teams = await getTeamsOrderedByEffectiveCapacity(db);

for (let i = 0; i < teams.length; i++) {
const team = teams[i];
for (const element of teams) {
const team = element;
// get pools for team
const pools = await db.collection('teampool').find({ teamId: team.id }).toArray();
const poolIds = pools.map((p) => p.poolId);
Expand Down Expand Up @@ -162,7 +161,7 @@ async function getNextPerson(db, teamId) {
if (people.length === 0) {
console.log('People assigned, unscheduling people...');
await db.collection('person').updateMany(
{ teamId: teamId },
{ teamId },
{
$set: {
scheduled: false
Expand All @@ -172,7 +171,7 @@ async function getNextPerson(db, teamId) {
people = await db
.collection('person')
.find({
teamId: teamId,
teamId,
$or: [{ scheduled: false }, { scheduled: { $exists: false } }]
})
.toArray();
Expand Down Expand Up @@ -228,8 +227,8 @@ async function generateUpToDay(db, date) {
cursor.setDate(cursor.getDate() + 1);
}

for (let i = 0; i < dates.length; i++) {
await generateScheduleForDay(db, dates[i]);
for (const element of dates) {
await generateScheduleForDay(db, element);
}
}

Expand Down Expand Up @@ -290,9 +289,9 @@ async function formatScheduleForDay(db, date) {

const scheduleDict = {};

for (let i = 0; i < response.length; i++) {
const person = response[i].personId;
const cluster = response[i].clusterId;
for (const element of response) {
const person = element.personId;
const cluster = element.clusterId;

(scheduleDict[person] ??= []).push(cluster);
}
Expand Down Expand Up @@ -320,7 +319,9 @@ async function handleStateChange(db) {
day: { $gte: dateFrom }
});

if (!scheduleExists) return;
if (!scheduleExists) {
return;
}

await db.collection('schedule').deleteMany({
day: { $gte: dateFrom }
Expand All @@ -329,5 +330,5 @@ async function handleStateChange(db) {

module.exports = {
getScheduleForDay: formatScheduleForDay,
handleStateChange: handleStateChange
handleStateChange
};
4 changes: 2 additions & 2 deletions backend/services/dailyReport/dailyReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = async (db) => {
.then((res) =>
res.map(({ _id, clusterId }) => ({
id: _id.toString(),
clusterId: clusterId
clusterId
}))
);

Expand Down Expand Up @@ -80,7 +80,7 @@ module.exports = async (db) => {
}

await db.collection('overviewReport').insertOne({
date: Long.fromNumber(new Date().getTime()),
date: Long.fromNumber(Date.now()),
reports: reports.map((report) => report.id),
missing: missingReports
});
Expand Down
3 changes: 3 additions & 0 deletions backend/services/templater/templateInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
},
{
"content": "Confirm home directories and shared filesystems are accessible."
},
{
"content": "Check node accessibility\n```sh\nfor node in node{\n01..06\n}; do\necho -n \"$node: \"\nstart=$(date +%s%N)\nssh -o BatchMode=yes -o ConnectTimeout=5 \"$node\"\"exit\"\nend=$(date +%s%N)\necho \"$(( (end-start)/1000000 )) ms\"\ndone```"
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions backend/services/templater/templateIt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs/promises');
const path = require('path');
const fs = require('node:fs/promises');
const path = require('node:path');

/**
* Adds a basic template to the HPC cluster so it has generic instructions and methods
Expand Down
Loading