|
|
|
@ -11,27 +11,22 @@ const EXECS_PATH = path.join("content", "team", "execs"); |
|
|
|
|
const fileType = ".md"; |
|
|
|
|
const { year, term } = getCurrentTerm(); |
|
|
|
|
|
|
|
|
|
const execPositions: { [name: string]: number } = { |
|
|
|
|
president: 1, |
|
|
|
|
"vice-president": 2, |
|
|
|
|
secretary: 3, |
|
|
|
|
treasurer: 4, |
|
|
|
|
sysadmin: 5, |
|
|
|
|
const execPositions: { [name: string]: string } = { |
|
|
|
|
president: "President", |
|
|
|
|
"vice-president": "Vice President", |
|
|
|
|
secretary: "Assistant Vice President", |
|
|
|
|
treasurer: "Treasurer", |
|
|
|
|
sysadmin: "System Administrator", |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const positionNames: string[] = [ |
|
|
|
|
"President", |
|
|
|
|
"Vice President", |
|
|
|
|
"Assistant Vice President", |
|
|
|
|
"Treasurer", |
|
|
|
|
"System Administrator", |
|
|
|
|
"president", |
|
|
|
|
"vice-president", |
|
|
|
|
"secretary", |
|
|
|
|
"treasurer", |
|
|
|
|
"sysadmin", |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
export interface ExecMembers { |
|
|
|
|
name: string; |
|
|
|
|
position: string; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export interface Metadata { |
|
|
|
|
name: string; |
|
|
|
|
role: string; |
|
|
|
@ -49,7 +44,8 @@ export async function getExecNames() { |
|
|
|
|
const searchDN = "ou=People,dc=csclub,dc=uwaterloo,dc=ca"; |
|
|
|
|
const client = new Client({ url }); |
|
|
|
|
|
|
|
|
|
let execMembers: ExecMembers[] = []; |
|
|
|
|
// position: name
|
|
|
|
|
let execMembers: { [name: string]: string }; |
|
|
|
|
let formattedExec: string[]; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
@ -62,29 +58,24 @@ export async function getExecNames() { |
|
|
|
|
)}${year}))`,
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
execMembers = searchEntries |
|
|
|
|
.map((item) => { |
|
|
|
|
return { |
|
|
|
|
name: item.cn as string, |
|
|
|
|
position: |
|
|
|
|
item.position === undefined |
|
|
|
|
? "" |
|
|
|
|
: typeof item.position === "string" |
|
|
|
|
? item.position |
|
|
|
|
: (item.position[0] as string), |
|
|
|
|
}; |
|
|
|
|
}) |
|
|
|
|
.filter((item: ExecMembers) => item.position !== ""); |
|
|
|
|
|
|
|
|
|
execMembers = execMembers.sort((item1: ExecMembers, item2: ExecMembers) => { |
|
|
|
|
return execPositions[item1.position] - execPositions[item2.position]; |
|
|
|
|
// item.position might be an array if the member has more than one position
|
|
|
|
|
searchEntries.forEach((item) => { |
|
|
|
|
if (typeof item.position === "string" && item.position in execPositions) { |
|
|
|
|
execMembers[item.position] = item.cn as string; |
|
|
|
|
} else if (typeof item.position === "object") { |
|
|
|
|
item.position.forEach((p) => { |
|
|
|
|
if ((p as string) in execPositions) { |
|
|
|
|
execMembers[p as string] = item.cn as string; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
formattedExec = execMembers.map( |
|
|
|
|
(member) => |
|
|
|
|
`0${execPositions[member.position]}-${member.name |
|
|
|
|
formattedExec = positionNames.map( |
|
|
|
|
(position, i) => |
|
|
|
|
`0${i + 1}-${execMembers[position] |
|
|
|
|
.split(" ")[0] |
|
|
|
|
.toLowerCase()}-${member.name.split(" ")[1].toLowerCase()}` |
|
|
|
|
.toLowerCase()}-${execMembers[position].split(" ")[1].toLowerCase()}` |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
formattedExec = [...formattedExec, "06-codey"]; |
|
|
|
@ -117,12 +108,12 @@ export async function getExec(fileName: string, convert = true) { |
|
|
|
|
fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1); |
|
|
|
|
|
|
|
|
|
const posOrder = fileName.split("-")[0][1]; |
|
|
|
|
const posName = positionNames[Number(posOrder) - 1]; |
|
|
|
|
const posName = execPositions[positionNames[Number(posOrder) - 1]]; |
|
|
|
|
({ content, metadata } = { |
|
|
|
|
content: "Coming soon!", |
|
|
|
|
metadata: { |
|
|
|
|
name: `${firstName} ${lastName}`, |
|
|
|
|
role: `${posName} ${Number(posOrder) - 1}`, |
|
|
|
|
role: `${posName}`, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|