CON-328 Add HTTP call to the slack when a meeting is ended#505
CON-328 Add HTTP call to the slack when a meeting is ended#505
Conversation
82fb602 to
775708d
Compare
f22261b to
b936f9b
Compare
b936f9b to
5981a90
Compare
joshuaocero
left a comment
There was a problem hiding this comment.
@Ramadhan0 there are a couple of things you need to work on. Please look into my feedback.
config.py
Outdated
| CELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND') | ||
|
|
||
| # slack bot url | ||
| notify_url = os.getenv('SLACK_NOTIFICATION_URL') |
There was a problem hiding this comment.
Please maintain consistency in variable naming. As you can see, all the other config variables are uppercased.
| """ | ||
|
|
||
| @celery.task(name="notify-slack") | ||
| def notify(event_Id): |
There was a problem hiding this comment.
Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)
|
|
||
| @celery.task(name="notify-slack") | ||
| def notify(event_Id): | ||
| requests.get(url=Config.notify_url+str(event_Id)) |
There was a problem hiding this comment.
Why are you casting event_Id to a string. Is it necessary? Also, please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)
There was a problem hiding this comment.
the event_id is an integer and the URL is a string
so, without converting event_id to a string was causing an error @joshuaocero
api/events/schema.py
Outdated
| event_reject_reason | ||
| ): | ||
| raise GraphQLError("Event cancelled but email not sent") | ||
| event_Id=kwargs['event_id'] |
There was a problem hiding this comment.
Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)
api/events/schema.py
Outdated
| ): | ||
| raise GraphQLError("Event cancelled but email not sent") | ||
| event_Id=kwargs['event_id'] | ||
| notify.delay(event_Id) |
There was a problem hiding this comment.
Please refer to variable naming conventions for event_Id. (https://www.python.org/dev/peps/pep-0008/#function-and-variable-names)
| @@ -0,0 +1,11 @@ | |||
| import requests | |||
There was a problem hiding this comment.
Make this filename leaner. It is already in a folder called events, no need to prefix the filename with event_.
| """ | ||
|
|
||
| @celery.task(name="notify-slack") | ||
| def notify(event_Id): |
There was a problem hiding this comment.
Please make this function name more descriptive. notify what? Think of a better function name. Ask yourself what exactly the function is doing then name it appropriately.
| class test_slack_notifier(unittest.TestCase): | ||
|
|
||
| @patch('helpers.event.event_slack_notifier.requests.get') | ||
| def test_add_room(self, mock_get_request): |
There was a problem hiding this comment.
Why is this function called test_add_room? You need to pay more attention to detail. Avoid unnecessary copying and pasting.
6e54f6f to
c8db89e
Compare
|
|
||
| def upgrade(): | ||
| op.add_column('events', sa.Column( | ||
| 'organizer_email', sa.String(), nullable=True)) |
There was a problem hiding this comment.
I just checked Samuel's PR and I saw that the organizer email is sent as a list since it is taking two emails, is this data type appropriate for storing it?
There was a problem hiding this comment.
I just wanna know from the list of 2 emails, how will I know which one is the actual organizer_email @mifeille
mifeille
left a comment
There was a problem hiding this comment.
Please validate organizerEmail and roomId fields.
- ensure the returned url is comprised with the organizer_email and room_id [Delivers CON-328]
Description
This feature ensures that an HTTP call is made to the slack integration micro-service when a meeting is ended, either by the user or when the meeting time runs out.
It sends out different arguments including the organizer_email, room_id, and the event_id.
How to test it:
SLACK_NOTIFICATION_URL=https://www.softwaretestinghelp.com/tools/30-top-website-link-verification-testing-tools/redismutation{ endEvent(calendarId:"andela.com_38393338303730373538@resource.calendar.google.com", eventId:"0manph5i3e8lnld6tnvb0o1pcc", organizerEmail:"converge.notification@andela.com", roomId: "18", startTime:"2018-08-19T23:00:00-07:00", endTime:"2018-08-20T05:00:00-07:00", meetingEndTime: "2018-08-14T07:00:00-07:00"){ event{ eventId eventTitle checkedIn cancelled meetingEndTime room{ id name calendarId } } } }200after finishing the task with a notify-slack name.Type of change
Please select the relevant option
How Has This Been Tested?
New feature
JIRA
CON-328
CV3-63