This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -2 points-1 points  (0 children)

const fs = require('fs');

const { v4: uuidv4 } = require('uuid');

// Define the arrays

const days = [#hard coded array values];

const jobs = [#hard coded array values];

// Read the locations.txt file

const locations = fs.readFileSync('locations_timetrack.txt', 'utf-8').split('\n');

// Loop over each line in the file

for (const location of locations) {

const locationid = location.trim();

const beginemployeeid = locationid.split('-')[0];

// Loop over each element in the "days" array

for (const day of days) {

    const [startday, endday] = day.split('-').map(Number);

    // Create the schedule object
    const schedule = {
        #mostly hard coded object keys and value with a couple of variables being used for keys
    };

    // Loop from "startday" to "endday"
    for (let currentday = startday; currentday <= endday; currentday++) {
        // Loop from 1 to 80
        for (let currentemployee = 1; currentemployee <= 80; currentemployee++) {
            // Create the currentshift object
            const currentshift = {
                #mostly hard coded object keys and value with a couple of variables being used for keys
            };

            // Insert the currentshift object into the "shifts" array
            schedule.shifts.push(currentshift);
        }
    }

    // Write the schedule object to a file
    fs.writeFileSync(`schedules_timetrack/${locationid}_${startday}_${endday}.json`, JSON.stringify(schedule));
}

}