Skip to content

Conversation

@dzemanov
Copy link
Member

@dzemanov dzemanov commented Sep 29, 2025

Hey, I just made a Pull Request!

Adds database.
Adds schedulers.

Fixes

https://issues.redhat.com/browse/RHIDP-8717

How to test

  1. Use sqllite database
backend:
  database:
    client: better-sqlite3
    connection:
      directory: './db'

Creates db directory under scorecard/packages
Or:

backend:
  database:
    client: better-sqlite3
    connection: ':memory:'
  1. Use Postgres db
backend:
  database:
    client: pg
    connection:
      host: localhost
      port: 5432
      user: ${POSTGRES_USER}
      password:${POSTGRES_PASSWORD}

For testing purposes, you can update schedule to fetch metrics more often:

scorecard:
  dataRetentionDays: 1
  plugins:
    jira:
      open_issues:
        schedule:
          frequency: { minutes: 2 }
          timeout: { minutes: 15 }
          initialDelay: { seconds: 3 }
    github:
      open_prs:
        schedule:
          frequency: { minutes: 2 }
          timeout: { minutes: 15 }
          initialDelay: { seconds: 3 }

You should see in logs:

2025-10-03T19:46:36.590Z scorecard info Task worker starting: github.open_prs, {"version":2,"cadence":"PT2M","initialDelayDuration":"PT3S","timeoutAfterDuration":"PT15M"} task="github.open_prs"
2025-10-03T19:46:36.591Z scorecard info Task worker starting: jira.open_issues, {"version":2,"cadence":"PT2M","initialDelayDuration":"PT3S","timeoutAfterDuration":"PT15M"} task="jira.open_issues"
2025-10-03T19:46:36.591Z scorecard info Scheduled 2/2 metric providers 

2025-10-03T19:46:39.595Z scorecard info Refreshing metrics for github.open_prs class="MetricProvidersScheduler" taskId="github.open_prs:refresh" taskInstanceId="8ba58bad-08e8-4005-8b7f-314fde6e3bb9"
2025-10-03T19:46:39.596Z scorecard info Refreshing metrics for jira.open_issues class="MetricProvidersScheduler" taskId="jira.open_issues:refresh" taskInstanceId="026e7e65-085a-4592-956d-df554f697b4c"

2025-10-03T19:46:40.543Z scorecard info Completed metric refresh for jira.open_issues: processed 2 entities class="MetricProvidersScheduler" taskId="jira.open_issues:refresh" taskInstanceId="026e7e65-085a-4592-956d-df554f697b4c"
2025-10-03T19:46:40.758Z scorecard info Completed metric refresh for github.open_prs: processed 3 entities class="MetricProvidersScheduler" taskId="github.open_prs:refresh" taskInstanceId="8ba58bad-08e8-4005-8b7f-314fde6e3bb9"

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Sep 29, 2025

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Unexpected Changesets

The following changeset(s) reference packages that have not been changed in this PR:

  • /home/runner/work/rhdh-plugins/rhdh-plugins/workspaces/scorecard/.changeset/free-rice-pick.md: @red-hat-developer-hub/backstage-plugin-scorecard

Note that only changes that affect the published package require changesets, for example changes to tests and storybook stories do not require changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-github workspaces/scorecard/plugins/scorecard-backend-module-github minor v1.0.0
@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-jira workspaces/scorecard/plugins/scorecard-backend-module-jira minor v1.0.1
@red-hat-developer-hub/backstage-plugin-scorecard-backend workspaces/scorecard/plugins/scorecard-backend minor v1.0.0
@red-hat-developer-hub/backstage-plugin-scorecard-node workspaces/scorecard/plugins/scorecard-node minor v1.0.0

@dzemanov dzemanov force-pushed the scorecard-db-schedulers branch from 7449254 to 97b6ba1 Compare October 3, 2025 18:10
@imykhno imykhno force-pushed the scorecard-db-schedulers branch 5 times, most recently from 07a5a55 to 5e87ead Compare October 20, 2025 10:03
@imykhno imykhno marked this pull request as ready for review October 20, 2025 10:12
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
Signed-off-by: Dominika Zemanovicova <[email protected]>
@imykhno imykhno force-pushed the scorecard-db-schedulers branch from 5e87ead to 2883b1d Compare October 24, 2025 12:49
@imykhno imykhno force-pushed the scorecard-db-schedulers branch from 2883b1d to 2964f31 Compare October 24, 2025 14:18
@sonarqubecloud
Copy link

Copy link
Member Author

Choose a reason for hiding this comment

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

Would rename to Scheduler since you already have scheduler.test.ts

* limitations under the License.
*/

export const CLEANUP_EXPIRED_METRICS_ID = 'cleanup-expired-metrics' as const;
Copy link
Member Author

Choose a reason for hiding this comment

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

Would maybe prefix it with scorecard: just to be sure it doesn't intersect anything.

Comment on lines +45 to +51
private readonly scheduler: SchedulerService,
private readonly logger: LoggerService,
private readonly database: DatabaseMetricValues,
private readonly config: Config,
private readonly catalog: CatalogService,
private readonly auth: AuthService,
private readonly provider: MetricProvider,
Copy link
Member Author

Choose a reason for hiding this comment

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

This to me looks like a lot of params. Just a recommendation, we could group under options or similiar name all except provider.

'@red-hat-developer-hub/backstage-plugin-scorecard': minor
---

Adds database persistence and scheduled metric collection.
Copy link
Member Author

Choose a reason for hiding this comment

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

I would add breaking here since we are now requiring getCatalogFilter
**BREAKING**: ...

  • Add information about what is breaking - getCatalogFilter

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