diff --git a/apps/docs/docs/integrate/api.md b/apps/docs/docs/integrate/api.md index b6866469b..1ea928c6f 100644 --- a/apps/docs/docs/integrate/api.md +++ b/apps/docs/docs/integrate/api.md @@ -52,7 +52,7 @@ query GetProjects { projects(limit: 10) { project_id project_name - project_slug + project_display_name user_namespace } } @@ -67,7 +67,6 @@ query GetCodeMetrics { order_by: { star_count: desc_nulls_last } ) { project_id - project_slug project_name artifact_namespace repository_count diff --git a/warehouse/dbt/models/intermediate/metrics/int_repo_metrics_by_project.sql b/warehouse/dbt/models/intermediate/metrics/int_repo_metrics_by_project.sql index c9ddfd696..7d0d1b593 100644 --- a/warehouse/dbt/models/intermediate/metrics/int_repo_metrics_by_project.sql +++ b/warehouse/dbt/models/intermediate/metrics/int_repo_metrics_by_project.sql @@ -4,7 +4,7 @@ with repo_artifact as ( is_fork, fork_count, star_count, - --license, + license_spdx_id, watcher_count, CAST(id as STRING) as artifact_source_id, LOWER(owner) as artifact_namespace, @@ -17,7 +17,7 @@ repo_snapshot as ( {{ oso_id("a.artifact_source", "a.artifact_source_id") }} as `artifact_id`, artifact_namespace, artifact_name, - --license, + license_spdx_id, is_fork, fork_count, star_count, @@ -50,6 +50,7 @@ select repo_snapshot.fork_count, repo_snapshot.star_count, repo_snapshot.watcher_count, + repo_snapshot.license_spdx_id, repo_stats.first_commit_time, repo_stats.last_commit_time, repo_stats.days_with_commits_count, diff --git a/warehouse/dbt/models/marts/superchain/rf4_repo_stats_by_project.sql b/warehouse/dbt/models/marts/superchain/rf4_repo_stats_by_project.sql new file mode 100644 index 000000000..45e0a0431 --- /dev/null +++ b/warehouse/dbt/models/marts/superchain/rf4_repo_stats_by_project.sql @@ -0,0 +1,39 @@ +select + int_repo_metrics_by_project.project_id, + int_repo_metrics_by_project.artifact_id, + projects_v1.project_name, + int_repo_metrics_by_project.artifact_namespace, + int_repo_metrics_by_project.artifact_name, + int_repo_metrics_by_project.is_fork, + int_repo_metrics_by_project.fork_count, + int_repo_metrics_by_project.star_count, + --int_repo_metrics_by_project.first_commit_time, + --int_repo_metrics_by_project.last_commit_time, + --int_repo_metrics_by_project.days_with_commits_count, + --int_repo_metrics_by_project.contributors_to_repo_count, + int_repo_metrics_by_project.license_spdx_id, + case + {# TODO: Review licenses https://spdx.org/licenses/ for OSI Approved #} + when int_repo_metrics_by_project.license_spdx_id in ( + 'MIT', 'MIT-0', 'Apache-2.0', 'Unlicense', + 'BSD-2-Clause', 'BSD-3-Clause', 'BSD-3-Clause-Clear', + 'AGPL-3.0', 'GPL-3.0', 'LGPL-3.0', 'GPL-2.0', 'MPL-2.0', 'LGPL-2.1', + 'OFL-1.1', 'EPL-1.0', 'EPL-2.0', 'OFL-1.1', 'EUPL-1.2', 'OSL-3.0', + 'ISC', '0BSD', 'NCSA', 'Zlib' + ) then 'Permissive' + when int_repo_metrics_by_project.license_spdx_id in ( + 'BSD-4-Clause', 'WTFPL', 'NOASSERTION', + 'CC0-1.0', 'CC-BY-SA-4.0', 'CC-BY-4.0' + ) then 'Restrictive' + else 'Unspecified' + end as license_type +from {{ ref('int_repo_metrics_by_project') }} +left join {{ ref('projects_v1') }} + on int_repo_metrics_by_project.project_id = projects_v1.project_id +left join {{ ref('projects_by_collection_v1') }} + on + int_repo_metrics_by_project.project_id + = projects_by_collection_v1.project_id +where + {# TODO: update with actual collection for RF4 #} + projects_by_collection_v1.collection_name = 'op-onchain' \ No newline at end of file diff --git a/warehouse/dbt/models/staging/oss-directory/stg_ossd__current_repositories.sql b/warehouse/dbt/models/staging/oss-directory/stg_ossd__current_repositories.sql index 1d480834c..cd26c0e0b 100644 --- a/warehouse/dbt/models/staging/oss-directory/stg_ossd__current_repositories.sql +++ b/warehouse/dbt/models/staging/oss-directory/stg_ossd__current_repositories.sql @@ -18,6 +18,8 @@ select repositories.watcher_count, repositories.fork_count, repositories.is_fork, + repositories.license_name, + repositories.license_spdx_id, repositories._cq_sync_time as `sync_time` from {{ oso_source('ossd', 'repositories') }} as repositories where _cq_sync_time = (select * from most_recent_sync)