@@ -225,6 +225,45 @@ export async function assignSteward(
225225 } )
226226}
227227
228+ export interface StewardshipSummary {
229+ stewards : StewardshipStewardRecord [ ]
230+ lastActivityAt : string | null
231+ }
232+
233+ export async function getStewardshipSummary (
234+ qx : QueryExecutor ,
235+ stewardshipId : string ,
236+ ) : Promise < StewardshipSummary > {
237+ const [ stewards , activityRow ] = await Promise . all ( [
238+ qx . select (
239+ `SELECT id, stewardship_id, user_id, role, assigned_at, assigned_by
240+ FROM stewardship_stewards
241+ WHERE stewardship_id = $(stewardshipId)
242+ AND deleted_at IS NULL
243+ ORDER BY assigned_at ASC` ,
244+ { stewardshipId } ,
245+ ) as Promise < Array < Record < string , unknown > > > ,
246+ qx . selectOneOrNone (
247+ `SELECT MAX(created_at) AS last_activity_at
248+ FROM stewardship_activity
249+ WHERE stewardship_id = $(stewardshipId)` ,
250+ { stewardshipId } ,
251+ ) as Promise < Record < string , unknown > | null > ,
252+ ] )
253+
254+ return {
255+ stewards : stewards . map ( ( s ) => ( {
256+ id : String ( s . id ) ,
257+ stewardshipId : String ( s . stewardship_id ) ,
258+ userId : String ( s . user_id ) ,
259+ role : String ( s . role ) ,
260+ assignedAt : toIso ( s . assigned_at ) ,
261+ assignedBy : s . assigned_by ? String ( s . assigned_by ) : null ,
262+ } ) ) ,
263+ lastActivityAt : activityRow ?. last_activity_at ? toIso ( activityRow . last_activity_at ) : null ,
264+ }
265+ }
266+
228267export const ESCALATION_RESOLUTION_PATHS = [
229268 'lf_staff_review' ,
230269 'community_outreach' ,
0 commit comments