Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Campaign Service and Campaign static methods #3893

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

d-rita
Copy link
Contributor

@d-rita d-rita commented Nov 19, 2020

What does this PR do?
This PR refactors the Campaign and Campaign Service static methods.

Steps Taken:

  • Add a new static method in the Organisation Service class to get all the organisations under a campaign
  • Add a new static method to convert a collection of campaigns to a List DTO
  • Move replicated static methods from the Campaign model to the Campaign Service class
  • Refactor methods to make use of newly added ones.

Some of the URLs to test:

  1. Via Postman. Method: GET.
  • http://127.0.0.1:5000/api/v2/campaigns/
  • http://127.0.0.1:5000/api/v2/campaigns/<int:campaign_id>/
  • http://127.0.0.1:5000/api/v2/organisations/<int:organisation_id>/campaigns/
  • http://127.0.0.1:5000/api/v2/projects/<int:project_id>/campaigns/
  1. Frontend
  • http://localhost:3000/manage/campaigns/
  • http://localhost:3000/manage/campaigns/<int:campaign_id>

@willemarcel
Copy link
Contributor

I like the new structure. We are not supporting to assign organizations with campaigns on the frontend and we are not using that information of organizations related to a campaign.

I think the best would be to remove that organization field from the campaign detail endpoint. When we have that need we can build a new endpoint: /api/v2/campaigns/<int:campaign_id>/organisations/

Copy link
Contributor

@willemarcel willemarcel left a comment

Choose a reason for hiding this comment

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

comment above

@d-rita d-rita closed this Nov 20, 2020
@d-rita d-rita reopened this Nov 20, 2020
@d-rita d-rita force-pushed the refactor/campaign-service-methods branch from 0fe8259 to 7a2fdcb Compare November 20, 2020 13:07
- Add separate method to get campaign organisations
- Move similar methods from Campaign model to Campaign service
- Add new method to return CampaignListDTO
- Remove organisation detail from returned campaign
@d-rita d-rita force-pushed the refactor/campaign-service-methods branch from 7a2fdcb to fbe6a89 Compare November 20, 2020 13:21
Copy link
Contributor

@willemarcel willemarcel left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!

@willemarcel willemarcel merged commit b326283 into develop Nov 30, 2020
@willemarcel willemarcel deleted the refactor/campaign-service-methods branch November 30, 2020 10:30
@willemarcel willemarcel added this to the 4.2.2 milestone Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants