-
Notifications
You must be signed in to change notification settings - Fork 0
Jan mongo button func #143
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
Open
NelsonDong41
wants to merge
8
commits into
main
Choose a base branch
from
JAN-MongoButtonFunc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e6fb85e
added endpoint for grouped hacker data
Mandy-cyber f5d6fc9
using Next getStaticProps to pass in environment variables
233cee1
Kept copy to clipboard button available at all times
e0829e8
removed dotenv for vercel deployment
e616d81
resolving comments from review!
Mandy-cyber 367a251
added id to destructuring
Mandy-cyber f1a48f9
adding return type to createSortedHacker
Mandy-cyber 3b24ee6
small changes from review
Mandy-cyber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 41 additions & 11 deletions
52
backend/cabin-sorting/controllers/sortedHackers-controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,47 @@ | ||
| import sortedHackersService from "../service/sortedHackers-service.js"; | ||
| import express, { Response, Request } from 'express'; | ||
|
|
||
|
|
||
| const getSortedHackers = async (_req: any, res: any) => { | ||
| const sortedHackers = await sortedHackersService.getSortedHackers(); | ||
| res.json(sortedHackers) | ||
| return sortedHackers; | ||
| const getSortedHackers = async (_req: Request, res: Response) => { | ||
| try { | ||
| const sortedHackers = await sortedHackersService.getSortedHackers(); | ||
| if (sortedHackers === null || Object.values(sortedHackers).length === 0) { | ||
| throw new Error("Sorted hackers were null/empty...") | ||
Mandy-cyber marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| res.json(sortedHackers) | ||
| return sortedHackers; | ||
| } catch (err) { | ||
| res.status(404).json({message: "Failed to get sorted hackers.", err}) | ||
Mandy-cyber marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return; | ||
| }; | ||
|
|
||
| const createSortedHacker = async (req: any, res: any) => { | ||
| const hackerInformation = req.body; | ||
| const createResponse = await sortedHackersService.createSortedHacker(hackerInformation) | ||
| res.json(createResponse) | ||
| return createResponse; | ||
| const createSortedHacker = async (req: Request, res: Response) => { | ||
| try { | ||
| const hackerInformation = req.body; | ||
| const createResponse = await sortedHackersService.createSortedHacker(hackerInformation) | ||
| if (createResponse === null || Object.values(createResponse).length === 0) { | ||
| throw new Error("Sorted hackers were null/empty...") | ||
| } | ||
| res.json(createResponse) | ||
| return createResponse; | ||
| } catch (err) { | ||
| res.status(404).json({message: "Failed to create sorted hackers.", err}) | ||
| } | ||
| return; | ||
| }; | ||
|
|
||
| export default {getSortedHackers, createSortedHacker}; | ||
| const groupHackersByCabin = async (_req: Request, res: Response) => { | ||
| try { | ||
| const groupedHackers = await sortedHackersService.groupHackersByCabin() | ||
| if (groupedHackers === null || Object.values(groupedHackers).length === 0) { | ||
| throw new Error("Grouped hackers were null/empty...") | ||
| } | ||
| res.json(groupedHackers) | ||
| return groupedHackers | ||
| } catch (err) { | ||
| res.status(404).json({message: "Failed to group hackers by cabin.", err}) | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| export default {getSortedHackers, createSortedHacker, groupHackersByCabin }; | ||
129 changes: 128 additions & 1 deletion
129
backend/cabin-sorting/data/json_outputs/sortedHackers.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,128 @@ | ||
| [{"question0":"answer1","question1":"answer1","question2":"answer1","question3":"answer1","question4":"answer1","question5":"answer1","question6":"answer1","question7":"answer1","question8":"answer1","question9":"answer1","question10":"answer1","question11":"answer1","id":"64accf3dd36486421bc50e53","email":"test","assignedCabin":"cabin1","secondAssignedCabin":" cabin2"},{"question0":"answer2","question1":"answer2","question2":"answer2","question3":"answer2","question4":"answer2","question5":"answer2","question6":"answer2","question7":"answer2","question8":"answer2","question9":"answer2","question10":"answer2","question11":"answer2","id":"64accf66d36486421bc50e55","email":"test2","assignedCabin":" cabin2","secondAssignedCabin":"cabin1"},{"question0":"answer3","question1":"answer3","question2":"answer3","question3":"answer3","question4":"answer3","question5":"answer3","question6":"answer3","question7":"answer3","question8":"answer3","question9":"answer3","question10":"answer3","question11":"answer3","id":"64accf7fd36486421bc50e57","email":"test3","assignedCabin":" cabin3","secondAssignedCabin":"cabin1"},{"question0":"answer4","question1":"answer4","question2":"answer4","question3":"answer4","question4":"answer4","question5":"answer4","question6":"answer4","question7":"answer4","question8":"answer4","question9":"answer4","question10":"answer4","question11":"answer4","id":"64accf8ed36486421bc50e59","email":"test4","assignedCabin":" cabin4","secondAssignedCabin":"cabin1"}] | ||
| [ | ||
| { | ||
| "id": "64accf3dd36486421bc50e53", | ||
| "email": "test", | ||
| "question0": "answer1", | ||
| "question1": "answer1", | ||
| "question2": "answer1", | ||
| "question3": "answer1", | ||
| "question4": "answer1", | ||
| "question5": "answer1", | ||
| "question6": "answer1", | ||
| "question7": "answer1", | ||
| "question8": "answer1", | ||
| "question9": "answer1", | ||
| "question10": "answer1", | ||
| "question11": "answer1", | ||
| "assignedCabin": "cabin1", | ||
| "secondAssignedCabin": "cabin2" | ||
| }, | ||
| { | ||
| "id": "64accf66d36486421bc50e55", | ||
| "email": "test2", | ||
| "question0": "answer2", | ||
| "question1": "answer2", | ||
| "question2": "answer2", | ||
| "question3": "answer2", | ||
| "question4": "answer2", | ||
| "question5": "answer2", | ||
| "question6": "answer2", | ||
| "question7": "answer2", | ||
| "question8": "answer2", | ||
| "question9": "answer2", | ||
| "question10": "answer2", | ||
| "question11": "answer2", | ||
| "assignedCabin": "cabin2", | ||
| "secondAssignedCabin": "cabin1" | ||
| }, | ||
| { | ||
| "id": "64accf7fd36486421bc50e57", | ||
| "email": "test3", | ||
| "question0": "answer3", | ||
| "question1": "answer3", | ||
| "question2": "answer3", | ||
| "question3": "answer3", | ||
| "question4": "answer3", | ||
| "question5": "answer3", | ||
| "question6": "answer3", | ||
| "question7": "answer3", | ||
| "question8": "answer3", | ||
| "question9": "answer3", | ||
| "question10": "answer3", | ||
| "question11": "answer3", | ||
| "assignedCabin": "cabin3", | ||
| "secondAssignedCabin": "cabin1" | ||
| }, | ||
| { | ||
| "id": "64accf8ed36486421bc50e59", | ||
| "email": "test4", | ||
| "question0": "answer4", | ||
| "question1": "answer4", | ||
| "question2": "answer4", | ||
| "question3": "answer4", | ||
| "question4": "answer4", | ||
| "question5": "answer4", | ||
| "question6": "answer4", | ||
| "question7": "answer4", | ||
| "question8": "answer4", | ||
| "question9": "answer4", | ||
| "question10": "answer4", | ||
| "question11": "answer4", | ||
| "assignedCabin": "cabin4", | ||
| "secondAssignedCabin": "cabin1" | ||
| }, | ||
| { | ||
| "id": "64ae0242cdcfed39b8b59958", | ||
| "email": "test4", | ||
| "question0": "answer4", | ||
| "question1": "answer4", | ||
| "question2": "answer4", | ||
| "question3": "answer4", | ||
| "question4": "answer4", | ||
| "question5": "answer4", | ||
| "question6": "answer4", | ||
| "question7": "answer4", | ||
| "question8": "answer4", | ||
| "question9": "answer4", | ||
| "question10": "answer4", | ||
| "question11": "answer4", | ||
| "assignedCabin": "cabin4", | ||
| "secondAssignedCabin": "cabin1" | ||
| }, | ||
| { | ||
| "id": "64ae024dcdcfed39b8b5995a", | ||
| "email": "test4", | ||
| "question0": "answer4", | ||
| "question1": "answer4", | ||
| "question2": "answer4", | ||
| "question3": "answer4", | ||
| "question4": "answer4", | ||
| "question5": "answer4", | ||
| "question6": "answer4", | ||
| "question7": "answer4", | ||
| "question8": "answer4", | ||
| "question9": "answer4", | ||
| "question10": "answer4", | ||
| "question11": "answer4", | ||
| "assignedCabin": "cabin4", | ||
| "secondAssignedCabin": "cabin1" | ||
| }, | ||
| { | ||
| "id": "64b0a5b67c6e7f3511e8509e", | ||
| "email": "test4", | ||
| "question0": "answer4", | ||
| "question1": "answer4", | ||
| "question2": "answer4", | ||
| "question3": "answer4", | ||
| "question4": "answer4", | ||
| "question5": "answer4", | ||
| "question6": "answer4", | ||
| "question7": "answer4", | ||
| "question8": "answer4", | ||
| "question9": "answer4", | ||
| "question10": "answer4", | ||
| "question11": "answer4", | ||
| "assignedCabin": "cabin4", | ||
| "secondAssignedCabin": "cabin1" | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.