Skip to content

Conversation

@dheeru0198
Copy link
Member

@dheeru0198 dheeru0198 commented Mar 7, 2025

Description

Updated the API responces to return the start_date and end_date in the project's timezone instead of user's timezone

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

Summary by CodeRabbit

  • New Features
    • Cycle start and end dates are now automatically adjusted based on your project's timezone settings. This update ensures that all cycle-related operations—whether viewing, creating, or editing—display date and time information consistently and accurately across the platform.

@CLAassistant
Copy link

CLAassistant commented Mar 7, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

This pull request enhances the cycle handling functionality by introducing project-specific timezone support. The changes update the serializer to initialize date fields based on the project's timezone, pass project details in serializer contexts within the API views, and adjust the timezone conversion in cycle view methods. These modifications ensure that all date fields across cycle retrieval and updates are consistently converted using the project’s timezone.

Changes

File(s) Change Summary
apiserver/.../serializers/cycle.py
apiserver/.../views/cycle.py
Added a new __init__ method in CycleSerializer to set timezone for start_date and end_date fields; updated API views to pass a project in the serializer context.
apiserver/.../views/cycle/base.py Modified cycle view methods (list, create, partial_update, retrieve) to convert datetime fields using the project's timezone instead of the user's timezone.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as API View
    participant P as Project Lookup
    participant S as CycleSerializer

    U->>A: Request cycle data
    A->>P: Retrieve project using project_id/slug
    P-->>A: Return project with timezone info
    A->>S: Instantiate serializer with project in context
    S->>S: Initialize serializer, setting timezone for dates via pytz
    S-->>A: Return serialized cycle data
    A-->>U: Deliver cycle data (timezone converted)
Loading

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, ⚙️backend

Suggested reviewers

  • NarayanBavisetti
  • pablohashescobar
  • sriramveeraghanta

Poem

I’m a bunny in the code, full of glee,
Hopping through timezones, wild and free!
Projects guide my fields with care,
Dates align with flair in the air.
Bugs nibble away as I celebrate the spree!
🐇💻🌟


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a953013 and 3217483.

📒 Files selected for processing (3)
  • apiserver/plane/api/serializers/cycle.py (2 hunks)
  • apiserver/plane/api/views/cycle.py (6 hunks)
  • apiserver/plane/app/views/cycle/base.py (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (16)
apiserver/plane/api/serializers/cycle.py (2)

2-2: Necessary import for timezone support.

Adding the pytz library enables timezone handling functionality needed for the project timezone feature.


22-29: Well-implemented timezone support for date serialization.

This new __init__ method properly configures the serializer to use the project's timezone when handling date fields. The implementation correctly:

  1. Retrieves the project from context
  2. Checks for project and timezone existence
  3. Sets the timezone for start_date and end_date fields

This ensures dates will be consistently returned in the project's timezone rather than user timezone.

apiserver/plane/api/views/cycle.py (8)

140-140: Essential project retrieval for timezone context.

This line fetches the project object which is needed to access the project's timezone information.


143-146: Added project context to serializer.

The serializer now receives the project in its context, enabling it to access the project's timezone information when serializing dates.


156-159: Consistent project context in serializer.

The project context is properly passed to the serializer for the "current" cycle view, maintaining consistency.


168-171: Maintaining consistency in upcoming cycles.

The project context is correctly passed to the serializer for the "upcoming" cycles, ensuring consistent timezone handling.


180-183: Consistent project context for completed cycles.

The project context is properly passed to the serializer for the "completed" cycles, maintaining timezone consistency.


192-195: Consistent project context for draft cycles.

The project context is properly passed to the serializer for the "draft" cycles, maintaining timezone handling consistency.


206-209: Consistent project context for incomplete cycles.

The project context is properly passed to the serializer for the "incomplete" cycles, maintaining consistency.


214-217: Consistent project context for default case.

The project context is properly passed to the serializer for the default case in pagination, ensuring consistent timezone handling throughout the entire method.

apiserver/plane/app/views/cycle/base.py (6)

270-272: Changed from user to project timezone.

This change switches the timezone conversion from using the user's timezone to using the project's timezone, which aligns with the PR objective.


321-324: Added project timezone retrieval.

These added lines fetch the project and its timezone, which is necessary for proper date conversion.


326-328: Using project timezone for conversion.

The timezone conversion now uses the project timezone instead of the user timezone, consistent with other changes.


414-417: Added project timezone retrieval for partial update.

Similar to the create method, these lines fetch the project timezone for consistent date handling in the partial_update method.


419-421: Using project timezone for conversion in partial update.

The timezone conversion now uses the project timezone instead of the user timezone in partial_update, maintaining consistency.


491-495: Added project timezone retrieval and conversion in retrieve method.

These changes ensure that the retrieve method also uses the project's timezone for date conversion, completing the consistent implementation across all methods.

✨ 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.

❤️ Share
🪧 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 @coderabbitai in 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 @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 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.

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 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 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.

@sriramveeraghanta sriramveeraghanta changed the title Return cycle start and end dates in project's timezone [WEB-3513] fix: return cycle start and end dates in project's timezone Mar 11, 2025
@makeplane
Copy link

makeplane bot commented Mar 11, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@sriramveeraghanta sriramveeraghanta merged commit 75a9b71 into preview Mar 24, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-cycle-date-display branch March 24, 2025 07:21
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.

5 participants