From ac0597737d8473b57d33346f6c40edd2106c0ec8 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Wed, 3 Apr 2019 01:39:44 +0000 Subject: [configloader] eslint is great --- server/api/configloader.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'server/api/configloader.js') diff --git a/server/api/configloader.js b/server/api/configloader.js index bb8f9f5..bc09a59 100644 --- a/server/api/configloader.js +++ b/server/api/configloader.js @@ -43,7 +43,7 @@ noAuthRouter.getAsync('/:uuid', async (req, res) => { if (client.events[i].client_x_event.blacklist) blacklist.push(client.events[i].id) else if (client.events[i].important) importantEvents.push(client.events[i]) else events.push(client.events[i]) - } else console.log('Event ' + client.events[i].name + ' ist nicht intime' ) + } else console.log('Event ' + client.events[i].name + ' ist nicht intime') } importantEvents = importantEvents.filter(e => !blacklist.includes(e.id)) @@ -114,7 +114,7 @@ noAuthRouter.get('/getconfig/:configId', (req, res) => { }) }) -function checkEventNow(times) { +function checkEventNow (times) { var now = new Date() if (!times.repetitive) { if (times.start * 1000 <= now && now < times.end * 1000) return true @@ -139,10 +139,8 @@ function checkEventNow(times) { if (checkEventInterval(startDate, yesterday, times.intervalType, times.interval)) { startAtDay.setDate(startAtDay.getDate() - 1) overnight = true - } - else return false - } - else if (endAtDay < now && startAtDay > now) endAtDay.setDate(endAtDay.getDate() + 1) + } else return false + } else if (endAtDay < now && startAtDay > now) endAtDay.setDate(endAtDay.getDate() + 1) else if (endAtDay < now && startAtDay < now && endAtDay < startAtDay) endAtDay.setDate(endAtDay.getDate() + 1) if (!(times.monthMap[now.getMonth()] && (overnight ? times.dayMap[((yesterday.getDay() + 6) % 7)] : times.dayMap[((now.getDay() + 6) % 7)]) && startDate <= now && now < endDate && startAtDay <= now && now < endAtDay)) return false @@ -152,13 +150,13 @@ function checkEventNow(times) { return false } -function dateDiffInDays(a, b) { +function dateDiffInDays (a, b) { const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate()) const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate()) return Math.floor((utc2 - utc1) / (1000 * 3600 * 24)) } -function checkEventInterval(startDate, now, type, interval) { +function checkEventInterval (startDate, now, type, interval) { if (type === 'day') { let dateDiff = dateDiffInDays(startDate, now) if (dateDiff % interval === 0) return true @@ -183,7 +181,6 @@ function checkEventInterval(startDate, now, type, interval) { } } - async function fetchParentConfigs (groupIds, blacklist) { if (groupIds.length === 0) return { 'ids': [], 'type': '' } -- cgit v1.2.3-55-g7522