Skip to content

Commit

Permalink
Clean up a little bit. Add a detail to the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Hughes committed Apr 8, 2022
1 parent 0453a96 commit 5a3b7c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All secrets (Google JWT, Twilio keys, your phone number, the Twilio phone number

# setup

Add a secret to your AWS secrets manager with the values indicated in secret_example.json. Copy the ARN of that secret and paste it in place of <SECRET_ARN> in serverless.yml. While you're there, enter your usual timezone in place of <YOUR_TIMEZONE>. Sorry, this tool won't work well for travelers...
Add a secret named calendarbot_auth to your AWS secrets manager with the values indicated in secret_example.json. Copy the ARN of that secret and paste it in place of <SECRET_ARN> in serverless.yml. While you're there, enter your usual timezone in place of <YOUR_TIMEZONE>. Sorry, this tool won't work well for travelers...

Setup Serverless if you haven't already. See https://www.serverless.com/framework/docs/getting-started. Replace <YOUR_ORG> in package.json with your Serverless org's name.

Expand Down
24 changes: 13 additions & 11 deletions src/eventProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@ const formatEvents = pipe(
);

const now = new Date();
const nextHour = new Date(now);
nextHour.setHours(now.getHours() + 1);
const isInNextHour = date =>
date.getHours() === nextHour.getHours() &&

const isInNextHour = date => {
const nextHour = new Date(now);
nextHour.setHours(now.getHours() + 1);
return date.getHours() === nextHour.getHours() &&
date.getDate() === nextHour.getDate();
}

const isInNextDate = date => {
const testDate = new Date(now);
testDate.setDate(testDate.getDate() + 1);
return date.getDate() === testDate.getDate();
const nextDate = new Date(now);
nextDate.setDate(nextDate.getDate() + 1);
return date.getDate() === nextDate.getDate();
}

const isInNextWeek = date => {
const testDate = new Date(now);
testDate.setDate(testDate.getDate() + 7);
return date.getDate() <= testDate.getDate();
const nextWeek = new Date(now);
nextWeek.setDate(nextWeek.getDate() + 7);
return date.getDate() <= nextWeek.getDate();
}

const buildFilterEvents = comparator => pipe(
path(['data', 'items']),
filter(pipe(
path(startPath),
start => new Date(start),
newDate,
comparator,
)),
);
Expand Down

0 comments on commit 5a3b7c2

Please sign in to comment.