Skip to content

Commit

Permalink
feat: add teams transparency endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp committed Jan 7, 2025
1 parent fe405f2 commit 52c9fff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/clients/Transparency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export type TransparencyBudget = {
category_percentages: Record<string, number>
}

export type TransparencyTeams = {
committees: Committee[]
}

const EMPTY_API: TransparencyData = {
balances: [],
income: {
Expand Down Expand Up @@ -93,4 +97,16 @@ export class Transparency {
return []
}
}

static async getTeams() {
try {
const response = (await (await fetch(`${API_URL}/teams.json`)).json()) as TransparencyTeams
return response
} catch (error) {
ErrorClient.report('Failed to fetch transparency data', { error, category: ErrorCategory.Transparency })
return {
committees: [],
}
}
}
}
2 changes: 1 addition & 1 deletion src/entities/Committee/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Committee, CommitteeName, 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)
}

Expand Down

0 comments on commit 52c9fff

Please sign in to comment.