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 1 commit
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
Next Next commit
fixing cabin sorting
  • Loading branch information
NelsonDong41 committed Feb 22, 2024
commit 48573b69bc88d4a35a66b15f11ef340dbfc26052
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
20 changes: 12 additions & 8 deletions ui/lib/service/SortedHackerApplicationDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let answerList: any[]
let cabinList: any[]
let questionNameMapping: { [key: string]: string }
const CABIN_SIZE = 5
const QUESTIONS_SIZE = 8
const QUESTIONS_SIZE = 9

const getAllHackersWithAssignedCabins = async (): Promise<
SortedHackersReturnType
Expand Down Expand Up @@ -80,7 +80,7 @@ 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 @@ -130,7 +130,12 @@ function matchAnswers (
const cabinScore = Array<number>(CABIN_SIZE).fill(0)

hydrateCabinScore(hackerWithCabins, cabinScore)

console.log(cabinScore)
let sum = 0
cabinScore.forEach(score => sum += score)
if (sum != QUESTIONS_SIZE) {
console.log(hacker)
}
// create extra column for hacker that determines the cabin they should
// join (the one with the most points)
const maxIndex: number = cabinScore.indexOf(Math.max(...cabinScore))
Expand All @@ -156,17 +161,16 @@ 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, -1).forEach((cabin: any, cabinIndex: number) => {
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