Skip to content

Commit 342942f

Browse files
committed
feat: add oss packages enrichment sink
Signed-off-by: anilb <epipav@gmail.com>
1 parent e1c746d commit 342942f

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

services/libs/tinybird/datasources/repoActivitySnapshot.datasource

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ SCHEMA >
3737
`issueMedianTimeToFirstResponseHours` Nullable(Int32) `json:$.record.issue_median_time_to_first_response_hours`
3838

3939
ENGINE ReplacingMergeTree
40-
ENGINE_PARTITION_KEY toYear(snapshotAt)
4140
ENGINE_SORTING_KEY repoId
4241
ENGINE_VER snapshotAt

services/libs/tinybird/pipes/ossPackages_enriched.pipe

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ SQL >
352352
multiIf(
353353
coalesce(ro.inRepositories, 0) = 1,
354354
'available',
355-
coalesce(mh.maintainersCount, 0) > 0,
355+
coalesce(mh.emailDomains, 0) > 0,
356356
'partial',
357357
'blocked'
358358
),
@@ -371,7 +371,13 @@ SQL >
371371
'dependency_health',
372372
if(coalesce(dv.hasDeps, 0) = 1, 'available', 'blocked'),
373373
'security_practices',
374-
if(r.branchProtectionEnabled IS NULL, 'partial', 'available'),
374+
multiIf(
375+
r.repoId IS NULL,
376+
'blocked',
377+
r.branchProtectionEnabled IS NULL,
378+
'partial',
379+
'available'
380+
),
375381
'supply_chain_integrity',
376382
'blocked',
377383
'release_cadence',
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
DESCRIPTION >
2+
Sink pipe that exports per-package enrichment (health/lifecycle) fields back to Kafka so a
3+
Kafka Connect JDBC sink can update the Postgres `packages` rows. Scoped to critical packages
4+
(isCritical = 1), since enrichment is only computed/meaningful for the tracked set. Columns
5+
are aliased to the snake_case Postgres column names so the JDBC sink maps field -> column 1:1.
6+
Runs daily after `ossPackages_enriched.pipe` (the 02:30 UTC enrichment COPY) has refreshed
7+
`ossPackages_enriched_ds`.
8+
9+
NODE ossPackages_enriched_sink_select
10+
SQL >
11+
SELECT
12+
purl,
13+
lifecycleLabel AS lifecycle_label,
14+
healthScore AS health_score,
15+
healthLabel AS health_label,
16+
maintainerHealthScore AS maintainer_health_score,
17+
securitySupplyChainScore AS security_supply_chain_score,
18+
developmentActivityScore AS development_activity_score,
19+
signalCoverageHealth AS signal_coverage_health
20+
FROM ossPackages_enriched_ds
21+
WHERE isCritical = 1
22+
23+
TYPE SINK
24+
EXPORT_SERVICE kafka
25+
EXPORT_CONNECTION_NAME lfx-oracle-kafka-streaming
26+
EXPORT_SCHEDULE 0 4 * * *
27+
EXPORT_FORMAT json
28+
EXPORT_STRATEGY @new
29+
EXPORT_KAFKA_TOPIC ossPackages_enriched_sink

0 commit comments

Comments
 (0)