Skip to content

Commit

Permalink
feat: update committees endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp committed Jan 7, 2025
1 parent 9be9838 commit 0d4bef9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/clients/Transparency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ const EMPTY_API: TransparencyData = {
committees: [],
}

const EMPTY_TEAMS: TransparencyTeams = {
committees: [],
}

export type TransparencyTeams = {
committees: Committee[]
}

export class Transparency {
static async getData() {
try {
Expand Down Expand Up @@ -117,4 +125,14 @@ export class Transparency {
return []
}
}

static async getTeams() {
try {
const response = (await (await fetch(`${TRANSPARENCY_API}/teams.json`)).json()) as TransparencyTeams
return response
} catch (error) {
ErrorClient.report('Failed to fetch transparency data', { error, category: ErrorCategory.Transparency })
return EMPTY_TEAMS
}
}
}
2 changes: 1 addition & 1 deletion src/utils/committee.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Committee, Transparency } from '../clients/Transparency'

export async function getCommitteesWithOpenSlots(): Promise<Committee[]> {
const { committees } = await Transparency.getData()
const { committees } = await Transparency.getTeams()
return committees.filter((committee) => committee.size > committee.members.length)
}

0 comments on commit 0d4bef9

Please sign in to comment.