Skip to content

Commit

Permalink
fix: Add _v1 to artifacts_by_project and projects_by_collection (#1339)
Browse files Browse the repository at this point in the history
* Update references
* Rename user_namespace to project_namespace and collection_namespace
  • Loading branch information
ryscheng authored May 1, 2024
1 parent 8b0678a commit 747b452
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SELECT
ptc.collection_id,
p.id AS project_id,
p.slug AS project_slug,
p.namespace AS user_namespace,
p.namespace AS project_namespace,
p.name AS project_name
FROM {{ ref('stg_ossd__projects_by_collection') }} AS ptc
INNER JOIN {{ ref('stg_ossd__current_projects') }} AS p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
}}

SELECT
atp.project_id AS project_id,
p.project_slug AS project_slug,
atp.artifact_id AS artifact_id,
atp.artifact_namespace AS artifact_namespace,
atp.artifact_type AS artifact_type,
atp.artifact_name AS artifact_name
atp.artifact_name AS artifact_name,
p.project_id,
p.project_namespace,
p.project_slug,
p.project_name
FROM {{ ref('stg_ossd__artifacts_by_project') }} AS atp
LEFT JOIN {{ ref('projects_v1') }} AS p
ON atp.project_id = p.project_id
2 changes: 1 addition & 1 deletion warehouse/dbt/models/marts/directory/collections_v1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

SELECT
id AS collection_id,
namespace AS user_namespace,
namespace AS collection_namespace,
slug AS collection_slug,
name AS collection_name
FROM {{ ref('stg_ossd__current_collections') }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ SELECT
atp.artifact_id AS artifact_id,
atp.artifact_namespace AS artifact_namespace,
atp.artifact_name AS artifact_name
FROM {{ ref('artifacts_by_project') }} AS atp
FROM {{ ref('artifacts_by_project_v1') }} AS atp
WHERE atp.artifact_type = 'DEPLOYER'
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
}}
SELECT
pbc.project_id,
pbc.project_namespace,
pbc.project_slug,
pbc.project_name,
c.collection_id,
c.collection_namespace,
c.collection_slug,
c.collection_name
FROM {{ ref('int_projects_by_collection') }} AS pbc
Expand Down
2 changes: 1 addition & 1 deletion warehouse/dbt/models/marts/directory/projects_v1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

SELECT
project_id,
namespace AS user_namespace,
namespace AS project_namespace,
project_slug,
project_name
FROM {{ ref('int_projects') }}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contracts AS (
project_id,
artifact_namespace AS network,
COUNT(DISTINCT artifact_name) AS num_contracts
FROM {{ ref('artifacts_by_project') }}
FROM {{ ref('artifacts_by_project_v1') }}
WHERE artifact_type IN ('CONTRACT', 'FACTORY')
GROUP BY 1, 2
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ SELECT
a.project_id,
COUNT(DISTINCT a.artifact_id) AS amount
FROM valid_contracts AS v
LEFT JOIN {{ ref('artifacts_by_project') }} AS a
LEFT JOIN {{ ref('artifacts_by_project_v1') }} AS a
ON v.artifact_id = a.artifact_id
GROUP BY 1

0 comments on commit 747b452

Please sign in to comment.