test president
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Rebecca-Chou 2022-02-16 23:31:14 +08:00
parent ca1a9f3185
commit bb743f4ca6
2 changed files with 33 additions and 15 deletions

View File

@ -8,9 +8,19 @@ export interface Member {
program: string; 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[]> { export async function getMembers(year: string, term: Term): Promise<Member[]> {
if (process.env.USE_LDAP?.toLowerCase() !== "true") { if (process.env.USE_LDAP?.toLowerCase() !== "true") {
return dummyMembers; return dummyMembers.sort((item1: Member, item2: Member) => {
return execPositions[item1.program] - execPositions[item2.program];
});
} }
let members: Member[] = []; let members: Member[] = [];
@ -26,6 +36,7 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
0, 0,
1 1
)}${year}))`, )}${year}))`,
explicitBufferAttributes: ["position"],
}); });
members = searchEntries members = searchEntries
@ -33,12 +44,14 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
return { return {
name: item.cn as string, name: item.cn as string,
id: item.uid as string, id: item.uid as string,
program: item.program === undefined ? "" : (item.program as string), program:
item.position === undefined ? "" : (item.position[0] as string),
}; };
}) })
.sort((item1: Member, item2: Member) => .filter((item: Member) => item.program !== "");
item1.name.localeCompare(item2.name) // .sort((item1: Member, item2: Member) => {
); // return execPositions[item1.program] - execPositions[item2.program];
// });
} finally { } finally {
await client.unbind(); await client.unbind();
} }
@ -48,13 +61,18 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
const dummyMembers: Member[] = [ const dummyMembers: Member[] = [
{ {
name: "John Smith", name: "Alice ",
id: "j12smith", id: "a12smith",
program: "MAT/Mathematics Computer Science", program: "sysadmin",
}, },
{ {
name: "Jane Smith", name: "Jane Smith",
id: "j34smith", id: "j34smith",
program: "MAT/Mathematics Computer Science", program: "vice-president",
},
{
name: "John Smith",
id: "j12smith",
program: "presidentcro",
}, },
]; ];

View File

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { readFile, readdir, access } from "fs/promises"; import { readFile, readdir, access } from "fs/promises";
import path from "path"; import path from "path";
@ -28,7 +27,7 @@ const positionNames: string[] = [
"System Administrator", "System Administrator",
]; ];
export interface execMembers { export interface ExecMembers {
name: string; name: string;
position: string; position: string;
} }
@ -50,7 +49,7 @@ export async function getExecNames() {
const searchDN = "ou=People,dc=csclub,dc=uwaterloo,dc=ca"; const searchDN = "ou=People,dc=csclub,dc=uwaterloo,dc=ca";
const client = new Client({ url }); const client = new Client({ url });
let execMembers: execMembers[] = []; let execMembers: ExecMembers[] = [];
let formattedExec: string[]; let formattedExec: string[];
try { try {
@ -61,6 +60,7 @@ export async function getExecNames() {
0, 0,
1 1
)}${year}))`, )}${year}))`,
explicitBufferAttributes: ["position"],
}); });
execMembers = searchEntries execMembers = searchEntries
@ -68,12 +68,12 @@ export async function getExecNames() {
return { return {
name: item.cn as string, name: item.cn as string,
position: position:
item.position === undefined ? "" : (item.position as string), item.position === undefined ? "" : (item.position[0] as string),
}; };
}) })
.filter((item: execMembers) => item.position !== ""); .filter((item: ExecMembers) => item.position !== "");
execMembers = execMembers.sort((item1: execMembers, item2: execMembers) => { execMembers = execMembers.sort((item1: ExecMembers, item2: ExecMembers) => {
return execPositions[item1.position] - execPositions[item2.position]; return execPositions[item1.position] - execPositions[item2.position];
}); });