eliminate position name to keep in sync
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
51bb491277
commit
4c087b4af4
46
lib/team.ts
46
lib/team.ts
|
@ -33,11 +33,9 @@ export interface Metadata {
|
||||||
image: string;
|
image: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getExecNames() {
|
export async function getExecNamePosPairs() {
|
||||||
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
|
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
|
||||||
return (await readdir(EXECS_PATH))
|
return [["codey", "mascot"]];
|
||||||
.filter((name) => name.endsWith(fileType))
|
|
||||||
.map((name) => name.slice(0, -1 * fileType.length));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = "ldap://ldap1.csclub.uwaterloo.ca";
|
const url = "ldap://ldap1.csclub.uwaterloo.ca";
|
||||||
|
@ -46,7 +44,7 @@ export async function getExecNames() {
|
||||||
|
|
||||||
// position: name
|
// position: name
|
||||||
const execMembers: { [name: string]: string } = {};
|
const execMembers: { [name: string]: string } = {};
|
||||||
let formattedExec: string[] = [];
|
let formattedExec: [string, string][] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.bind("", "");
|
await client.bind("", "");
|
||||||
|
@ -62,7 +60,7 @@ export async function getExecNames() {
|
||||||
searchEntries.forEach((item) => {
|
searchEntries.forEach((item) => {
|
||||||
if (typeof item.position === "string" && item.position in execPositions) {
|
if (typeof item.position === "string" && item.position in execPositions) {
|
||||||
execMembers[item.position] = item.cn as string;
|
execMembers[item.position] = item.cn as string;
|
||||||
} else if (typeof item.position === "object") {
|
} else if (item.position instanceof Array) {
|
||||||
item.position.forEach((p) => {
|
item.position.forEach((p) => {
|
||||||
if ((p as string) in execPositions) {
|
if ((p as string) in execPositions) {
|
||||||
execMembers[p as string] = item.cn as string;
|
execMembers[p as string] = item.cn as string;
|
||||||
|
@ -71,14 +69,18 @@ export async function getExecNames() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
formattedExec = positionNames.map(
|
formattedExec = positionNames.map((position) => {
|
||||||
(position, i) =>
|
return [
|
||||||
`0${i + 1}-${execMembers[position]
|
`${execMembers[position].split(" ")[0].toLowerCase()}-${execMembers[
|
||||||
.split(" ")[0]
|
position
|
||||||
.toLowerCase()}-${execMembers[position].split(" ")[1].toLowerCase()}`
|
]
|
||||||
);
|
.split(" ")[1]
|
||||||
|
.toLowerCase()}`,
|
||||||
|
position,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
formattedExec = [...formattedExec, "06-codey"];
|
formattedExec = [...formattedExec, ["codey", "mascot"]];
|
||||||
} finally {
|
} finally {
|
||||||
await client.unbind();
|
await client.unbind();
|
||||||
}
|
}
|
||||||
|
@ -86,11 +88,16 @@ export async function getExecNames() {
|
||||||
return formattedExec;
|
return formattedExec;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getExec(fileName: string, convert = true) {
|
export async function getExec(
|
||||||
|
execNamePosPair: [string, string],
|
||||||
|
convert = true
|
||||||
|
) {
|
||||||
let content, metadata;
|
let content, metadata;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`));
|
const raw = await readFile(
|
||||||
|
path.join(EXECS_PATH, `${execNamePosPair[0]}${fileType}`)
|
||||||
|
);
|
||||||
({ content, data: metadata } = matter(raw));
|
({ content, data: metadata } = matter(raw));
|
||||||
|
|
||||||
const image =
|
const image =
|
||||||
|
@ -103,12 +110,13 @@ export async function getExec(fileName: string, convert = true) {
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const firstName =
|
const firstName =
|
||||||
fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1);
|
execNamePosPair[0].split("-")[0][0].toUpperCase() +
|
||||||
|
execNamePosPair[0].split("-")[0].slice(1);
|
||||||
const lastName =
|
const lastName =
|
||||||
fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1);
|
execNamePosPair[0].split("-")[1][0].toUpperCase() +
|
||||||
|
execNamePosPair[0].split("-")[1].slice(1);
|
||||||
|
|
||||||
const posOrder = fileName.split("-")[0][1];
|
const posName = execPositions[execNamePosPair[1]];
|
||||||
const posName = execPositions[positionNames[Number(posOrder) - 1]];
|
|
||||||
({ content, metadata } = {
|
({ content, metadata } = {
|
||||||
content: "Coming soon!",
|
content: "Coming soon!",
|
||||||
metadata: {
|
metadata: {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { TeamMemberCard } from "@/components/TeamMemberCard";
|
||||||
import { Title } from "@/components/Title";
|
import { Title } from "@/components/Title";
|
||||||
import {
|
import {
|
||||||
getExec,
|
getExec,
|
||||||
getExecNames,
|
getExecNamePosPairs,
|
||||||
Metadata,
|
Metadata,
|
||||||
getMemberImagePath,
|
getMemberImagePath,
|
||||||
} from "@/lib/team";
|
} from "@/lib/team";
|
||||||
|
@ -140,10 +140,10 @@ async function getTeamWithImages(team: TeamMember[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps<Props> = async () => {
|
export const getStaticProps: GetStaticProps<Props> = async () => {
|
||||||
const execNames = await getExecNames();
|
const execNamePosPairs = await getExecNamePosPairs();
|
||||||
|
|
||||||
const execs = (await Promise.all(
|
const execs = (await Promise.all(
|
||||||
execNames.map((name) => getExec(name))
|
execNamePosPairs.map((namePosPair) => getExec(namePosPair))
|
||||||
)) as SerializedExec[];
|
)) as SerializedExec[];
|
||||||
|
|
||||||
const [programme, website, systems, terminal] = await Promise.all([
|
const [programme, website, systems, terminal] = await Promise.all([
|
||||||
|
|
Loading…
Reference in New Issue