feat(scorecard): add DORA database - #4319
Conversation
Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Assisted-By: Cursor Desktop Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
|
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
|
🤖 Finished Review · ✅ Success · Started 4:49 PM UTC · Completed 5:08 PM UTC Commit: |
PR Summary by Qodofeat(scorecard): persist DORA source data in the database
AI Description
Diagram
High-Level Assessment
Files changed (69)
|
Code Review by Qodo
1.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4319 +/- ##
==========================================
+ Coverage 61.21% 61.35% +0.13%
==========================================
Files 2507 2521 +14
Lines 100348 100786 +438
Branches 28086 28183 +97
==========================================
+ Hits 61430 61834 +404
- Misses 38371 38404 +33
- Partials 547 548 +1
*This pull request uses carry forward flags. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
ReviewFindingsHigh
Medium
Low
Next steps:
Previous runReviewFindingsHigh
Medium
Low
Next steps:
|
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
|
🤖 Review · ❌ Terminated · Started 9:30 AM UTC · Ended 9:50 AM UTC Commit: |
|
There was a problem hiding this comment.
See the review comment for full details.
Note: The following inline comments could not be posted on the diff (GitHub returned 422) and are included here instead:
workspaces/scorecard/.changeset/evil-turtles-return.md(file-level): Line 9 · [high] semver-breaking-change
The changeset marks @red-hat-developer-hub/backstage-plugin-scorecard-backend-module-jira as a minor bump, but the changeset body declares a BREAKING change. The Jira module is at version 4.2.0 (post-1.0), so per semver this should be a major bump. Custom collectors implementing the jira:incidents contract will fail Zod validation after upgrading because the input schema now requires updatedSince and the output schema now requires updatedAt.
Suggested fix: Change the changeset bump type for the Jira module from minor to major, or make the new fields backward-compatible by marking them as optional with fallback behavior.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/metricProviders/schemas/incidentSchemas.ts:23: [medium] collector-contract-compatibility
The DORA module incident collector input schema adds a mandatory updatedSince field. This is the contract the DORA module enforces on ANY incident collector via collectorsService.collect(). The breaking change note only mentions the Jira collector, but the DORA-side schema change affects all incident collectors generically.
Suggested fix: Clarify in the breaking-change notice that the contract change applies to ALL incident collectors registered for DORA metrics, not only jira:incidents. Consider making updatedAt optional with a fallback to createdAt for backward compatibility.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/service/DoraSyncService.ts:144: [low] error handling
In doSyncDeployments, the lastSyncDb.setLastSyncedAt watermark is advanced to options.windowTo after deploymentsDb.upsert succeeds. In practice, upsert failures with Knex are all-or-nothing per statement, so the described partial-failure scenario cannot occur. However, if batching is introduced later, this could become a data loss bug. The same pattern exists in doSyncIncidents.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/service/DoraSyncService.ts:257: [low] edge-case
In doSyncPullRequestsForDeployment, the guard if existing.length > 0 return prevents re-syncing pull requests once any PRs exist for a deployment. If the initial PR sync returns partial results, they will never be picked up. Unlike deployments and incidents which use a watermark, PRs have no mechanism to refresh stale data.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/database/DatabaseDoraDeployments.ts:52: [low] unbounded-batch-insert
The upsert methods in all Database*Store classes insert the entire array in a single INSERT statement without any batch-size limit. Practical record counts are bounded by collectors own limits, but the contract does not enforce an upper bound.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/scheduler/utils.ts:17: [low] function-declaration-style
The daysToMilliseconds function uses arrow-function-assigned-to-const style, while every other exported utility function in this codebase uses the export function declaration style.
workspaces/scorecard/plugins/scorecard-backend-module-dora/src/database/DatabaseDoraDeployments.ts:17: [low] import-style
Uses value import import { Knex } from knex while Knex is only used as a type annotation. Same pattern in all four Database*Store files.
workspaces/scorecard/plugins/scorecard-backend-module-jira/src/collectors/schemas/incidentSchemas.ts:32: [low] schema-strictness-asymmetry
The Jira module incident output schema uses plain z.object() (default strip mode) while the DORA module uses .strict(). This asymmetry is pre-existing and not introduced by this PR.
|
🤖 Finished Review · ✅ Success · Started 9:30 AM UTC · Completed 9:50 AM UTC Commit: |



Hey, I just made a Pull Request!
scorecard-dora:cleanup-expired-datawith retention viascorecard.plugins.dora.dataRetentionDays(default 365)scorecard.plugins.dora.staleAfterMsfor DORA deployment and incident collector refresh - if last successful deployments or incidents sync for a collector is within this value, data refresh is skipped and existing database data is reused.Fixes
Fixes https://redhat.atlassian.net/browse/RHIDP-14848
✔️ Checklist