test sort function
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
615a8ddbf9
commit
3506b6d00c
|
@ -8,6 +8,14 @@ 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;
|
||||
|
@ -36,7 +44,10 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
|
|||
program: item.position === undefined ? "" : (item.position as string),
|
||||
};
|
||||
})
|
||||
.filter((item: Member) => item.program !== "");
|
||||
.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)
|
||||
// );
|
||||
|
|
|
@ -68,10 +68,10 @@ export async function getExecNames() {
|
|||
return {
|
||||
name: item.cn as string,
|
||||
position:
|
||||
item.position === undefined ? "none" : (item.position as string),
|
||||
item.position === undefined ? "" : (item.position as string),
|
||||
};
|
||||
})
|
||||
.filter((item: execMembers) => item.position in execPositions)
|
||||
.filter((item: execMembers) => item.position !== "")
|
||||
.sort((item1: execMembers, item2: execMembers) => {
|
||||
return execPositions[item1.position] - execPositions[item2.position];
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue