function to save calendar data to seperate .json files
This commit is contained in:
parent
3578ea262d
commit
318f585689
1 changed files with 16 additions and 1 deletions
17
server.js
17
server.js
|
@ -114,7 +114,7 @@ app.get('/calendar/:id', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
//function to save CalendarData to calendars.json
|
//function to save CalendarData to calendars.json
|
||||||
function saveCalendarData(calendarId, linkGroupName, calendars) {
|
function saveCalendarDataJoint(calendarId, linkGroupName, calendars) {
|
||||||
let calendarsData = { mergedCalendars: [] };
|
let calendarsData = { mergedCalendars: [] };
|
||||||
if (fs.existsSync(CALENDARS_FILE)) {
|
if (fs.existsSync(CALENDARS_FILE)) {
|
||||||
try {
|
try {
|
||||||
|
@ -143,6 +143,21 @@ function saveCalendarData(calendarId, linkGroupName, calendars) {
|
||||||
console.error('Error writing to calendars file:', error);
|
console.error('Error writing to calendars file:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//function to save calendar data to seperate .json files
|
||||||
|
function saveCalendarData(calendarId, linkGroupName, calendars) {
|
||||||
|
const calendarFile = `${MERGED_CALENDARS_DIR}/${calendarId}.json`;
|
||||||
|
const calendarData = {
|
||||||
|
id: calendarId,
|
||||||
|
linkGroupName: linkGroupName,
|
||||||
|
calendars: calendars
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(calendarFile, JSON.stringify(calendarData, null, 2));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error writing to calendar file:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to update the merged calendar
|
// Function to update the merged calendar
|
||||||
async function updateMergedCalendars(calendarId){
|
async function updateMergedCalendars(calendarId){
|
||||||
|
|
Loading…
Add table
Reference in a new issue