Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Made number of days ahread we should gather events for configurable a…
Browse files Browse the repository at this point in the history
…nd default to 14 days
  • Loading branch information
MatsAnd committed Sep 30, 2020
1 parent 86ce423 commit 93d1181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
tenantId: process.env.GRAPH_TENANT_ID || '08f3813c-9f29-482f-9aec-16ef7cbf477a'
},
events: {
endpoint: process.env.GRAPH_EVENTS_ENDPOINT || 'calendarview'
endpoint: process.env.GRAPH_EVENTS_ENDPOINT || 'calendarview',
eventsDaysAhead: process.env.GRAPH_EVENTS_DAYS_AHEAD || 14,
},
configList: {
sitesUrl: process.env.GRAPH_SITE_ENDPOINT || 'https://graph.microsoft.com/v1.0/sites',
Expand Down
6 changes: 3 additions & 3 deletions lib/graph/get-graph-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module.exports = async (context, token, userPrincipalName, graphUserUrl, daysAhe
context.log(['events', 'get-graph-events', userPrincipalName, 'get-events', 'url', graphUrl])

const now = new Date()
const oneWeek = new Date()
oneWeek.setDate(oneWeek.getDate() + (isNaN(daysAhead) ? 7 : parseInt(daysAhead.toString())))
const dateAhead = new Date()
dateAhead.setDate(dateAhead.getDate() + (isNaN(daysAhead) ? parseInt(events.eventsDaysAhead.toString()) : parseInt(daysAhead.toString())))

const { data } = await axios({
url: graphUrl,
Expand All @@ -29,7 +29,7 @@ module.exports = async (context, token, userPrincipalName, graphUserUrl, daysAhe
},
params: {
startDateTime: now.toISOString(),
endDateTime: oneWeek.toISOString(),
endDateTime: dateAhead.toISOString(),
$orderby: 'start/dateTime'
}
})
Expand Down

0 comments on commit 93d1181

Please # to comment.