Skip to content

Commit 31773a4

Browse files
committed
fix: adding steward details
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent e9e1a4a commit 31773a4

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { QueryExecutor } from '../queryExecutor'
22

3+
import { STEWARD_DISPLAY_NAME_METADATA, STEWARD_MENTIONED_JOIN } from './stewardships'
4+
35
export interface PackageMetrics {
46
totalPackages: number
57
criticalPackages: number
@@ -512,8 +514,10 @@ export async function listPackagesForApi(
512514
opts.includeLastActivity === true
513515
? `
514516
LEFT JOIN LATERAL (
515-
SELECT sa.activity_type, sa.content, sa.metadata, sa.created_at
517+
SELECT sa.activity_type, sa.content, sa.created_at,
518+
${STEWARD_DISPLAY_NAME_METADATA} AS metadata
516519
FROM stewardship_activity sa
520+
${STEWARD_MENTIONED_JOIN}
517521
WHERE sa.stewardship_id = s.id
518522
ORDER BY sa.created_at DESC
519523
LIMIT 1

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ export interface ActivityFeedRow {
351351
total: string
352352
}
353353

354-
const STEWARD_MENTIONED_JOIN = `
354+
export const STEWARD_MENTIONED_JOIN = `
355355
LEFT JOIN stewards st_mentioned
356356
ON sa.activity_type = 'steward_added'
357357
AND st_mentioned.user_id = (sa.metadata->>'userId')`
358358

359-
const STEWARD_DISPLAY_NAME_METADATA = `CASE
359+
export const STEWARD_DISPLAY_NAME_METADATA = `CASE
360360
WHEN sa.activity_type = 'steward_added' AND st_mentioned.display_name IS NOT NULL
361361
THEN COALESCE(sa.metadata, '{}'::jsonb) || jsonb_build_object('stewardDisplayName', st_mentioned.display_name)
362362
ELSE sa.metadata
@@ -607,8 +607,10 @@ export async function listMyPackages(
607607

608608
const displayLaterals = `
609609
LEFT JOIN LATERAL (
610-
SELECT sa.content, sa.activity_type, sa.metadata, sa.created_at
610+
SELECT sa.content, sa.activity_type, sa.created_at,
611+
${STEWARD_DISPLAY_NAME_METADATA} AS metadata
611612
FROM stewardship_activity sa
613+
${STEWARD_MENTIONED_JOIN}
612614
WHERE sa.stewardship_id = s.id
613615
ORDER BY sa.created_at DESC
614616
LIMIT 1

0 commit comments

Comments
 (0)