Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing cabin sorting #148

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ui/lib/answer.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
question0,question1,question2,question3,question4,question5,question6,question7
answer1,answer1,answer1,answer1,answer1,answer1,answer1,answer1
answer2,answer2,answer2,answer2,answer2,answer2,answer2,answer2
answer3,answer3,answer3,answer3,answer3,answer3,answer3,answer3
answer4,answer4,answer4,answer4,answer4,answer4,answer4,answer4
answer5,answer5,answer5,answer5,answer5,answer5,answer5,answer5
answer6,answer6,answer6,answer6,answer6,answer6,answer6,answer6
question0,question1,question2,question3,question4,question5,question6,question7,question8
"Listening to what everyone has to say!","Water purifying water bottle","Use the strength of an empire to make this nation feel hopeless","Be well-liked. You want people to trust your judgment, and have as many friends as possible.","Ask upperclassmen for for tips and tricks","Find your RA’s Discord and call them immediately","Gardening!","I don’t have social media!","Do other class’s homework"
"Leading the conversation and planning another hangout","You already have an emergency backpack packed","Send someone to marry the heir to their throne to take over from the within","Be a ruler. You like it when people go to you for advice, when people look to you as their leader. You like to assign tasks, rather than do them.","Start a study group that meets daily","First tell all of your friends also stuck in the elevator to calm down and not panic and ask everyone to brainstorm a solution","Speech and Debate!","Instagram","always asking questions, when you’re not asking questions you’re talking to your friends"
"Thinking about what book you’re going to read when you get home","Survival for Dummies","Take the time to learn about the history of this nation and research its weaknesses to exploit them.","Be wise. Knowledge is your source of happiness. Nothing pleases you more but seeing your own intellectual growth.","Drill pass exams questions","Try to debug the elevator yourself","University Book Club!","Pinterest","Active listening and reflecting and making connections"
"Talking everyone’s ear off about your latest rock climbing experience","GoPro! Gotta vlog the journey","Stage a surprise attack on a sacred holiday of this nation.","Be a risk-taker. Exploring new things and taking on the challenges that others quiver from gives you unprecedented dopamine. You believe only great risks can there be great success","Trick your professor into giving you the topics and types of questions on the exam","Try to kick the door open","Outdoor Adventure Club!","Tiktok","Haha you’re kidding I won’t be in class"
"On a discord channel","Laptop. We’ll figure out the wifi later","Launch a cyber attack to nullify all communications inside and out.","Be remembered. You see leaving your mark on the world as the meaning in life. You want to leave a lasting impression on the world through the work you do!","Go to online office hours and ask for rundowns of potential topics","Pretend it didn’t happen and continue to game","Online Gaming Club!","Twitch","Game with mechanical keyboard"
2 changes: 1 addition & 1 deletion ui/lib/cabinTypes.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cabin0,cabin1,cabin2,cabin3,cabin4
Finding Nemo,Sharknado,Northern Water Tribe,Bikini Bottom,Minecraft Ocean Monument
4 changes: 2 additions & 2 deletions ui/lib/questionNameMapping.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hangingWithFriends,zombieApocalypse,takeOverNation,aspirations,study,stuckInElevator,socialMedia,duringClass
question0,question1,question2,question3,question4,question5,question6,question7
hangingWithFriends,zombieApocalypse,takeOverNation,aspirations,study,stuckInElevator,club,socialMedia,duringClass
question0,question1,question2,question3,question4,question5,question6,question7,question8
69 changes: 37 additions & 32 deletions ui/lib/service/SortedHackerApplicationDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,32 @@ let answerList: any[]
let cabinList: any[]
let questionNameMapping: { [key: string]: string }
const CABIN_SIZE = 5
const QUESTIONS_SIZE = 8

const getAllHackersWithAssignedCabins = async (): Promise<
SortedHackersReturnType
> => {
await fetch('http://localhost:3000/api/cabinSorting/answerList')
.then((response) => response.json())
.then((data) => {
answerList = data.content
})

await fetch('http://localhost:3000/api/cabinSorting/cabinList')
.then((response) => response.json())
.then((data) => {
cabinList = data.content[0]
})

await fetch('http://localhost:3000/api/cabinSorting/questionNameMapping')
.then((response) => response.json())
.then((data) => {
questionNameMapping = data
})

const rawHackerData = await HackerApplicationDataDao.find()
const formattedHackerData = formatRawData(rawHackerData)
return matchAnswers(formattedHackerData)
}
const QUESTIONS_SIZE = 9

const getAllHackersWithAssignedCabins =
async (): Promise<SortedHackersReturnType> => {
await fetch('http://localhost:3000/api/cabinSorting/answerList')
.then((response) => response.json())
.then((data) => {
answerList = data.content
})

await fetch('http://localhost:3000/api/cabinSorting/cabinList')
.then((response) => response.json())
.then((data) => {
cabinList = data.content[0]
})

await fetch('http://localhost:3000/api/cabinSorting/questionNameMapping')
.then((response) => response.json())
.then((data) => {
questionNameMapping = data
})

const rawHackerData = await HackerApplicationDataDao.find()
const formattedHackerData = formatRawData(rawHackerData)
return matchAnswers(formattedHackerData)
}

const pingServer = async (): Promise<void> => {
for (let i = 1; i <= 3; i++) {
Expand Down Expand Up @@ -80,7 +79,12 @@ function formatRawData (
rawHackerData: HackerApplicationDataType[]
): FormattedHackerDataType[] {
return rawHackerData
.filter((hackerData) => !!hackerData.postAcceptanceResponses)
.filter(
(hackerData) =>
hackerData.decisionStatus === 'Admitted' &&
hackerData.rsvpStatus === 'Confirmed' &&
!!hackerData.postAcceptanceResponses
)
.map((hackerData) => {
const { email, postAcceptanceResponses } = hackerData

Expand Down Expand Up @@ -156,16 +160,17 @@ function hydrateCabinScore (
hacker: FormattedHackerWithCabinsDataType,
cabinScore: number[]
) {
answerList.forEach((cabin: any, cabinIndex: number) => {
// skip first row of answerList because of question name
if (cabinIndex === 0) return
// skip first row of answerList because of question name
answerList.slice(1).forEach((cabin: any, cabinIndex: number) => {
console.log(cabin, cabinIndex)
for (
let questionIndex = 0;
questionIndex < QUESTIONS_SIZE;
questionIndex++
) {
if (
cabin[questionIndex] === hacker['question' + questionIndex.toString()]
cabin[questionIndex].trim() ===
hacker['question' + questionIndex.toString()].trim()
) {
cabinScore[cabinIndex]++
}
Expand Down
2 changes: 1 addition & 1 deletion ui/models/HackerApplicationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const HackerApplicationDataSchema =
}
},
{
collection: 'hacker_applications',
collection: 'applicant_data',
versionKey: false
}
)
Expand Down
10 changes: 5 additions & 5 deletions ui/pages/cabinSorting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default function CabinSorting ({
cabinData
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
const cabinHeaders: string[] = [
'Cabin 0',
'Cabin 1',
'Cabin 2',
'Cabin 3',
'Cabin 4'
'Finding Nemo',
'Sharknado',
'Northern Water Tribe',
'Bikini Bottom',
'Minecraft Ocean Monument'
]

const cabinValues: string[][] = []
Expand Down