Debug ldap data fetch function
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Rebecca-Chou 2022-02-13 23:48:30 +08:00
parent ae0b81c4cc
commit 3a7ec04f4e
1 changed files with 21 additions and 16 deletions

View File

@ -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)
);
.filter((item: execMembers) => item.position in execPositions)
.sort((item1: execMembers, item2: execMembers) => {
return (
execPositions[item1.position].order -
execPositions[item2.position].order
);
});
const formattedExec: string[] = execMembers.map(
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 =