-
Notifications
You must be signed in to change notification settings - Fork 132
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
Conversation
Wambere
commented
May 25, 2018
•
edited
Loading
edited
- Add new endpoint that returns the total number of submissions to a user's private and public forms
- Add monthly submissions serializer
- Add tests
c46f6f1
to
5b8a45c
Compare
There was a problem hiding this 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() |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
650216b
to
9b44213
Compare
docs/profiles.rst
Outdated
^^^^^^^^ | ||
|
||
:: | ||
[ |
There was a problem hiding this comment.
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.