Debug ldap data fetch function

pull/403/head
Rebecca-Chou 10 months ago
parent ae0b81c4cc
commit 3a7ec04f4e
  1. 39
      lib/team.ts

@ -11,9 +11,17 @@ const EXECS_PATH = path.join("content", "team", "execs");
const fileType = ".md";
const { year, term } = getCurrentTerm();
const execPositions: { [name: string]: { order: number; name: string } } = {
president: { order: 1, name: "President" },
"vice-president": { order: 2, name: "Vice President" },
treasurer: { order: 3, name: "Treasurer" },
secretary: { order: 4, name: "Assistant Vice President" },
sysadmin: { order: 5, name: "System Administrator" },
};
export interface execMembers {
name: string;
order: string;
position: string;
}
export interface Metadata {
@ -34,6 +42,7 @@ export async function getExecNames() {
const client = new Client({ url });
let execMembers: execMembers[] = [];
let formattedExec: string[];
try {
await client.bind("", "");
@ -42,23 +51,27 @@ export async function getExecNames() {
filter: `(&(objectClass=member)(term=${(term as string).slice(
0,
1
)}${year})(exec=True))`,
)}${year})(position=*))`,
});
execMembers = searchEntries
.map((item) => {
return {
name: item.cn as string,
order: item.order as string,
position: item.position as string,
};
})
.sort((item1: execMembers, item2: execMembers) =>
item1.order.localeCompare(item2.order)
);
const formattedExec: string[] = execMembers.map(
.filter((item: execMembers) => item.position in execPositions)
.sort((item1: execMembers, item2: execMembers) => {
return (
execPositions[item1.position].order -
execPositions[item2.position].order
);
});
formattedExec = execMembers.map(
(member) =>
`0${member.order}-
`0${execPositions[member.position].order}-
${member.name.split(" ")[1].toLowerCase()}-
${member.name.split(" ")[0].toLowerCase()}`
);
@ -70,14 +83,6 @@ export async function getExecNames() {
}
export async function getExec(fileName: string, convert = true) {
// const posDict: { [name: string]: string } = {
// "01": "President",
// "02": "Vice President",
// "03": "Assistant Vice President",
// "04": "Treasurer",
// "05": "Systems Administrator",
// };
// const firstName =
// fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1);
// const lastName =

Loading…
Cancel
Save