-
Notifications
You must be signed in to change notification settings - Fork 9
KTL-4386: Implement OSS Health index metric #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Nikita Vlaev (nikitavlaevjb)
merged 13 commits into
feature/KTL-4245-Explore-insights-meta
from
feature/KTL-4386-Implement-OSS-Health-index-metric
May 29, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7ff0d4f
KTL-4370: Fall back to search.maven.org content endpoint when the cac…
nikitavlaevjb f3a184a
KTL-4386: Add data model and queue columns for OSS Health metric.
nikitavlaevjb ea44af1
KTL-4386: Extend GitHub integration to stream issue/PR events and rea…
nikitavlaevjb eb4b602
KTL-4386: Add OSS Health formula and yaml-tunable thresholds.
nikitavlaevjb 64588ad
KTL-4386: Add scheduled jobs to populate OSS Health components.
nikitavlaevjb 9ea68a4
KTL-4386: Expose ossHealthScore on project details API.
nikitavlaevjb 0276fe0
KTL-4386: Allow sorting projects by OSS Health score.
nikitavlaevjb 8ed64aa
KTL-4386: Expose ossHealthScore on project search API.
nikitavlaevjb aa57e4a
KTL-4386: Added rate limit checking for Github
nikitavlaevjb 9ce2f19
KTL-4386: Merge OSS health sync and score jobs into the repo update l…
nikitavlaevjb 3a3e76e
KTL-4386: Bundle frontend changes for OSS Health metric (project type…
nikitavlaevjb 346a942
KTL-4386: Added id to ScmRepoIssueEventRepository table
nikitavlaevjb 5dfa241
Reworked Github prometheus metrics
nikitavlaevjb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
184 changes: 184 additions & 0 deletions
184
app/src/main/resources/db/migration/2026-Q2/2026-04-24_oss_health_metric.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| databaseChangeLog: | ||
| - changeSet: | ||
| id: create scm_repo_issue_or_pr table | ||
| author: nikita.vlaev@jetbrains.com | ||
| comment: "KTL-4386: Sliding-window store of closed issues and merged PRs for OSS Health index." | ||
| preConditions: | ||
| - onFail: MARK_RAN | ||
| - not: | ||
| tableExists: | ||
| tableName: scm_repo_issue_or_pr | ||
| changes: | ||
| - createTable: | ||
| tableName: scm_repo_issue_or_pr | ||
| columns: | ||
| - column: | ||
| name: id | ||
| type: BIGINT | ||
| constraints: | ||
| nullable: false | ||
| primaryKey: true | ||
| primaryKeyName: pk_scm_repo_issue_or_pr | ||
| - column: | ||
| name: scm_repo_id | ||
| type: INT | ||
| constraints: | ||
| nullable: false | ||
| foreignKeyName: fk_scm_repo_issue_or_pr_scm_repo_id | ||
| references: scm_repo(id) | ||
| - column: | ||
| name: gh_number | ||
| type: INT | ||
| remarks: "GitHub's per-repo issue/PR number (the integer in /issues/N URLs); together with scm_repo_id, this is the upsert dedup key." | ||
| constraints: | ||
| nullable: false | ||
| - column: | ||
| name: type | ||
| type: VARCHAR(8) | ||
| remarks: "ISSUE or PR. Aggregate queries filter by this since I and P sub-scores are computed separately." | ||
| constraints: | ||
| nullable: false | ||
| - column: | ||
| name: created_at | ||
| type: TIMESTAMP | ||
| constraints: | ||
| nullable: false | ||
| - column: | ||
| name: closed_at | ||
| type: TIMESTAMP | ||
| - column: | ||
| name: merged_at | ||
| type: TIMESTAMP | ||
| - column: | ||
| name: duration_days | ||
| type: INT | ||
| - addUniqueConstraint: | ||
| tableName: scm_repo_issue_or_pr | ||
| columnNames: scm_repo_id, gh_number | ||
| constraintName: uq_scm_repo_issue_or_pr_repo_number | ||
|
|
||
| - changeSet: | ||
| id: create scm_repo_issue_or_pr sequence | ||
| author: nikita.vlaev@jetbrains.com | ||
| preConditions: | ||
| - onFail: MARK_RAN | ||
| - not: | ||
| sequenceExists: | ||
| sequenceName: scm_repo_issue_or_pr_id_seq | ||
| changes: | ||
| - sql: | ||
| sql: | | ||
| CREATE SEQUENCE scm_repo_issue_or_pr_id_seq | ||
| AS BIGINT | ||
| INCREMENT BY 50 | ||
| START WITH 1; | ||
|
|
||
| - changeSet: | ||
| id: index scm_repo_issue_or_pr on repo/type/closed | ||
| author: nikita.vlaev@jetbrains.com | ||
| preConditions: | ||
| - onFail: MARK_RAN | ||
| - not: | ||
| indexExists: | ||
| tableName: scm_repo_issue_or_pr | ||
| indexName: scm_repo_issue_or_pr_repo_type_closed_idx | ||
| changes: | ||
| - createIndex: | ||
| indexName: scm_repo_issue_or_pr_repo_type_closed_idx | ||
| tableName: scm_repo_issue_or_pr | ||
| columns: | ||
| - column: | ||
| name: scm_repo_id | ||
| - column: | ||
| name: type | ||
| - column: | ||
| name: closed_at | ||
|
|
||
| - changeSet: | ||
| id: index scm_repo_issue_or_pr on repo/type/created | ||
| author: nikita.vlaev@jetbrains.com | ||
| preConditions: | ||
| - onFail: MARK_RAN | ||
| - not: | ||
| indexExists: | ||
| tableName: scm_repo_issue_or_pr | ||
| indexName: scm_repo_issue_or_pr_repo_type_created_idx | ||
| changes: | ||
| - createIndex: | ||
| indexName: scm_repo_issue_or_pr_repo_type_created_idx | ||
| tableName: scm_repo_issue_or_pr | ||
| columns: | ||
| - column: | ||
| name: scm_repo_id | ||
| - column: | ||
| name: type | ||
| - column: | ||
| name: created_at | ||
|
|
||
| - changeSet: | ||
| id: create scm_repo_health_components table | ||
| author: nikita.vlaev@jetbrains.com | ||
| comment: "KTL-4386: Per-repo OSS Health components snapshot (one row per repo, overwritten each run)." | ||
| preConditions: | ||
| - onFail: MARK_RAN | ||
| - not: | ||
| tableExists: | ||
| tableName: scm_repo_health_components | ||
| changes: | ||
| - createTable: | ||
| tableName: scm_repo_health_components | ||
| columns: | ||
| - column: | ||
| name: scm_repo_id | ||
| type: INT | ||
| constraints: | ||
| nullable: false | ||
| primaryKey: true | ||
| foreignKeyName: fk_scm_repo_health_components_scm_repo_id | ||
| references: scm_repo(id) | ||
| - column: | ||
| name: score_recomputed_ts | ||
| type: TIMESTAMP | ||
| - column: | ||
| name: issue_opened_count | ||
| type: INT | ||
| - column: | ||
| name: issue_closed_count | ||
| type: INT | ||
| - column: | ||
| name: median_issue_close_days | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: pr_opened_count | ||
| type: INT | ||
| - column: | ||
| name: pr_merged_count | ||
| type: INT | ||
| - column: | ||
| name: median_pr_merge_days | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: active_contributors | ||
| type: INT | ||
| - column: | ||
| name: top_contributor_share | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: c_score | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: i_score | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: p_score | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: a_score | ||
| type: DOUBLE PRECISION | ||
| - column: | ||
| name: health_score | ||
| type: INT | ||
| - column: | ||
| name: last_issue_or_pr_sync_ts | ||
| type: TIMESTAMP | ||
| remarks: "Last time the issue/PR sync populated I/P inputs for this repo; drives the issue/PR sync queue." | ||
67 changes: 67 additions & 0 deletions
67
...in/resources/db/migration/2026-Q2/2026-04-30_recreate_project_index_with_health_score.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| DROP MATERIALIZED VIEW IF EXISTS project_index; | ||
|
|
||
| CREATE MATERIALIZED VIEW project_index AS | ||
| WITH package_info AS (SELECT project.id, | ||
| array_agg(DISTINCT platform) AS platforms, | ||
| array_to_tsvector(array_agg(DISTINCT platform)) AS platforms_vector, | ||
| string_agg(format('%s:1', pckg.group_id), ' ')::tsvector AS group_ids_vector, | ||
| string_agg(format('%s:2', pckg.artifact_id), ' ')::tsvector AS artifact_ids_vector, | ||
| array_to_tsvector(array_remove( | ||
| array_agg(DISTINCT COALESCE(platform || '_' || target, platform)), | ||
| NULL)) AS targets_vector | ||
| FROM project | ||
| JOIN package_index pckg ON project.id = pckg.project_id | ||
| JOIN scm_owner owner ON project.owner_id = owner.id | ||
| CROSS JOIN LATERAL unnest(pckg.platforms) as platform | ||
| LEFT JOIN LATERAL jsonb_array_elements_text(COALESCE(pckg.targets -> platform, '[]'::jsonb)) AS target | ||
| ON true | ||
| WHERE NOT (owner.login = 'androidx' AND project.name = 'room' AND platform IN ('WASM', 'JS')) | ||
| GROUP BY project.id), | ||
| markers_info AS (SELECT project_marker.project_id, | ||
| array_agg(DISTINCT project_marker.type) AS markers | ||
| FROM project_marker | ||
| GROUP BY project_marker.project_id), | ||
| tags_info AS (SELECT project_id, | ||
| COALESCE( | ||
| array_agg(DISTINCT value ORDER BY value DESC) FILTER (WHERE origin = 'USER'), | ||
| array_agg(DISTINCT value ORDER BY value DESC) FILTER (WHERE origin = 'GITHUB'), | ||
| array_agg(DISTINCT value ORDER BY value DESC) FILTER (WHERE origin = 'AI') | ||
| ) AS tags | ||
| FROM project_tags | ||
| GROUP BY project_id) | ||
| SELECT project.id AS project_id, | ||
| owner.type AS owner_type, | ||
| owner.login AS owner_login, | ||
| repo.name AS repo_name, -- We still need this to form GH repo link and GH pages link, because androidx projects have diffent names for repository and project. | ||
| project.name, | ||
| repo.stars, | ||
| repo.license_name, | ||
| project.latest_version, | ||
| project.latest_version_ts, | ||
| package_info.platforms, | ||
| package_info.platforms_vector, | ||
| package_info.targets_vector, | ||
| coalesce(project.description, repo.description) AS plain_description, | ||
| tags_info.tags AS tags, | ||
| markers_info.markers AS markers, | ||
| project.dependent_count AS dependent_count, | ||
| health.health_score AS health_score, | ||
| (setweight(to_tsvector(owner.login), 'A') || | ||
| setweight(to_tsvector(project.name), 'A') || | ||
| setweight(format('%s:1', project.name)::tsvector, 'A') || | ||
| setweight(format('%s:1', owner.login)::tsvector, 'A') || | ||
| setweight(package_info.group_ids_vector, 'B') || | ||
| setweight(package_info.artifact_ids_vector, 'B') || | ||
| setweight(to_tsvector(coalesce(owner.name, '')), 'D') || | ||
| setweight(to_tsvector(coalesce(owner.description, '')), 'D') || | ||
| setweight(to_tsvector(coalesce(project.minimized_readme, '')), 'D') || | ||
| setweight(to_tsvector(coalesce(project.description, '')), 'C') || | ||
| setweight(to_tsvector(coalesce(repo.description, '')), 'C') || | ||
| setweight(to_tsvector(coalesce(array_to_string(tags_info.tags, ' '), '')), 'B')) AS fts | ||
| FROM project | ||
| JOIN package_info ON project.id = package_info.id | ||
| JOIN scm_owner owner ON project.owner_id = owner.id | ||
| JOIN scm_repo repo ON project.scm_repo_id = repo.id | ||
| LEFT JOIN markers_info on markers_info.project_id = project.id | ||
| LEFT JOIN tags_info on tags_info.project_id = project.id | ||
| LEFT JOIN scm_repo_health_components health on health.scm_repo_id = repo.id; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.