Skip to content

Commit 1df1336

Browse files
authored
make check for exclude teams case insensitive by storing as lower case and comparing to lower case (#29)
* new setting added EXCLUDE_TEAMS to AppConfig, added note in README * add check for ExcludeTeams and ignore processing of team if in the array * make check for exclude teams case insensitive by storing as lower case and comparing to lower case
1 parent 3514a8a commit 1df1336

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ GITHUB_API_VERSION=2022-11-28
105105
# valid values are day, week, month, quarter, or year
106106
TIME_PERIOD=month
107107

108+
# any teams to exclude from the results (comma separated list)
109+
EXCLUDE_TEAMS=team1,team2
110+
108111
# pretty, json, hidden
109112
LOG_TYPE=pretty
110113

src/data/copilot-associations-data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { listCopilotSeats } from "../restapi/copilot";
22
import { getAuditLogForActor } from "../restapi/organizations";
33
import { listRepoContributors } from "../restapi/repositories";
44
import { listTeamMembers, listTeams } from "../restapi/teams";
5+
import { AppConfig } from "../shared/app-config";
56
import logger from "../shared/app-logger";
67
import { CopilotSeatAssignee, Repository, TeamInfo, TimePeriodType } from "../shared/shared-types";
78
import { timestampToDate } from "../shared/time-util";
@@ -123,6 +124,10 @@ async function processRepositories(repository_owner_name: string, seat_assignee:
123124
async function fetchOrgTeamsMembers(org: string, per_page: number, teams: { [team: string]: TeamInfo }, org_copilot_seats: CopilotSeatAssignee[]) {
124125
let team_count: number = 0;
125126
for await (const team of listTeams({ org, per_page })) {
127+
if (AppConfig.EXCLUDE_TEAMS.includes(team.slug.toLowerCase())) {
128+
continue;
129+
}
130+
126131
processTeams(org, team.slug, per_page, teams, org_copilot_seats);
127132
team_count++;
128133
}

src/report/copilot-associations-report.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ function getTeamAssociations(data: CopilotAssociationsData): { member: string, t
109109
const member_teams: { [member: string]: Set<string> } = {};
110110

111111
for (const team_name in data.teams) {
112+
if(AppConfig.EXCLUDE_TEAMS.includes(team_name.toLowerCase())) {
113+
continue;
114+
}
115+
112116
const team = data.teams[team_name];
113117
const copilot_users = new Set(team.copilot_users);
114118

src/shared/app-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export class AppConfig {
1212
public static readonly GENERATE_DATA: boolean = AppConfig.getEnvVar("GENERATE_DATA", "true").toLowerCase() === "true";
1313
public static readonly GITHUB_TOKENS_BY_ORG: { [key: string]: string } = AppConfig.getTokensByOrg(AppConfig.getEnvVar("GITHUB_TOKENS_BY_ORG"));
1414
public static readonly PER_PAGE: number = parseInt(AppConfig.getEnvVar("PER_PAGE", "100"));
15+
public static readonly EXCLUDE_TEAMS: string[] = AppConfig.getEnvVar("EXCLUDE_TEAMS", "")
16+
.split(",")
17+
.map((team) => team.trim().toLowerCase())
18+
.filter((team) => team !== "");
1519

1620
// logging settings
1721
public static readonly MIN_LOG_LEVEL: number = parseInt(AppConfig.getEnvVar("MIN_LOG_LEVEL", "3"));

0 commit comments

Comments
 (0)