plane
plane copied to clipboard
chore: analytics endpoint
Description
Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Feature (non-breaking change which adds functionality)
- [ ] Improvement (change that would cause existing functionality to not work as expected)
- [ ] Code refactoring
- [ ] Performance improvements
- [ ] Documentation update
Screenshots and Media (if applicable)
Test Scenarios
References
"""
Walkthrough
This update extends the advanced analytics capabilities of the Django application by adding a new export endpoint alongside existing analytics, statistics, and chart endpoints. Four new API endpoints are introduced, providing detailed workspace-level analytics on projects and issues with flexible filtering and grouping options. A new utility module is added to generate chart data from ORM querysets, supporting dynamic aggregation and grouping. Additionally, a background Celery task is implemented to export analytics data as CSV and email it to users. The changes include new URL patterns, view classes, utility functions, and background task logic.
Changes
| File(s) | Change Summary |
|---|---|
| apiserver/plane/app/urls/analytic.py | Added new URL route for advanced analytics export endpoint alongside existing advanced analytics endpoints. |
| apiserver/plane/app/views/init.py | Imported four new advanced analytics endpoint classes from analytic.advance module. |
| apiserver/plane/app/views/analytic/advance.py | Added four new API endpoint classes: AdvanceAnalyticsEndpoint, AdvanceAnalyticsStatsEndpoint, AdvanceAnalyticsChartEndpoint, and AdvanceAnalyticsExportEndpoint, implementing analytics data retrieval and export functionality. |
| apiserver/plane/utils/build_chart.py | Added new utility functions to build analytics chart data from Django ORM querysets, supporting flexible filtering, grouping, and aggregation. |
| apiserver/plane/bgtasks/analytic_plot_export.py | Added new Celery shared task to export analytics data to CSV and email it, with exception handling and logging. |
| apiserver/plane/utils/date_utils.py | Added new utility functions to handle date range calculations and filtering for analytics queries, supporting multiple predefined and custom date filters. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant API_Server
participant AnalyticsView
participant ChartUtils
participant BackgroundTask
Client->>API_Server: GET /workspaces/{slug}/advance-analytics/
API_Server->>AnalyticsView: Route to AdvanceAnalyticsEndpoint
AnalyticsView->>AnalyticsView: Process filters and tabs
AnalyticsView->>API_Server: Return overview or work-items stats
Client->>API_Server: GET /workspaces/{slug}/advance-analytics-stats/
API_Server->>AnalyticsView: Route to AdvanceAnalyticsStatsEndpoint
AnalyticsView->>AnalyticsView: Aggregate project and issue stats
AnalyticsView->>API_Server: Return stats data
Client->>API_Server: GET /workspaces/{slug}/advance-analytics-charts/
API_Server->>AnalyticsView: Route to AdvanceAnalyticsChartEndpoint
AnalyticsView->>ChartUtils: Call build_analytics_chart with params
ChartUtils->>AnalyticsView: Return chart data
AnalyticsView->>API_Server: Return chart data
Client->>API_Server: POST /workspaces/{slug}/advance-analytics-export/
API_Server->>AnalyticsView: Route to AdvanceAnalyticsExportEndpoint
AnalyticsView->>BackgroundTask: Trigger export_analytics_to_csv_email task
BackgroundTask->>UserEmail: Send CSV export email
AnalyticsView->>API_Server: Confirm export initiation
Suggested reviewers
- sriramveeraghanta
- vamsikrishnamathala
Poem
🐇✨ In fields of data, the numbers now dance,
New endpoints arrive, giving stats a chance.
Charts bloom like flowers, exports take flight,
Sending insights by day and by night.
This rabbit hops joy with each new API,
Analytics advancing—oh, how high we fly! 📊🌿 """
[!TIP]
⚡️ Faster reviews with caching
- CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure
Review - Disable Cacheat either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off theData Retentionsetting under your Organization Settings.Enjoy the performance boost—your workflow just got faster.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
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.
🪧 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.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Pull Request Linked with Plane Work Items
- [WEB-3782] Analytics 2.0 API's - Free version
Comment Automatically Generated by Plane
@NarayanBavisetti Add type hints to the code.