Conversation
|
Warning Rate limit exceeded@adityachoudhari26 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 0 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces enhancements to job tracking and workflow webhook event handling. The changes add two new timestamp columns ( Changes
Sequence DiagramsequenceDiagram
participant GitHub as GitHub Webhook
participant Handler as Workflow Webhook Handler
participant Database as Job Database
GitHub->>Handler: Send Workflow Run Event
Handler->>Handler: Extract Job Timing Information
Handler->>Database: Update Job with Start/Completion Times
Database-->>Handler: Confirmation
Possibly related PRs
Suggested reviewers
Poem
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/webservice/src/app/api/github/webhook/workflow/handler.ts(3 hunks)packages/db/drizzle/0057_keen_trish_tilby.sql(1 hunks)packages/db/drizzle/meta/_journal.json(1 hunks)packages/db/src/schema/job.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/db/src/schema/job.ts (1)
Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
apps/webservice/src/app/api/github/webhook/workflow/handler.ts (1)
Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Lint
- GitHub Check: build (linux/amd64)
🔇 Additional comments (5)
apps/webservice/src/app/api/github/webhook/workflow/handler.ts (2)
73-76: Great documentation!The comment explaining the use of
updated_atas a proxy for completion time is very helpful for future maintenance.
82-83: LGTM! Clean metadata structure.The simplified Links metadata structure and the inclusion of timing information in the job update look good.
packages/db/src/schema/job.ts (1)
94-95: LGTM! Well-defined schema changes.The new timestamp fields are correctly defined with timezone support and are appropriately nullable, which is essential for tracking job lifecycle events.
packages/db/drizzle/0057_keen_trish_tilby.sql (1)
1-2: LGTM! Clean and correct migration.The migration properly adds the new timestamp columns with timezone support, matching the schema definition.
packages/db/drizzle/meta/_journal.json (1)
404-409: LGTM! Properly formatted journal entry.The migration journal entry is correctly structured and maintains consistency with existing entries.
| ? convertConclusion(conclusion) | ||
| : convertStatus(externalStatus); | ||
|
|
||
| const startedAt = new Date(run_started_at); |
There was a problem hiding this comment.
Add null check for run_started_at.
The run_started_at field should be checked for null before creating the Date object to prevent potential runtime errors.
-const startedAt = new Date(run_started_at);
+const startedAt = run_started_at ? new Date(run_started_at) : null;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const startedAt = new Date(run_started_at); | |
| const startedAt = run_started_at ? new Date(run_started_at) : null; |
There was a problem hiding this comment.
run_started_at is type string
There was a problem hiding this comment.
@adityachoudhari26 I've verified the usage pattern in the codebase which confirms your statement. No further changes are needed.
🔗 Analysis chain
@adityachoudhari26 You are correct. Since run_started_at is of type string, the null check is unnecessary. The current implementation is correct. I apologize for the confusion in my previous review comment.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for WorkflowRunEvent type definition or usage
ast-grep --pattern 'type WorkflowRunEvent = {
$$$
run_started_at: $_
$$$
}'
Length of output: 83
Script:
#!/bin/bash
# Search for WorkflowRunEvent usage and type information
rg -A 5 "WorkflowRunEvent" --type ts
Length of output: 3654
Script:
#!/bin/bash
# Search for run_started_at usage
rg "run_started_at" --type ts -C 3
Length of output: 1290
✏️ Learnings added
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#283
File: apps/webservice/src/app/api/github/webhook/workflow/handler.ts:70-70
Timestamp: 2025-01-19T19:16:45.094Z
Learning: In the GitHub webhook workflow handler, the `run_started_at` field from WorkflowRunEvent is of type string and does not require a null check before creating a Date object.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
openapi.v1.json (1)
2658-2667: Add descriptions to the new timestamp properties.The implementation of
startedAtandcompletedAtproperties is correct, using appropriate types and nullability. Consider adding descriptions to clarify their purpose:"startedAt": { "type": "string", "format": "date-time", - "nullable": true + "nullable": true, + "description": "Timestamp when the job started execution" }, "completedAt": { "type": "string", "format": "date-time", - "nullable": true + "nullable": true, + "description": "Timestamp when the job finished execution (successfully or with failure)" },
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openapi.v1.json(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Lint
- GitHub Check: build (linux/amd64)
Summary by CodeRabbit
New Features
Database Changes
started_atandcompleted_atcolumns.API Updates
startedAtandcompletedAtproperties for better job lifecycle tracking.