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

feat: GET allowances #288

Merged
merged 4 commits into from
Jul 16, 2024
Merged

feat: GET allowances #288

merged 4 commits into from
Jul 16, 2024

Conversation

zacharis278
Copy link
Contributor

@zacharis278 zacharis278 commented Jul 15, 2024

JIRA: COSMO-368

Description: Adds API to retrieve a list of allowances by course id

The story suggested using generic DRF views for this since there's no business logic. I tried that out but found would introduce a new pattern without making it much simpler really. It would also mess with our class for exception logging

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  edx_exams/apps/api
  serializers.py
  edx_exams/apps/api/v1
  views.py
  edx_exams/apps/api/v1/tests
  test_views.py
  edx_exams/apps/core
  models.py
  edx_exams/apps/core/test_utils
  factories.py
Project Total  

This report was generated by python-coverage-comment-action

@zacharis278 zacharis278 force-pushed the zhancock/get-allowances branch from 3de7387 to f45a61d Compare July 15, 2024 16:10
@@ -109,6 +109,7 @@ class CourseStaffRoleAdmin(admin.ModelAdmin):
@admin.register(StudentAllowance)
class StudentAllowanceAdmin(admin.ModelAdmin):
""" Admin configuration for the Student Allowance model """
raw_id_fields = ('user', 'exam')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated since the default (a dropdown) is unusable for this on prod/stage

course_id=self.course_id,
)

def request_api(self, method, user, course_id):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

overbuilt in anticipation of post+delete endpoints

response = self.request_api('get', course_staff_user, self.course_id)
self.assertEqual(response.status_code, 200)

def test_get_allowances(self):
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a DB query count check? I want to ensure this API only call DB once or twice, for even 1000 returned records.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO we only need to check query counts if is there's something more interesting happening in the business logic or model that might hide DB issues. In this case it's a pretty straightforward use of .filter()

Copy link
Member

@schenedx schenedx left a comment

Choose a reason for hiding this comment

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

👍

@zacharis278 zacharis278 merged commit 4cf5d52 into main Jul 16, 2024
5 checks passed
@zacharis278 zacharis278 deleted the zhancock/get-allowances branch July 16, 2024 12:58
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