debug sort function

pull/403/head
Rebecca-Chou 10 months ago
parent 3506b6d00c
commit ca1a9f3185
  1. 20
      lib/members.ts
  2. 11
      lib/team.ts

@ -8,14 +8,6 @@ export interface Member {
program: string;
}
const execPositions: { [name: string]: number } = {
presidentcro: 1,
"vice-president": 2,
secretary: 3,
treasurer: 4,
sysadmin: 5,
};
export async function getMembers(year: string, term: Term): Promise<Member[]> {
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
return dummyMembers;
@ -41,16 +33,12 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
return {
name: item.cn as string,
id: item.uid as string,
program: item.position === undefined ? "" : (item.position as string),
program: item.program === undefined ? "" : (item.program as string),
};
})
.filter((item: Member) => item.program !== "")
.sort((item1: Member, item2: Member) => {
return execPositions[item1.program] - execPositions[item2.program];
});
// .sort((item1: Member, item2: Member) =>
// item1.name.localeCompare(item2.name)
// );
.sort((item1: Member, item2: Member) =>
item1.name.localeCompare(item2.name)
);
} finally {
await client.unbind();
}

@ -71,10 +71,11 @@ export async function getExecNames() {
item.position === undefined ? "" : (item.position as string),
};
})
.filter((item: execMembers) => item.position !== "")
.sort((item1: execMembers, item2: execMembers) => {
return execPositions[item1.position] - execPositions[item2.position];
});
.filter((item: execMembers) => item.position !== "");
execMembers = execMembers.sort((item1: execMembers, item2: execMembers) => {
return execPositions[item1.position] - execPositions[item2.position];
});
formattedExec = execMembers.map(
(member) =>
@ -118,7 +119,7 @@ export async function getExec(fileName: string, convert = true) {
content: "Coming soon!",
metadata: {
name: `${firstName} ${lastName}`,
role: `${posName}`,
role: `${posName} ${Number(posOrder) - 1}`,
},
});

Loading…
Cancel
Save