Skip to content

feat/ add-export-functionality-for-filtered-issues-(CSV & JSON) #3570#3595

Closed
sonu1680 wants to merge 2 commits intoOWASP:mainfrom
sonu1680:feat/export-issues-csv-json-3570
Closed

feat/ add-export-functionality-for-filtered-issues-(CSV & JSON) #3570#3595
sonu1680 wants to merge 2 commits intoOWASP:mainfrom
sonu1680:feat/export-issues-csv-json-3570

Conversation

@sonu1680
Copy link

This PR resolves Issue #3570 by adding support to export filtered issues in CSV and JSON formats. The implementation follows existing project patterns and ensures no breaking changes.

✅ What’s included

Backend

  • Added a new export endpoint:

    GET /api/v1/modules/:moduleKey/issues/export
    
  • Supports exporting issues based on existing filters (state, labels, etc.)

  • Reuses current issue filtering logic to avoid duplication

  • Returns correct content types for CSV and JSON

  • Ensures authorization and access control are respected

Frontend

  • Added an Export option near the issue filters
  • Allows users to download filtered results as CSV or JSON
  • Preserves applied filters during export
  • Handles loading and error states gracefully

Code Quality

  • Removed unnecessary comments and AI-style artifacts
  • Kept only meaningful, non-obvious comments
  • Followed existing code structure and conventions
  • No functional regressions or API breaking changes

🧪 Testing

  • Verified export with multiple filter combinations
  • Tested both CSV and JSON downloads
  • Confirmed access control and permissions
  • Checked behavior with empty and large datasets

📎 Related Issue

Fixes: #3570

@github-actions
Copy link

The linked issue must be assigned to the PR author.

@github-actions github-actions bot closed this Jan 27, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Caution

Review failed

The pull request is closed.

Summary by CodeRabbit

New Features

  • Added CSV and JSON export functionality for mentorship module issues, with support for label filtering and configurable export limits.
  • Introduced an export button to the module issues page, allowing users to select and download issue data in their preferred format.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Adds export functionality for mentorship module issues in CSV and JSON formats. Introduces backend GraphQL types, utilities for serialization, and a GraphQL resolver field. Frontend adds UI components, download utilities, and integrates export into the issues page with comprehensive test coverage.

Changes

Cohort / File(s) Summary
Backend GraphQL Types
backend/apps/mentorship/api/internal/nodes/export_types.py
Defines ExportFormatEnum (CSV, JSON) and ExportResult type with content, filename, mime_type, and count fields for GraphQL exposure.
Backend GraphQL Field
backend/apps/mentorship/api/internal/nodes/module.py
Adds export_issues field to ModuleNode accepting format, optional label filter, and limit; serializes to CSV/JSON via utility functions and returns ExportResult.
Backend Export Utilities
backend/apps/mentorship/utils/export.py
Core export logic: ExportFormat enum, serialize_issues_to_csv(), serialize_issues_to_json(), and generate_export_filename() functions with MAX_EXPORT_LIMIT (1000) constant. Handles datetime formatting and missing data gracefully.
Backend Utility Exports
backend/apps/mentorship/utils/__init__.py
Re-exports ExportFormat, serialize_issues_to_csv, and serialize_issues_to_json to establish public API surface.
Backend Test Infrastructure
backend/tests/apps/mentorship/__init__.py, backend/tests/apps/mentorship/utils/__init__.py
Package initializers for mentorship test suite.
Backend Export Tests
backend/tests/apps/mentorship/utils/export_test.py
Comprehensive test coverage for CSV/JSON serialization, filename generation, and export limits; includes mock issue/label/user/repository classes.
Frontend Export Utilities
frontend/src/utils/exportUtils.ts
Exports ExportFormat, ExportOptions, ExportResult types; provides buildExportQuery(), parseExportResponse(), downloadFile(), and getExportErrorMessage() utilities for GraphQL export integration and browser downloads.
Frontend Export Component
frontend/src/components/ExportButton.tsx
React component with dropdown menu for CSV/JSON format selection; manages loading state during export and provides async callback integration.
Frontend Issues Page
frontend/src/app/my/mentorship/programs/[programKey]/modules/[moduleKey]/issues/page.tsx
Integrates ExportButton, implements handleExport() workflow with GraphQL query execution, response parsing, error handling, and file download with toast notifications.
Frontend Test Updates
frontend/__tests__/a11y/pages/MyMentorship.a11y.test.tsx
Wraps accessibility checks in waitFor block to handle asynchronous updates properly.
Frontend Test Refactor
frontend/__tests__/unit/pages/CreateModule.test.tsx
Refactors test structure from inline to named function with explicit timeout (15000 ms); test assertions and setup remain functionally equivalent.
Frontend Export Utilities Tests
frontend/__tests__/unit/utils/exportUtils.test.ts
Unit tests for export utilities covering query building, response parsing, error mapping, and file download triggering with mocked browser APIs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CSV/JSON export functionality for filtered project issues

1 participant