test president

pull/403/head
Rebecca-Chou 9 months ago
parent ca1a9f3185
commit bb743f4ca6
  1. 36
      lib/members.ts
  2. 12
      lib/team.ts

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

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

Loading…
Cancel
Save