[WEB-1980] feat: user recent visited entities#5211
[WEB-1980] feat: user recent visited entities#5211sriramveeraghanta merged 6 commits intopreviewfrom
Conversation
WalkthroughThe recent updates enhance user interaction tracking across various views in the application. By introducing asynchronous task calls to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant TaskQueue
participant Database
User->>API: Request to view a cycle/issue/module/page/project
API->>Database: Retrieve entity data
Database-->>API: Return entity information
API->>TaskQueue: recent_visited_task.delay(...)
TaskQueue->>Database: Log user visit
Database-->>TaskQueue: Confirm visit logged
TaskQueue-->>API: Acknowledge logging
API-->>User: Return entity data
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 11
Outside diff range, codebase verification and nitpick comments (3)
apiserver/plane/bgtasks/recent_visited_task.py (1)
1-10: Organize imports for better readability.Group imports into standard library, third-party, and local imports.
# Python imports from django.utils import timezone # Third party imports from celery import shared_task # Module imports from plane.db.models import UserRecentVisit, Workspace from plane.utils.exception_logger import log_exceptionapiserver/plane/app/views/view/base.py (2)
113-128: Ensure consistency inretrievemethod parameters.The
retrievemethod inapiserver/plane/app/views/view/base.pyhas inconsistent parameters. There are two definitions:
(self, request, slug, pk)(self, request, slug, project_id, pk)Please verify and ensure that
project_idis correctly handled and consistent across the method definitions.
apiserver/plane/app/views/view/base.pyAnalysis chain
Ensure consistency in
retrievemethod parameters.The
retrievemethod parameters should be consistent with the class's purpose. Verify thatproject_idis correctly handled.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency of `retrieve` method parameters. # Test: Search for the `retrieve` method definitions. Expect: Consistent parameters. rg --type python 'def retrieve'Length of output: 64
Script:
#!/bin/bash # Description: Verify the consistency of `retrieve` method parameters. # Test: Search for the `retrieve` method definitions. Expect: Consistent parameters. rg 'def retrieve' --glob '*.py' -A 5Length of output: 7480
393-408: Ensure consistency inretrievemethod parameters.The
IssueViewFavoriteViewSetclass inapiserver/plane/app/views/view/base.pycontains tworetrievemethods with different parameters. This inconsistency needs to be addressed to ensure clarity and proper usage.
def retrieve(self, request, slug, pk)def retrieve(self, request, slug, project_id, pk)Please review and refactor these methods to maintain consistency.
Analysis chain
Ensure consistency in
retrievemethod parameters.The
retrievemethod parameters should be consistent with the class's purpose. Verify thatproject_idis correctly handled.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency of `retrieve` method parameters. # Test: Search for the `retrieve` method definitions. Expect: Consistent parameters. rg --type python 'def retrieve'Length of output: 64
Script:
#!/bin/bash # Description: Verify the consistency of `retrieve` method parameters. # Test: Search for the `retrieve` method definitions. Expect: Consistent parameters. rg 'def retrieve'Length of output: 1513
Script:
#!/bin/bash # Description: Verify the context of `retrieve` method parameters in `apiserver/plane/app/views/view/base.py`. # Test: Search for the class definitions and usages of `retrieve` methods in the specified file. rg -A 10 'class ' apiserver/plane/app/views/view/base.py rg -A 10 'def retrieve' apiserver/plane/app/views/view/base.pyLength of output: 2318
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- apiserver/plane/app/views/cycle/base.py (2 hunks)
- apiserver/plane/app/views/issue/base.py (4 hunks)
- apiserver/plane/app/views/module/base.py (2 hunks)
- apiserver/plane/app/views/page/base.py (2 hunks)
- apiserver/plane/app/views/project/base.py (2 hunks)
- apiserver/plane/app/views/view/base.py (4 hunks)
- apiserver/plane/bgtasks/recent_visited_task.py (1 hunks)
- apiserver/plane/db/models/init.py (1 hunks)
Additional context used
Ruff
apiserver/plane/db/models/__init__.py
114-114:
.recent_visit.UserRecentVisitimported but unused; consider removing, adding to__all__, or using a redundant alias(F401)
Additional comments not posted (5)
apiserver/plane/db/models/__init__.py (1)
114-114: Verify the necessity of the import.Ensure that
UserRecentVisitis used within the module or add it to__all__if it is intended to be publicly accessible.Verification successful
The import of
UserRecentVisitis necessary as it is used in the codebase, specifically in therecent_visited_task.pyfile and a migration file. However, it is not included in the__all__list inapiserver/plane/db/models/__init__.py. IfUserRecentVisitis intended to be publicly accessible, consider adding it to the__all__list.
- File:
apiserver/plane/db/models/__init__.py- Lines: Add
UserRecentVisitto__all__if it is meant to be publicly accessible.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `UserRecentVisit` in the module. # Test: Search for the usage of `UserRecentVisit`. Expect: At least one usage or add to `__all__`. rg --type python 'UserRecentVisit'Length of output: 65
Script:
#!/bin/bash # Description: Verify the usage of `UserRecentVisit` in the module and check if it is included in `__all__`. # Search for the usage of `UserRecentVisit` in the codebase. rg 'UserRecentVisit' # Check if `UserRecentVisit` is included in the `__all__` list in the `__init__.py` file. rg '__all__' apiserver/plane/db/models/__init__.py -A 5Length of output: 880
Tools
Ruff
114-114:
.recent_visit.UserRecentVisitimported but unused; consider removing, adding to__all__, or using a redundant alias(F401)
apiserver/plane/app/views/view/base.py (2)
118-124: Ensure proper handling of asynchronous tasks.Verify that
recent_visited_task.delayis correctly called and handled.Verification successful
Ensure proper handling of asynchronous tasks.
The
recent_visited_task.delayfunction is correctly called and handled across multiple files. The function is defined inapiserver/plane/bgtasks/recent_visited_task.pyand is properly imported where used.
- Files with usage:
apiserver/plane/app/views/view/base.pyapiserver/plane/app/views/project/base.pyapiserver/plane/app/views/page/base.pyapiserver/plane/app/views/issue/base.pyapiserver/plane/app/views/module/base.pyapiserver/plane/app/views/cycle/base.pyScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `recent_visited_task.delay`. # Test: Search for the usage of `recent_visited_task.delay`. Expect: Correct usage. rg --type python 'recent_visited_task.delay'Length of output: 75
Script:
#!/bin/bash # Description: Verify the usage of `recent_visited_task.delay`. # Search for the usage of `recent_visited_task.delay` in Python files. rg 'recent_visited_task.delay' --glob '*.py' -A 5 # Search for the definition of `recent_visited_task`. rg 'recent_visited_task' --glob '*.py' -A 5 # Search for the import of `recent_visited_task`. rg 'import recent_visited_task' --glob '*.py' -A 5Length of output: 13423
398-404: Ensure proper handling of asynchronous tasks.Verify that
recent_visited_task.delayis correctly called and handled.apiserver/plane/app/views/module/base.py (1)
663-669: Ensure proper error handling for the asynchronous task.The
recent_visited_task.delaycall logs user visits asynchronously. Ensure that any potential errors in the task do not affect the main functionality of theretrievemethod.Is there a mechanism in place to handle potential errors from
recent_visited_task.delay?apiserver/plane/app/views/cycle/base.py (1)
1037-1043: Ensure proper error handling for the asynchronous task.The
recent_visited_task.delaycall logs user visits asynchronously. Ensure that any potential errors in the task do not affect the main functionality of theretrievemethod.Is there a mechanism in place to handle potential errors from
recent_visited_task.delay?
There was a problem hiding this comment.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- apiserver/plane/app/views/cycle/base.py (2 hunks)
- apiserver/plane/app/views/issue/base.py (4 hunks)
- apiserver/plane/app/views/module/base.py (2 hunks)
- apiserver/plane/app/views/page/base.py (2 hunks)
- apiserver/plane/app/views/project/base.py (2 hunks)
- apiserver/plane/app/views/view/base.py (4 hunks)
Additional comments not posted (6)
apiserver/plane/app/views/page/base.py (1)
225-231: Integration of asynchronous task looks good.The
recent_visited_task.delay()call is correctly placed to track page visits asynchronously. Ensure that error handling is implemented as suggested in the existing comment.apiserver/plane/app/views/issue/base.py (3)
131-137: Integration of asynchronous task looks good.The
recent_visited_task.delay()call is correctly placed to track issue list retrievals asynchronously. Ensure that error handling is implemented as suggested in the existing comment.
259-265: Integration of asynchronous task looks good.The
recent_visited_task.delay()call is correctly placed to track issue list retrievals asynchronously. Ensure that error handling is implemented as suggested in the existing comment.
503-509: Integration of asynchronous task looks good.The
recent_visited_task.delay()call is correctly placed to track issue retrievals asynchronously. Ensure that error handling is implemented as suggested in the existing comment.apiserver/plane/app/views/project/base.py (1)
268-274: Integration of asynchronous task looks good.The
recent_visited_task.delay()call is correctly placed to track project retrievals asynchronously. Ensure that error handling is implemented as suggested in the existing comment.apiserver/plane/app/views/cycle/base.py (1)
1032-1038: Verify the handling of asynchronous task inputs.Ensure that the
recent_visited_taskfunction correctly handles the inputs and operates efficiently. Consider potential impacts on performance and user experience, especially in high-traffic scenarios.Verification successful
The
recent_visited_taskfunction is implemented and used correctly.The function is defined as a Celery task and handles the parameters as expected. It is imported and utilized across multiple modules, including the one under review. The task's implementation appears to align with its intended purpose of tracking recent visits. No issues were found regarding its definition or usage.
- Location of definition:
apiserver/plane/bgtasks/recent_visited_task.py- Usage in various modules: Confirmed through imports and task execution.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `recent_visited_task` function to ensure it handles inputs correctly and efficiently. # Test: Search for the function implementation. Expect: Correct handling of parameters and efficient execution. ast-grep --lang python --pattern $'def recent_visited_task(slug, entity_name, entity_identifier, user_id, project_id):\n $$$'Length of output: 126
Script:
#!/bin/bash # Description: Search for the definition or import of `recent_visited_task` in the codebase. # Search for the function definition with any parameter signature. ast-grep --lang python --pattern 'def recent_visited_task($$$):\n $$$' # Search for import statements that might import `recent_visited_task`. rg 'import .+recent_visited_task' --context 2Length of output: 121
Script:
#!/bin/bash # Description: Search for any usage of `recent_visited_task` in the codebase to gather more context. # Search for any usage of `recent_visited_task`. rg 'recent_visited_task' --context 5Length of output: 12727
Issue Link: WEB-1980
New Features
Bug Fixes
Chores
Summary by CodeRabbit
New Features
Bug Fixes
Documentation