Skip to content

CON-297 Refresh channels on a bouquet#25

Open
mnswaleh wants to merge 1 commit intov2from
story/CON-297-refresh-channels-on-bouquet
Open

CON-297 Refresh channels on a bouquet#25
mnswaleh wants to merge 1 commit intov2from
story/CON-297-refresh-channels-on-bouquet

Conversation

@mnswaleh
Copy link

@mnswaleh mnswaleh commented Sep 10, 2019

Description

This pull request creates an endpoint that refreshes channels in a particular bouquet.

How can This be tested

  • Clone the repo: git clone https://github.com/andela/mrm_api.git
  • Setup project according to Readme.md
  • checkout to branch story/CON-297-refresh-channels-on-bouquet
  • to refresh channels in a restful bouquet, hit the endpoint v2/refresh/restful_api/<bouquet_id> with a post request
  • to refresh channels in a graphql bouquet, hit the endpoint v2/refresh/graphql_api/<bouquet_id> with a post request
  • to run migrations
    alembic stamp ____
    alembic upgrade head
  • to run tests and test coverage pytest --cov=api/v2 --cov-report=term-missing

Type of change

Please select the relevant option

  • Bugfix(a non-breaking change which fixes an issue)
  • New feature(a non-breaking change which adds functionality)
  • Breaking change(fix of a feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have linted my code prior to submission
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

JIRA

CON-297

Relevant screenshots:

Screenshot 2019-09-12 at 13 43 04

@mnswaleh mnswaleh added the WIP label Sep 10, 2019
@mnswaleh mnswaleh force-pushed the story/CON-297-refresh-channels-on-bouquet branch from b02bfeb to e2bbae4 Compare September 11, 2019 14:33
- add restful refresh endpoint
- add graphql refresh endpoint
[Delivers CON-269]
@mnswaleh mnswaleh force-pushed the story/CON-297-refresh-channels-on-bouquet branch from e2bbae4 to 632f856 Compare September 12, 2019 10:40
@mnswaleh mnswaleh removed the WIP label Sep 12, 2019
Copy link
Contributor

@joshuaocero joshuaocero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnswaleh this is a well-written feature, please see some of my recommendations though. Also, after the registerChannels() feature is implemented, we'll have to call that functionality after the refresh. Please make a mental note of that.


from api.v2.controllers.channels.channels_controller import Channels
from api.v2.controllers.boquets.bouquets_controller import Bouquets
from api.v2.controllers.boquets.bouquets_controller import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's fix the typo boquets, it should be bouquet.

bouquet = query_bouquet(bouquet_id)
if bouquet:
response = {'response':
{"Error": "Refresh endpoint not responding appropriatly"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct typo appropriatly

if bouquet:
response = {'response':
{"Error": "Refresh endpoint not responding appropriatly"},
'code': 424
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we are using this HTTP status code? It seems to represent failed dependencies and does not seem to be a standard HTTP status code. Please shed some more light here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to check if the refresh URL endpoint is responding as required. If an error occurs at this point it is to be because of that dependency and not necessarily on our endpoint

return bouquet


def refresh_bouquet_channels(api_type, bouquet_id):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation can take a while if you are waiting for a response. Let's consider using Celery to queue requests and create a notifications table to store tasks statuses which users will use to monitor their tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants