Skip to content

Conversation

@manasdutta04
Copy link

@manasdutta04 manasdutta04 commented Aug 10, 2025

🎯 What's Changed #184

Added comprehensive data export functionality allowing users to export GitHub issues and pull requests in CSV and JSON formats.

✨ Features

  • 📊 CSV Export - Spreadsheet-ready format
  • 💻 JSON Export - Developer-friendly structured data
  • 🎛️ Export Options - Current tab or all data
  • 🔍 Filter Support - Respects search, date, repo, and state filters
  • 🎨 Clean UI - Dropdown menu with format descriptions
  • 🔔 Notifications - Success/error feedback
  • 📁 Smart Naming - Auto-generated filenames with timestamps

🛠️ Technical Changes

  • Created ExportButton component with Material-UI dropdown
  • Added exportUtils.ts with CSV/JSON conversion functions
  • Enhanced GitHub data hook to include user and labels
  • Integrated export buttons in Tracker component
  • Added proper TypeScript support and error handling

📁 Files Modified

  • src/components/ExportButton.tsx ✨ New
  • src/utils/exportUtils.ts ✨ New
  • src/pages/Tracker/Tracker.tsx 🔧 Modified
  • src/hooks/useGitHubData.ts 🔧 Modified
  • docs/EXPORT_FEATURE.md ✨ New
  • src/utils/__tests__/exportUtils.test.ts ✨ New

GSSoC 2025 Contribution 🌟

Summary by CodeRabbit

  • New Features

    • Added export functionality for GitHub issues and pull requests, allowing users to export data in CSV or JSON formats.
    • Users can export all data, the current tab, or filtered results directly from the interface.
    • Exported files are named with user, data type, date, and format for easy identification.
  • Bug Fixes

    • Improved data consistency by ensuring all exported items include user and label information.
  • Documentation

    • Added detailed documentation describing the export feature, usage instructions, and future enhancement plans.
  • Tests

    • Introduced tests to validate export utilities, including error handling and file generation.

- Add CSV and JSON export formats
- Create reusable ExportButton component with dropdown menu
- Implement export utilities with proper error handling
- Add export options for current tab and all data
- Support filtered data export (respects search, date, repo filters)
- Include success/error notifications with react-hot-toast
- Add automatic filename generation with timestamps
- Enhance GitHub data hook to include user and labels info
- Add comprehensive documentation and basic tests
- Improve user experience with disabled states and item counts

Fixes: Data export functionality for better data analysis and backup
@netlify
Copy link

netlify bot commented Aug 10, 2025

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit d23db9f
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6898b1a02adf1800085c70de
😎 Deploy Preview https://deploy-preview-185--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 10, 2025

Walkthrough

This change introduces a comprehensive data export feature for GitHub issues and pull requests. It adds a new export button UI, utility functions for CSV and JSON export, filename generation, error handling, and corresponding documentation and tests. The export options are integrated into the tracker page and support exporting filtered or all data.

Changes

Cohort / File(s) Change Summary
Documentation
docs/EXPORT_FEATURE.md
New documentation describing the data export feature, formats, usage, technical details, and future enhancements.
Export Button Component
src/components/ExportButton.tsx
New React component providing UI for exporting data as CSV or JSON, with menu, notifications, and integration with utility functions.
Export Utilities
src/utils/exportUtils.ts
New utility module defining GitHubItem interface, export functions for CSV/JSON, filename generation, and file download logic.
Export Utilities Tests
src/utils/__tests__/exportUtils.test.ts
New test suite covering filename generation, export functions, and error handling for export utilities.
Tracker Page Integration
src/pages/Tracker/Tracker.tsx
Integration of the export button into the tracker page, enabling export of all or filtered data, with UI adjustments.
GitHub Data Hook
src/hooks/useGitHubData.ts
Internal update to ensure all fetched items have user and labels properties for compatibility with export logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TrackerPage
    participant ExportButton
    participant exportUtils

    User->>TrackerPage: Clicks "Export" button
    TrackerPage->>ExportButton: Renders with data, username, type
    User->>ExportButton: Selects CSV or JSON
    ExportButton->>exportUtils: Calls exportToCSV/exportToJSON(data, filename)
    exportUtils->>ExportButton: Triggers file download or error
    ExportButton->>User: Shows toast notification (success/error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related issues

Suggested labels

gssoc2025, level2

Suggested reviewers

  • mehul-m-prajapati

Poem

🐇✨
With a hop and a click, your data takes flight,
Exporting in CSV or JSON delight.
Issues and PRs, all neat in a row,
With filenames so clever, off they go!
A toast for success, a nudge if you err—
The tracker’s now smarter, thanks to this hare!
📦🍃

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (14)
src/utils/exportUtils.ts (2)

13-46: Improve repository name extraction for better clarity.

The CSV export logic is well-implemented with proper quote escaping and error handling. However, consider including the repository owner in the repository name for better clarity.

Apply this diff to include the owner name:

-      `"${item.repository_url.split('/').slice(-1)[0]}"`,
+      `"${item.repository_url.split('/').slice(-2).join('/')}"`,

This will export repository names as "owner/repo" instead of just "repo", making them more informative and consistent with GitHub's standard naming convention.


48-67: Apply consistent repository name extraction.

The JSON export function is well-structured with proper error handling and data transformation. Apply the same repository name improvement as suggested for the CSV function.

Apply this diff:

-    repository: item.repository_url.split('/').slice(-1)[0],
+    repository: item.repository_url.split('/').slice(-2).join('/'),
src/utils/__tests__/exportUtils.test.ts (1)

65-84: Consider enhancing test coverage.

The current tests effectively verify error handling and basic success cases. Consider adding tests to verify the actual CSV/JSON content structure and data transformation logic.

Example additional test:

it('should generate correct CSV structure', () => {
  const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
  const csvContent = exportToCSV(mockData, 'test.csv');
  // Verify CSV headers and data structure
  expect(csvContent).toContain('ID,Title,State,Type,Repository');
  consoleSpy.mockRestore();
});
src/components/ExportButton.tsx (1)

1-33: Consider consolidating interface definitions.

The component imports and structure look good. However, the GitHubItem interface is duplicated from exportUtils.ts. Consider creating a shared types file or importing the interface to maintain DRY principles.

Create a shared src/types/github.ts file:

export interface GitHubItem {
  id: number;
  title: string;
  state: string;
  created_at: string;
  pull_request?: { merged_at: string | null };
  repository_url: string;
  html_url: string;
  user?: { login: string };
  labels?: Array<{ name: string }>;
}

Then import it in both files:

import { GitHubItem } from '../types/github';
docs/EXPORT_FEATURE.md (10)

20-29: Clarify CSV column semantics (state, repository, date, labels).

  • “State” lists “merged” which GitHub’s Issues/PR API doesn’t return in the state field for PRs (it’s a separate merged flag). If you map merged PRs to “merged,” please document that mapping. Also note that Issues will only be open/closed.
  • “Repository” says “Repository name”; consider using/clarifying “owner/repo” to avoid collisions across orgs/users.
  • “Created Date” says “local format.” Localized strings are ambiguous in CSV. Please document the exact format and timezone, and note that JSON uses ISO-8601. If possible, prefer ISO-8601 for CSV too.
  • “Labels” are comma-separated, which clashes with CSV’s delimiter. Confirm that label strings and titles are properly CSV-escaped (quotes, commas, newlines).

Apply this doc tweak for precision:

- - State: Current state (open, closed, merged)
- - Repository: Repository name
- - Created Date: Creation date in local format
- - Labels: Comma-separated list of labels
+ - State: Current state. Issues: open/closed. PRs: open/closed; merged PRs are reported as "merged" via a custom mapping.
+ - Repository: Full repository identifier (owner/repo) to avoid name collisions.
+ - Created Date: Creation timestamp. CSV uses <document exact format/timezone here>; JSON uses ISO-8601 (UTC).
+ - Labels: Comma-separated; values are CSV-escaped to handle commas/quotes/newlines safely (RFC 4180).

31-45: Ensure field names and date formats match the actual export payload.

The example uses “createdDate”. If utilities emit “createdAt” (GitHub-style) or a different casing, please align docs and code. Also state the timezone (example shows Z/UTC).

Proposed clarification:

-     "createdDate": "2024-01-15T10:30:00Z",
+     "createdAt": "2024-01-15T10:30:00Z", // ISO-8601 UTC (Z)

49-56: Add required token scopes and a quick link.

You mention entering a token; specify scopes so users don’t get empty exports due to insufficient permissions (e.g., private repos/orgs).

 2. Enter your GitHub username and token
+   - Required scopes: public data needs no extra scopes; private repos/orgs may require `repo` and `read:org`.
+   - See: https://github.com/settings/tokens (create a fine-grained token with least privileges).

12-16: Clarify “Export All” structure for CSV.

If “Export All” produces a single CSV containing both Issues and PRs, call out that the “Type” column disambiguates rows and that headers are unified.

- 2. **Export All**: Export both issues and pull requests in a single file
+ 2. **Export All**: Export both issues and pull requests in a single file. The "Type" column labels each row as Issue or Pull Request.

70-78: Align naming convention with “timestamps” claim; include timezone.

PR summary mentions timestamps but examples only show dates. Recommend including time to prevent filename collisions and documenting timezone.

-Files are automatically named using the pattern:
-`github-{username}-{type}-{date}.{format}`
+Files are automatically named using the pattern:
+`github-{username}-{type}-{timestamp}.{format}`
+Where `{timestamp}` is `YYYY-MM-DD_HH-mm-ss` in UTC (e.g., 2025-08-10_14-30-05).
@@
-- `github-johndoe-issues-2024-01-15.csv`
-- `github-johndoe-prs-2024-01-15.json`
-- `github-johndoe-all-2024-01-15.csv`
+- `github-johndoe-issues-2025-08-10_14-30-05.csv`
+- `github-johndoe-prs-2025-08-10_14-30-05.json`
+- `github-johndoe-all-2025-08-10_14-30-05.csv`

81-90: Link directly to source for quick navigation.

Add relative links to files to improve discoverability in the repo.

-- `ExportButton.tsx`: Main export component with dropdown menu
-- `exportUtils.ts`: Utility functions for data processing and file generation
+- [`src/components/ExportButton.tsx`](../src/components/ExportButton.tsx): Main export component with dropdown menu
+- [`src/utils/exportUtils.ts`](../src/utils/exportUtils.ts): Utility functions for data processing and file generation

91-96: Document rate limits and large-export behavior.

Exports over many pages may be impacted by GitHub API rate limits and pagination. Note how the UI handles partial data, retries, and user feedback.

 - Empty data validation
 - Format-specific error handling
 - User-friendly error messages via toast notifications
 - Success confirmations
+ - Graceful handling of GitHub API rate limits (inform users and suggest retry) and large datasets (pagination status and progress).

97-101: Browser nuances (Safari/iOS) for downloads.

Add a note about Safari/iOS download limitations and fallbacks for the anchor download attribute with Blob URLs.

 - Modern browsers with Blob API support
 - File download functionality
 - No server-side processing required
+ - Note: iOS Safari has limited support for programmatic downloads; users may be prompted to preview before saving.

3-11: CSV format specification.

State that CSV output follows RFC 4180 (commas as delimiter, CRLF line endings, quotes escaping) to set expectations for consumers.

 ## Features
@@
 - **CSV Format**: Spreadsheet-compatible format perfect for Excel, Google Sheets, or data analysis tools
+  - CSV adheres to RFC 4180 (commas as delimiters, quoted fields for commas/quotes/newlines).
 - **JSON Format**: Developer-friendly format ideal for programmatic processing or API integration

97-108: Add a Privacy & Security note.

Explicitly confirm that no tokens or secrets are included in exports and remind users about sharing exported data.

 ## Future Enhancements
+## Privacy & Security
+- Exported files contain only issue/PR metadata (titles, labels, authors, URLs). Authentication tokens and secrets are never written to files.
+- Be cautious when sharing exports that may contain organization-internal data.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 988166d and d23db9f.

📒 Files selected for processing (6)
  • docs/EXPORT_FEATURE.md (1 hunks)
  • src/components/ExportButton.tsx (1 hunks)
  • src/hooks/useGitHubData.ts (1 hunks)
  • src/pages/Tracker/Tracker.tsx (4 hunks)
  • src/utils/__tests__/exportUtils.test.ts (1 hunks)
  • src/utils/exportUtils.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/utils/exportUtils.ts (1)
src/pages/ContributorProfile/ContributorProfile.tsx (1)
  • ContributorProfile (11-95)
🔇 Additional comments (13)
src/hooks/useGitHubData.ts (1)

22-31: LGTM! Good defensive programming for export compatibility.

The enhancement ensures consistent data structure by providing default values for user and labels properties. This prevents potential runtime errors in the export utilities when these optional fields are missing from the GitHub API response.

src/utils/exportUtils.ts (3)

1-11: Well-defined interface structure.

The interface properly captures the GitHub API response structure with appropriate optional fields. The optional user and labels properties align with the defensive enhancements in the data hook.


69-81: LGTM! Proper file download implementation.

The function correctly implements programmatic file download with proper cleanup of object URLs to prevent memory leaks.


83-86: LGTM! Clear filename generation.

The filename format is descriptive and includes all relevant information with a timestamp for uniqueness.

src/utils/__tests__/exportUtils.test.ts (2)

3-50: Comprehensive test setup with proper mocking.

The mock data structure accurately represents GitHub API responses, and the DOM API mocking is thorough and appropriate for testing file download functionality without side effects.


52-63: LGTM! Proper filename format validation.

The tests effectively validate the filename generation using regex patterns that verify the expected format including username, type, timestamp, and file extension.

src/pages/Tracker/Tracker.tsx (4)

35-35: LGTM! Proper component import.


188-188: Good styling improvement for filter alignment.


218-227: LGTM! Well-implemented "Export All" functionality.

The conditional rendering ensures the button only appears when data is available, and the data combination properly applies filters to both issues and PRs before merging.


252-286: Excellent integration of tab-specific export functionality.

The layout restructuring maintains good UX with proper spacing and alignment. The export button correctly uses currentFilteredData to export only the active tab's filtered results, and the state filter remains properly positioned.

src/components/ExportButton.tsx (3)

35-50: LGTM! Standard Material-UI menu pattern.

The state management and event handlers follow Material-UI best practices for dropdown menus.


52-69: LGTM! Excellent error handling and user feedback.

The export logic properly handles both success and error cases with appropriate toast notifications. The error logging will help with debugging while maintaining good user experience.


71-122: LGTM! User-friendly UI implementation.

The component provides excellent UX with:

  • Clear visual indicators (icons and descriptions)
  • Helpful item count display
  • Proper disabled states
  • Intuitive menu layout

The Material-UI integration is clean and follows design system conventions.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant