New updatedAt record for services#1428
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughService jobs now record ChangesService job update tracking
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant GetServicesHandler
participant SQLiteCompute
Client->>GetServicesHandler: Send updatedSince cursor
GetServicesHandler->>GetServicesHandler: Validate and parse cursor
GetServicesHandler->>SQLiteCompute: Read all service jobs
SQLiteCompute-->>GetServicesHandler: Return jobs with updatedAt
GetServicesHandler-->>Client: Return jobs updated since cursor
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
/run-security-scan |
|
@coderabbitai review |
✅ Action performedReview finished.
|
alexcos20
left a comment
There was a problem hiding this comment.
AI automated code review (Gemini 3).
Overall risk: low
Summary:
This PR successfully adds the updatedAt timestamp to service jobs and implements the ability to incrementally sync jobs via updatedSince. The implementation handles backward compatibility correctly for existing records that lack the updatedAt field, and the unit tests are comprehensive and well-written.
Comments:
• [INFO][style] There is a minor typo in the validation error message (an extra space before the colon). Consider removing it for consistency with other error formats in this file.
- 'Parameter : "updatedSince" is not a valid string'
+ 'Parameter "updatedSince" is not a valid string'• [INFO][performance] While this aligns with existing code patterns, loading all service jobs into memory via getServiceJob() to perform application-level filtering can become a performance bottleneck at scale. As a future improvement, consider pushing this filtering down to the database query layer (e.g., utilizing SQLite's JSON functions like json_extract(json, '$.updatedAt') >= ?).
• [INFO][style] Good use of the object spread syntax to cleanly inject or overwrite the updatedAt timestamp into the persisted JSON payload before saving to the database. LGTM!
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/core/service/getServices.ts`:
- Around line 63-71: Update the updatedSince validation in the service request
flow around command.updatedSince and parseFromTimestamp to reject empty strings
and non-finite parsed timestamps before the all-jobs or unfiltered paths
execute. Preserve valid ISO dates and finite Unix timestamps, and add validation
tests covering an empty cursor and an overflowing numeric cursor that must
return a 400 response.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7479e9ea-a2eb-4017-bc54-b1b174789580
📒 Files selected for processing (6)
src/@types/C2D/ServiceOnDemand.tssrc/@types/commands.tssrc/components/core/service/getServices.tssrc/components/database/sqliteCompute.tssrc/test/unit/service/serviceHandlers.test.tssrc/test/unit/service/serviceJobsDatabase.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
/run-security-scan |
alexcos20
left a comment
There was a problem hiding this comment.
AI automated code review (Gemini 3).
Overall risk: low
Summary:
This PR introduces incremental fetching of services by adding an updatedAt timestamp to ServiceJobs and allowing queries via the updatedSince parameter. The implementation handles backward compatibility correctly, and adds strict validation for timestamp inputs.
Comments:
• [INFO][security] Using Number.isFinite is an excellent improvement over strictly checking for null. This prevents invalid inputs that parse to NaN or Infinity (like overflowing string numbers) from bypassing validation, avoiding potential edge cases or unexpected behaviors downstream.
• [INFO][performance] Fetching all jobs into memory via await eng.db.getServiceJob() and filtering application-side is consistent with the existing codebase logic. However, for nodes maintaining a massive number of jobs, this could eventually become a memory and processing bottleneck. Consider moving filtering to the database query level (e.g., adding indexes and query arguments for clusterHash and updatedAt) in a future architectural refactor.
• [INFO][style] Using the object spread operator ...job to inject the updatedAt timestamp inside JSON.stringify is a clean pattern. It ensures the database payload gets the new field without unintentionally mutating the original job reference in memory.
LGTM!
Fixes # .
Changes proposed in this PR:
Summary by CodeRabbit
New Features
updatedSincetimestamp.updatedAttimestamp.Bug Fixes
updatedSincevalues now return a clear bad-request response.