Skip to content
Merged
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
60 changes: 60 additions & 0 deletions server/schema/mock_schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Check for the command line argument
if [ "$1" == "" ]; then
echo "Usage: mock_data.sh <number_of_documents>"
exit 1
fi

# If command line utils aren't installed, exit
if ! foobar_loc="$(type -p mongoimport)" || [[ -z $foobar_loc ]]; then
echo "monogoimport not installed"
exit 1
fi

if ! foobar_loc="$(type -p mongodb-dataset-generator)" || [[ -z $foobar_loc ]]; then
echo "mongodb-dataset-generator not installed"
exit 1
fi

if ! foobar_loc="$(type -p jq)" || [[ -z $foobar_loc ]]; then
echo "jq not installed"
exit 1
fi

# Mongodb Cloud Atlas URI
MONGO_HOST=HackMerced-shard-0/hackmerced-shard-00-00-1za3e.mongodb.net:27017,hackmerced-shard-00-01-1za3e.mongodb.net:27017,hackmerced-shard-00-02-1za3e.mongodb.net:27017

# Replace the placeholder and insert the correct number of documents to be produced
sed -i 's/__SIZE__/'$1'/g' schema.json

# Generate dummy data
mongodb-dataset-generator schema.json -n 1 -o mock_data.json > /dev/null

# Parse the json into individual file for each collection
jq '.[0].hackers' mock_data.json > hackers_mock_data.json
jq '.[0].judges' mock_data.json > judges_mock_data.json
jq '.[0].volunteers' mock_data.json > volunteers_mock_data.json
jq '.[0].sponsors' mock_data.json > sponsors_mock_data.json

# Get username & password
echo "Connecting to mongo cloud: "
echo "Username: "
read USERNAME
echo "Password: "
read -s PASSWORD

# Upload & import dummy data into the appropriate collections
mongoimport --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db users --collection main --file ./hackers_mock_data.json --jsonArray --drop
mongoimport --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db users --collection main --file ./judges_mock_data.json --jsonArray
mongoimport --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db users --collection main --file ./volunteers_mock_data.json --jsonArray
mongoimport --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db users --collection main --file ./sponsors_mock_data.json --jsonArray
mongofiles --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db resources put person-icon.png --replace
mongofiles --host $MONGO_HOST --ssl --username $USERNAME --password $PASSWORD --authenticationDatabase admin --db resources put orange-triangle-banner.jpg --replace

# Replace the placeholder for document size
sed -i 's/{"size": '$1'/{"size": __SIZE__/g' schema.json

# Clean up
rm ./mock_data.json ./hackers_mock_data.json ./judges_mock_data.json ./volunteers_mock_data.json ./sponsors_mock_data.json

Binary file added server/schema/orange-triangle-banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/schema/person-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions server/schema/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"hackers":
[ "{{_$config}}", {"size": __SIZE__}, {
"full_name": "{{chance.first()}} {{chance.last()}}",
"email": "{{chance.email()}}",
"password": "{{chance.word({ length: 10 })}}",
"phone": "{{chance.phone()}}",
"school": "{{chance.sentence({ words: 5 })}}",
"age": "{{chance.age()}}",
"gender": "{{util.sample(['Male', 'Female', 'Non-Binary/Other', 'Prefer Not To Say'])}}",
"skills": "{{chance.pick(['Developement', 'Design', 'Data Science', 'Project Management'], chance.integer({ min: 0, max: 4}))}}",
"interests": "{{chance.pick(['Front-End Web', 'Back-End Web', 'Mobile Apps', 'Embedded Devices', 'IOT', 'VR', 'Distributed Systems', 'Hardware', 'Data Science', 'Data Visualization'], chance.integer({ min: 0, max: 9}))}}",
"programming_languages": "{{chance.pick(['Python', 'Java', 'C/C++', 'Javascript', 'Ruby', 'R'], chance.integer({ min: 0, max: 6}))}}",
"dietary_restrictions": "{{chance.sentence({ words: 5 })}}",
"allergies": "{{chance.sentence({ words: 5 })}}",
"special_needs": "{{chance.sentence({ words: 5 })}}",
"shirt_size": "{{util.sample(['X-Small', 'Small', 'Medium', 'Large', 'X-Large', 'XX-Large', 'XXX-Large'])}}",
"previous_hackathons": "{{util.sample(['0', '1-2', '3-4', '4+'])}}",
"have_team": "{{util.sample(['yes', 'no'])}}",
"team_emails": [ "{{_$config}}", {"size": [0,4]}, "{{chance.email()}}"],
"require_reimbursement": "{{util.sample(['yes', 'no'])}}",
"linkedin": "http://linkedin.com/in/{{chance.word({ length: 7 })}}",
"github": "http://github.com/{{chance.word({ length: 7 })}}",
"site_other": "{{chance.domain()}}",
"resume": "{{chance.domain()}}/{{chance.word({ length: 5 })}}.pdf",
"application_status": "{{util.sample(['received', 'under review', 'accepted'])}}",
"privileges": ["user"],
"type": "hacker"
}],
"judges":
[ "{{_$config}}", {"size": __SIZE__}, {
"full_name": "{{chance.first()}} {{chance.last()}}",
"title": "{{util.sample(['Prof.', 'Software Engineer'])}}",
"email": "{{chance.email()}}",
"password": "{{chance.word({ length: 10 })}}",
"phone": "{{chance.phone()}}",
"shirt_size": "{{util.sample(['X-Small', 'Small', 'Medium', 'Large', 'X-Large', 'XX-Large', 'XXX-Large'])}}",
"occupation": "{{util.sample(['Faculty', 'Professional', 'Other'])}}",
"position": "{{chance.sentence({ words: 3 })}}",
"organization": "{{chance.pick([chance.city()+' University','University of '+chance.city(), chance.sentence({ words: 1 })+' Co.', chance.sentence({ words: 1 })+' Ltd'])}}",
"linkedin": "http://linkedin.com/in/{{chance.word({ length: 7 })}}",
"site_other": "{{chance.domain()}}",
"photo": "person-icon.png",
"privileges": ["user"],
"type": "judge"
}],
"volunteers":
[ "{{_$config}}", {"size": __SIZE__}, {
"full_name": "{{chance.first()}} {{chance.last()}}",
"phone": "{{chance.phone()}}",
"email": "{{chance.email()}}",
"password": "{{chance.word({ length: 10 })}}",
"shirt_size": "{{util.sample(['X-Small', 'Small', 'Medium', 'Large', 'X-Large'])}}",
"availability": "",
"privileges": ["user"],
"type": "volunteer"
}],
"sponsors":
[ "{{_$config}}", {"size": __SIZE__}, {
"organization": "{{chance.pick([chance.city()+' University','University of '+chance.city(), chance.sentence({ words: 1 })+' Co.', chance.sentence({ words: 1 })+' Ltd'])}}",
"email": "{{chance.email()}}",
"password": "{{chance.word({ length: 10 })}}",
"phone": "{{chance.phone()}}",
"rep_name": "{{chance.first()}} {{chance.last()}}",
"rep_position": "{{chance.sentence({ words: 3 })}}",
"linkedin": "http://linkedin.com/in/{{chance.word({ length: 7 })}}",
"site_other": "{{chance.domain()}}",
"photo": "orange-triangle-banner.jpg",
"privileges": ["user"],
"type": "sponsor"
}],
"teams":
{
"project_name": "{{chance.sentence({words:1})}}",
"project_description": "{{chance.sentence({words:20})}}",
"leader": "{{chance.email()}}",
"members": [ "{{_$config}}", {"size": [0,4]}, "{{chance.email()}}"],
"github": "http://github.com/{{chance.word({ length: 7 })}}",
"devpost": "http://devpost.com/software/{{chance.word({ length: 9 })}}"
},
"travel_reimbursement":
{
"email": "{{chance.email()}}",
"reimbursement_amount_requested": "{{chance.integer({min:10,max:200})}}",
"reimbursement_amount_approved": "{{chance.integer({min:10,max:200})}}",
"reimbursement_status": "{{util.sample(['Under review', 'Approved', 'Denied'])}}"
}
}