Skip to content

Exclude COMMITTED events from adapted timeline#679

Merged
jayantbh merged 1 commit into
middlewarehq:mainfrom
Kamlesh72:sync-idempotency-error
Jul 16, 2025
Merged

Exclude COMMITTED events from adapted timeline#679
jayantbh merged 1 commit into
middlewarehq:mainfrom
Kamlesh72:sync-idempotency-error

Conversation

@Kamlesh72

@Kamlesh72 Kamlesh72 commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

Linked Issue(s)

Closes #678

Further comments

Hash can be same for commits in different PRs.
Later we would also need to handle this case for PullRequestCommit table, as we use currently use hash as Primary Key.

Summary by CodeRabbit

  • Bug Fixes
    • Improved filtering of timeline events to exclude specific event types and prevent incomplete events from being processed.

@coderabbitai

coderabbitai Bot commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The update modifies the logic in the GitHub timeline event adaptation method by introducing a new filter: events of type COMMITTED are now excluded from the adapted list. Additionally, the code no longer logs warnings for skipped or incomplete events, and an import for the relevant event type enumeration is added.

Changes

File(s) Change Summary
backend/analytics_server/mhq/exapi/github.py Added import for PullRequestEventType; updated event filtering to exclude COMMITTED type; removed warning log for skipped events.

Sequence Diagram(s)

sequenceDiagram
    participant GitHubAdapter as GitHubAdapter
    participant Event as TimelineEvent
    participant AdaptedList as AdaptedEvents

    loop For each event in timeline
        GitHubAdapter->>Event: Check required fields (timestamp, type, id, user)
        alt Event.type != COMMITTED
            GitHubAdapter->>AdaptedList: Append event
        else Event.type == COMMITTED
            Note right of GitHubAdapter: Skip event (no warning logged)
        end
    end
Loading

Poem

In the code where events align,
"Committed" types now toe the line.
No warnings echo in the night—
Only the right events take flight.
With a hop and a skip, the filter is tight,
The rabbit approves: the logic feels right! 🐇✨

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bafb28c and d1dedd5.

📒 Files selected for processing (1)
  • backend/analytics_server/mhq/exapi/github.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/analytics_server/mhq/exapi/github.py (2)
backend/analytics_server/mhq/store/models/code/enums.py (1)
  • PullRequestEventType (30-51)
backend/analytics_server/mhq/exapi/models/github_timeline.py (3)
  • timestamp (113-121)
  • id (128-132)
  • user (89-110)
🔇 Additional comments (2)
backend/analytics_server/mhq/exapi/github.py (2)

21-21: Import addition looks correct.

The import for PullRequestEventType is properly added to support the enum comparison in the filtering logic.


377-380: Confirmed use of event.type is correct.

The GithubPullRequestTimelineEvents model defines a @property def type(self) -> Optional[PullRequestEventType] (in backend/analytics_server/mhq/exapi/models/github_timeline.py), which internally maps the raw event_type field to the proper enum. There is no standalone event_type property on the instance, so accessing event.type here correctly returns the PullRequestEventType. No changes required.

Comment on lines +377 to +380
if (
all([event.timestamp, event.type, event.id, event.user])
and event.type != PullRequestEventType.COMMITTED
):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding test coverage for the COMMITTED event exclusion.

The filtering logic successfully excludes COMMITTED events from the adapted timeline, which aligns with the PR objectives. However, consider adding unit tests to verify this behavior works correctly and prevents potential regressions.

Would you like me to generate unit tests for this filtering logic to ensure COMMITTED events are properly excluded?

🤖 Prompt for AI Agents
In backend/analytics_server/mhq/exapi/github.py around lines 377 to 380, the
code filters out events of type COMMITTED from the adapted timeline. To ensure
this exclusion works correctly and to prevent regressions, add unit tests that
specifically create events with type COMMITTED and verify they are excluded by
the filtering logic. Also, include tests for other event types to confirm they
are included as expected.

@jayantbh jayantbh merged commit ede0123 into middlewarehq:main Jul 16, 2025
5 checks passed
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.

Stuck on calculating DORA screen

2 participants