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

New Monthly Submissions Endpoint #1423

Merged
merged 4 commits into from
May 30, 2018
Merged

New Monthly Submissions Endpoint #1423

merged 4 commits into from
May 30, 2018

Conversation

Wambere
Copy link
Contributor

@Wambere Wambere commented May 25, 2018

  • Add new endpoint that returns the total number of submissions to a user's private and public forms
  • Add monthly submissions serializer
  • Add tests

Copy link
Member

@ukanga ukanga left a comment

Choose a reason for hiding this comment

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

Could you write up documentation for the new endpoint, this should be in the docs/profiles.rst I think.

label = 'public' if state else 'private'
result_dictionary[label] = i['num_instances']

get_result()
Copy link
Member

Choose a reason for hiding this comment

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

I see no reason for the get_result() function, the loop block could easily be not within a function and still work.

year = year_param if year_param else str(now.year)

instance_count = Instance.objects.filter(
xform__user=profile.user).filter(
Copy link
Member

Choose a reason for hiding this comment

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

is chaining filter instead of a single filter the best practice for this?

result_dictionary = {}

def get_result():
for state in states:
Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to do this without states and the extra outer loop around states

- Add monthly-submissions endpoint to the UserProfiles viewset which returns
  the total number of submissions in a given month to the user's forms
- Add monthly submissions serializer
- Add tests
- Change query to be more efficient
- Optimize code in serializer
- Add validation for the query parameters in the monthly submissions endpoint
- Return first item in the list, which is the dictionary with the total number of submissions
- Change the tests to check for a dictionary instead of a list of a dictionary
^^^^^^^^

::
[
Copy link
Member

Choose a reason for hiding this comment

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

I think this changed, it is no longer a list but an object response.

@ukanga ukanga merged commit 2fe415f into master May 30, 2018
@ukanga ukanga deleted the monthly-submissions branch May 30, 2018 08:08
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.

3 participants