Skip to content

Commit cf60c8f

Browse files
authored
fix: adding total count (#4231)
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 45554ae commit cf60c8f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • services/libs/data-access-layer/src/osspckgs

services/libs/data-access-layer/src/osspckgs/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export async function getPackagesByStewardshipPurls(
5151

5252
// TODO[deprecate]: rename to AkritesMetrics once /v1/ossprey is removed
5353
export interface OsspreyMetrics {
54+
totalPackages: number
5455
criticalPackages: number
5556
coveragePercent: number
5657
coverageTrend: number | null
@@ -64,6 +65,7 @@ export interface OsspreyMetrics {
6465
export async function getOsspreyMetrics(qx: QueryExecutor): Promise<OsspreyMetrics> {
6566
const [counts, stewardRow]: [
6667
{
68+
totalPackages: string
6769
criticalPackages: string
6870
covered: string
6971
needsAttention: string
@@ -74,6 +76,7 @@ export async function getOsspreyMetrics(qx: QueryExecutor): Promise<OsspreyMetri
7476
] = await Promise.all([
7577
qx.selectOne(`
7678
SELECT
79+
(SELECT reltuples::bigint::text FROM pg_class WHERE relname = 'packages') AS "totalPackages",
7780
COUNT(*)::text AS "criticalPackages",
7881
COUNT(*) FILTER (WHERE s.status IN ('assessing','active','needs_attention'))::text AS covered,
7982
COUNT(*) FILTER (WHERE s.status = 'needs_attention')::text AS "needsAttention",
@@ -96,6 +99,7 @@ export async function getOsspreyMetrics(qx: QueryExecutor): Promise<OsspreyMetri
9699
const covered = parseInt(counts.covered, 10)
97100

98101
return {
102+
totalPackages: parseInt(counts.totalPackages, 10),
99103
criticalPackages: total,
100104
coveragePercent: total > 0 ? Math.round((covered / total) * 1000) / 10 : 0,
101105
coverageTrend: null, // TODO: requires snapshot mechanism or stewardship_activity timestamp analysis

0 commit comments

Comments
 (0)