Skip to content

Conversation

@Bolortulga07
Copy link
Collaborator

@Bolortulga07 Bolortulga07 commented Oct 9, 2025

Summary by Sourcery

Enhance cycle GraphQL queries to use date-based filtering and adjust completion criteria

Enhancements:

  • Import and use startOfDay to normalize the current date in getCyclesActive
  • Remove the isCompleted filter from getCycle to return all cycles regardless of completion
  • Update getCyclesActive to only include non-completed cycles that are ongoing (startDate ≤ today ≤ endDate) or upcoming (startDate > today)

Summary by CodeRabbit

  • New Features

    • Cycle list now includes completed cycles alongside active ones for your team.
  • Bug Fixes

    • Active cycles are now determined using day-based boundaries, improving accuracy across time zones.
    • Active view correctly shows cycles in progress and upcoming (starting today or later) while excluding completed and past cycles.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 9, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors the cycle query resolvers to normalize date comparisons using startOfDay and refines completion and status filters for more accurate and streamlined cycle retrieval.

Sequence diagram for getCyclesActive query with normalized date comparisons

sequenceDiagram
participant Client
participant CycleResolver
participant TaskModel
participant CycleModel
Client->>CycleResolver: getCyclesActive(params)
alt params.taskId is provided
    CycleResolver->>TaskModel: findOne({_id: params.taskId})
    TaskModel-->>CycleResolver: Task
end
CycleResolver->>CycleModel: find({
  teamId: params.teamId,
  isCompleted: false,
  $or: [
    {isActive: true},
    {_id: params.cycleId},
    {startDate <= today, endDate >= today},
    {startDate > today}
  ]
})
CycleModel-->>CycleResolver: Cycles
CycleResolver-->>Client: Cycles
Loading

File-Level Changes

Change Details Files
Normalize and centralize date handling for cycle queries
  • Imported startOfDay from date-fns
  • Declared today as startOfDay(new Date())
  • Replaced new Date() comparisons with today in $or date conditions
backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts
Refine completion and status filters in cycle queries
  • Removed isCompleted constraint in getCycle to include all cycles
  • Changed isCompleted filter in getCyclesActive from {$ne: true} to false
  • Dropped isActive and explicit cycleId checks from $or conditions
backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts:62` </location>
<code_context>
         query: {
           teamId: params.teamId,
-          isCompleted: { $ne: true },
+          isCompleted: false,
           $or: [
-            { isActive: true },
</code_context>

<issue_to_address>
**issue (bug_risk):** Changing isCompleted filter from '$ne: true' to 'false' may alter results.

This change excludes cycles with undefined or null isCompleted values, which may impact results if legacy data lacks this field.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Updated cycle query resolvers to adjust filters: removed isCompleted constraint from getCycles; revised getCyclesActive to use startOfDay for “today,” added endDate >= today, tightened startDate <= today, added future-start branch, and set isCompleted to false explicitly.

Changes

Cohort / File(s) Summary
Cycle query resolvers
backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts
Import startOfDay. getCycles: remove isCompleted filter (now only teamId). getCyclesActive: compute today via startOfDay; set isCompleted: false; update date filters to startDate <= today and endDate >= today, plus branch for startDate > today.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Resolver as CycleResolver
  participant DateFns as date-fns
  participant DB as Database

  rect rgba(200,235,255,0.3)
  note over Client,Resolver: getCycles(teamId)
  Client->>Resolver: Query getCycles
  Resolver->>DB: find({ teamId })
  DB-->>Resolver: cycles
  Resolver-->>Client: cycles
  end

  rect rgba(220,255,220,0.35)
  note over Client,Resolver: getCyclesActive(teamId)
  Client->>Resolver: Query getCyclesActive
  Resolver->>DateFns: startOfDay(new Date())
  DateFns-->>Resolver: today
  Note right of Resolver: Build filter:<br/>isCompleted: false<br/>teamId: X<br/>date window:<br/>- startDate <= today AND endDate >= today<br/>OR startDate > today
  Resolver->>DB: find({ teamId, isCompleted: false, date conditions })
  DB-->>Resolver: active cycles
  Resolver-->>Client: active cycles
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws at dawn’s first ray,
Start-of-day now leads the way.
Filters trimmed, the cycles chime—
Past to future, right on time.
Burrows neat, queries tight,
Hop! The active ones in sight. 🐇⏳

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "Operation tasks" is too generic and does not clearly summarize that the pull request updates the cycle GraphQL resolver queries to include specific date-based filtering, so reviewers cannot quickly grasp the main change. Rename the pull request to explicitly reflect the main change, for example “Add date-based filtering to getCyclesActive resolver” or “Refactor cycle queries to use startDate and endDate filters.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch operation-tasks

📜 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 3007a8b and ed3c682.

📒 Files selected for processing (1)
  • backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Use functional and declarative programming patterns; avoid classes.
Use TypeScript for all code; prefer interfaces over types.
Avoid enums; use maps instead.

Files:

  • backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Avoid console logs.
Always use absolute paths when importing.
Use the "function" keyword for pure functions.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

**/*.{ts,tsx,js,jsx}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use the "function" keyword for pure functions.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
Use absolute path when import.

Files:

  • backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (4)
backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts (4)

13-13: LGTM!

The startOfDay import is appropriate for normalizing date comparisons to day boundaries.


36-37: Good use of startOfDay for date normalization.

Using startOfDay ensures consistent date comparisons at day boundaries (midnight), which is better than using new Date() directly.

Note: startOfDay uses the server's local timezone by default. If timezone-aware behavior is required (e.g., users in different timezones), consider using @date-fns/tz with an explicit timezone context as shown in the learnings.

Based on learnings.


20-33: Confirm removal of isCompleted filter is intentional
Removing isCompleted: false changes getCycles to return completed cycles as well. No internal references to this resolver were found in this repo—please verify this aligns with your API contract, coordinate with any external consumers, and update documentation or migration notes accordingly.


60-72: Approve filtering logic in getCyclesActive Schema enforces isCompleted: Boolean (default false) and requires endDate, so explicit isCompleted: false has no unintended gaps and null endDate cases can’t occur; including future cycles aligns with its intended UI use.


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.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to ed3c682 in 1 minute and 13 seconds. Click for details.
  • Reviewed 49 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts:26
  • Draft comment:
    Removed 'isCompleted: false' filter in getCycles query. Confirm if returning all cycles (including completed) is intended.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts:33
  • Draft comment:
    Good use of startOfDay for consistent date comparisons in getCyclesActive.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts:60
  • Draft comment:
    Changed 'isCompleted' condition from { $ne: true } to false. Ensure all cycles have an explicit boolean value for isCompleted.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50% None
4. backend/plugins/operation_api/src/modules/cycle/graphql/resolvers/queries/cycle.ts:65
  • Draft comment:
    Removed cycleId and isActive filtering in the $or clause. Confirm this change aligns with the desired behavior when a taskId is provided.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_dR7jfMzP8wwSvBA7

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

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.

2 participants