-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbt: refactor projects mart to use int model (#1262)
* refactor: create int_projects * update projects mart * change comments
- Loading branch information
Showing
3 changed files
with
47 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
36 changes: 36 additions & 0 deletions
36
warehouse/dbt/models/intermediate/directory/int_projects.sql
This file contains 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,36 @@ | ||
WITH ranked_repos AS ( | ||
SELECT | ||
project_id, | ||
owner, | ||
star_count, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY project_id ORDER BY star_count DESC | ||
) AS row_number, | ||
COUNT(DISTINCT owner) OVER (PARTITION BY project_id) AS count_github_owners | ||
FROM {{ ref('stg_ossd__repositories_by_project') }} | ||
), | ||
|
||
project_owners AS ( | ||
SELECT | ||
project_id, | ||
count_github_owners, | ||
LOWER(owner) AS primary_github_owner | ||
{# TODO: is_git_organization #} | ||
FROM ranked_repos | ||
WHERE row_number = 1 | ||
) | ||
|
||
SELECT | ||
p.id AS project_id, | ||
p.slug AS project_slug, | ||
{# TODO: description AS project_description #} | ||
p.name AS project_name, | ||
p.namespace AS namespace, | ||
po.primary_github_owner, | ||
po.count_github_owners, | ||
ARRAY_LENGTH(JSON_EXTRACT_ARRAY(p.github)) AS count_github_artifacts, | ||
ARRAY_LENGTH(JSON_EXTRACT_ARRAY(p.blockchain)) AS count_blockchain_artifacts, | ||
ARRAY_LENGTH(JSON_EXTRACT_ARRAY(p.npm)) AS count_npm_artifacts | ||
FROM {{ ref('stg_ossd__current_projects') }} AS p | ||
LEFT JOIN project_owners AS po | ||
ON p.id = po.project_id |
This file contains 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