-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add payment statistics API endpoint #366
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
base: main
Are you sure you want to change the base?
Conversation
- Add PaymentStatisticsView to provide sales metrics including total sales, order count, average order value, and daily breakdown - Add get_payment_statistics function for aggregating payment data - Add API documentation for the payment statistics endpoint - Add comprehensive tests for payment statistics - Fix duplicate test class definitions in test_views.py that were causing coverage failures (TestCoursesFeedbackView and TestLibrariesView) - Add mock models for Cart, CartItem, and CatalogueItem for testing
cb5fe57 to
2b9f1b5
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.
Pull request overview
This PR adds a new payment statistics API endpoint to provide sales metrics for courses, including total sales, order count, average order value, and daily breakdowns. It also includes test infrastructure improvements and fixes for duplicate test class definitions.
- Adds PaymentStatisticsView with comprehensive date filtering and tenant-based access control
- Implements get_payment_statistics function with permission-based course filtering
- Upgrades mock zeitlabs_payments models from simple classes to proper Django models for better testing
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| futurex_openedx_extensions/dashboard/views.py | Adds PaymentStatisticsView with date/course/tenant filtering and permission checks |
| futurex_openedx_extensions/dashboard/statistics/payments.py | Implements core payment statistics aggregation logic with daily breakdowns |
| futurex_openedx_extensions/dashboard/urls.py | Registers new payment statistics endpoint |
| futurex_openedx_extensions/dashboard/docs_src.py | Adds API documentation for payment statistics endpoint |
| tests/test_dashboard/test_views.py | Removes duplicate test classes and adds comprehensive PaymentStatisticsView tests |
| tests/test_dashboard/test_statistics/test_payments.py | Adds unit tests for payment statistics function |
| tests/test_dashboard/test_serializers.py | Adds additional serializer validation tests |
| test_utils/edx_platform_mocks_shared/zeitlabs_payments/models.py | Converts mock models to proper Django models with relationships |
| tests/conftest.py | Adds gc_collect fixture to mitigate potential memory issues |
| tox.ini | Excludes zeitlabs-payments directory and sets PYTHONHASHSEED for reproducibility |
| docs/concepts/payment_statistics.rst | Adds comprehensive documentation of payment statistics mathematical logic |
| docs/concepts/index.rst | Updates documentation index to include payment statistics concept |
| futurex_openedx_extensions/helpers/admin.py | Adds commented-out permission methods (should be cleaned up) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # def has_add_permission(self, request: Any) -> bool: # pylint: disable=unused-argument | ||
| # """Disable add permission for CacheInvalidator.""" | ||
| # return False | ||
|
|
||
| # def has_change_permission(self, request: Any, obj: Any = None) -> bool: # pylint: disable=unused-argument | ||
| # """Disable change permission for CacheInvalidator.""" | ||
| # return False | ||
|
|
||
| # def has_delete_permission(self, request: Any, obj: Any = None) -> bool: # pylint: disable=unused-argument | ||
| # """Disable delete permission for CacheInvalidator.""" | ||
| # return False |
Copilot
AI
Dec 30, 2025
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.
Commented-out code should be removed. If these permission methods need to be disabled, they should either be removed entirely or uncommented with proper justification. Keeping commented-out code reduces code maintainability and clarity.
| ' following are the available tags along with the fields they include:\n' | ||
| '| tag | mapped fields |\n' | ||
| '|-----|---------------|\n' | ||
|
|
Copilot
AI
Dec 30, 2025
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.
The empty line 247 appears to be unintentional and breaks the continuity of the docstring table. This should either be removed or the table should be completed if it's incomplete.
|
|
||
| re_path(r'^api/fx/payments/v1/orders/$', views.PaymentOrdersView.as_view(), name='payments-orders'), | ||
| re_path(r'^api/fx/statistics/v1/payments/$', views.PaymentStatisticsView.as_view(), name='payment-statistics'), | ||
|
|
Copilot
AI
Dec 30, 2025
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.
Extra blank line should be removed to maintain consistency with the rest of the URL patterns in the file.
Description:
Add a brief description of the changes made in this PR.
Related Issue: