Skip to content

Conversation

@mkurkar
Copy link
Collaborator

@mkurkar mkurkar commented Dec 30, 2025

  • 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

Description:

Add a brief description of the changes made in this PR.

Related Issue:

- 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
Copy link

Copilot AI left a 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.

Comment on lines +260 to +270
# 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
Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.
' following are the available tags along with the fields they include:\n'
'| tag | mapped fields |\n'
'|-----|---------------|\n'

Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.

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'),

Copy link

Copilot AI Dec 30, 2025

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.

Copilot uses AI. Check for mistakes.
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