Codeminer42 / marvin-cm42

Marvin is a chatbot built on the Hubot framework and used to help communication on Codeminer 42.
MIT License
15 stars 8 forks source link

`!calendar`: Fix Google API call to correctly retrieve events information. #36

Closed ramos-ph closed 2 years ago

ramos-ph commented 2 years ago

What does this PR do?

This PR updates the getCalendarEvents function used to retrieve data from marvin's Google Calendar. It moves the verification of dates in retrieveCalendar.js to be a parameter in on the request calls. It also fixes the date exhibition. Previously, when requesting from Google API, it would show the date of creation of the events instead of the date of ocurrence. Courtesy of @paulodiovani :

marvin> !calendar
marvin> 
> **Workshop: #opensource**
> _17 de set. de 2021 09:30_

> **Workshop: DevOps**
> _29 de set. de 2021 17:30_

> **Workshop: Modern-Java by Philipe e Martin**
> _6 de out. de 2021 17:00_

> **Grupo de estudos de frontend**
> _9 de nov. de 2021 16:30_

> **Grupo de estudos de Elixir**
> _27 de jan. de 2022 17:00_

> **Grupo de estudos Ruby by Sam, Paty e Boniatti**
> _28 de mar. de 2022 17:00_

Also, there's a small update on the response. Instead of bringing every event on the current week, It'll bring events between the current day and the end of the current week.

Where should the reviewer start?

The reviewer can start by seeing the changes on calendarEvents.js and the respective API call change.

NOTE: I'm opening this PR on a Friday, so there are no upcoming events. But you can hard-code a period to fetch data on calendarEvents.js:

// Current implementation
13  const currentDay = DateTime.local().setZone('America/Sao_Paulo').toISO()
14  const endOfTheCurrentWeek = DateTime.local().setZone('America/Sao_Paulo').endOf('week').toISO()

// Update .local() to define the period. This one is from Sunday to Saturday
13  const currentDay = DateTime.local(2022, 3, 27).setZone('America/Sao_Paulo').toISO()
14  const endOfTheCurrentWeek = DateTime.local(2022, 4, 2).setZone('America/Sao_Paulo').endOf('week').toISO()

Just run !calendar to see the changes

What testing has been done on this PR?

I've experimented a lot with the dates and events, trying to bring data from different periods. However, no new tests cases were added.

What are the relevant issues?

Currently when we run the !calendar command, we get an error.

Screenshots (if appropriate)

marinv1 marvin2

Is this change backwards compatible or is it a breaking change?

It's backwards compatible. Though it won't bring the same result, depending on the day you're running.

Observations

I took the liberty to include the "Workshops & Grupos de estudo" calendar on Marvin's Google account. It wasn't showing anything regarding that when you logged in, though it's on the same organization. Did this because it was one of my attempts to solve this issue. I apologize if this wasn't required.

adbatista commented 2 years ago

add this in the readme

 took the liberty to include the "Workshops & Grupos de estudo" calendar on Marvin's Google account.
It wasn't showing anything regarding that when you logged in, though it's on the same organization. Did this because it was one of my attempts to solve this issue.
I apologize if this wasn't required.

so if someone else wants to configure this for another company will know who to do it