Skip to content

Commit

Permalink
feat: update mongodb script
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavilien committed Feb 8, 2025
1 parent a9474ca commit 74d697a
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 6 deletions.
49 changes: 44 additions & 5 deletions scripts/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

load_dotenv()

API_URL = "https://backend.tartanhacks.com"
JUDGING_URL = "https://judging.tartanhacks.com"
API_URL = "https://dev.backend.tartanhacks.com"
JUDGING_URL = "https://dev.judging.tartanhacks.com"
JWT_SECRET = os.getenv("JWT_SECRET")
MONGO_CONNECTION_STRING = os.getenv("MONGODB_URI")
HELIX_DB = "tartanhacks-25"
HELIX_DB = "tartanhacks-25-dev"
JUDGING_DB = "tartanhacks-25-judging-dev"

print(f"MONGO_CONNECTION_STRING: {MONGO_CONNECTION_STRING}")
Expand Down Expand Up @@ -132,9 +132,18 @@ def create_projects(n):
headers={"x-access-token": JWT_SECRET},
)

table_number_response = requests.patch(
f"{API_URL}/projects/{project_response.json()['_id']}/table-number",
json={"tableNumber": 1},
headers={"x-access-token": JWT_SECRET},
)

print(
f"Response for project creation: {project_response.status_code} - {project_response.text}"
)
print(
f"Response for table number assignment: {table_number_response.status_code} - {table_number_response.text}"
)


def delete_projects():
Expand Down Expand Up @@ -186,8 +195,8 @@ def create_judges(n):
)


# def delete_judging_database():
# client.drop_database(JUDGING_DB)
def delete_judging_database():
client.drop_database(JUDGING_DB)


def synchronize():
Expand Down Expand Up @@ -436,12 +445,42 @@ def get_pitt_checkins(event_id):
# print(f"Email: {user['email']}")


def add_judges():
with open("../data/add_judges.csv", mode="r") as users_file:
csv_reader = csv.DictReader(users_file)
judges = []
for row in csv_reader:
if row["email"]:
judges.append(row["email"])

judge_response = requests.post(
f"{API_URL}/judges/", json=judges, headers={"x-access-token": JWT_SECRET}
)

# Copy users file to judges file using os but only the email and passwords by opening the csv and copying
with open("../data/users.csv", mode="r") as users_file, open(
"../data/judges.csv", mode="w", newline=""
) as judges_file:
csv_reader = csv.DictReader(users_file)
fieldnames = ["email", "password"]
writer = csv.DictWriter(judges_file, fieldnames=fieldnames)
writer.writeheader()

for row in csv_reader:
writer.writerow({"email": row["email"], "password": row["password"]})

print(
f"Response for judge creation: {judge_response.status_code} - {judge_response.text}"
)


if __name__ == "__main__":
# create_users(3)
# create_judges(3)
# delete_projects()
# create_projects(10)
# delete_judging_database()
# add_judges()
# synchronize()
# create_sponsors()
# delete_checkins()
Expand Down
133 changes: 132 additions & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,100 @@
}
}
},
"/projects/{id}/location": {
"patch": {
"summary": "Update project location/table number",
"security": [
{
"apiKeyAuth": []
}
],
"tags": [
"Projects Module"
],
"description": "Update a project's location/table number. Access - User(own)/Admin.",
"parameters": [
{
"in": "path",
"name": "id",
"schema": {
"type": "string"
},
"required": true,
"description": "Project ID"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The new table number/location"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Success."
},
"400": {
"description": "Bad request"
},
"403": {
"description": "Unauthorized."
},
"500": {
"description": "Internal Server Error."
}
}
}
},
"/projects/{id}/submit": {
"post": {
"summary": "Submit a project",
"security": [
{
"apiKeyAuth": []
}
],
"tags": [
"Projects Module"
],
"description": "Submit a project. Access - User(Own)/Admin.",
"parameters": [
{
"in": "path",
"name": "id",
"schema": {
"type": "string"
},
"required": true,
"description": "Project ID"
}
],
"responses": {
"200": {
"description": "Success."
},
"400": {
"description": "Bad request"
},
"403": {
"description": "Unauthorized."
},
"500": {
"description": "Internal Server Error."
}
}
}
},
"/recruiter": {
"post": {
"summary": "Create a new recruiter",
Expand Down Expand Up @@ -2619,6 +2713,43 @@
}
}
},
"/config/expo": {
"get": {
"summary": "Get expo configuration",
"tags": [
"Settings Module"
],
"description": "Get expo start time and submission deadline",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"expoStartTime": {
"type": "string",
"format": "date-time"
},
"submissionDeadline": {
"type": "string",
"format": "date-time"
}
}
}
}
}
},
"404": {
"description": "Configuration not found"
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/sponsor/": {
"post": {
"summary": "Create a new sponsor (company)",
Expand Down Expand Up @@ -3652,7 +3783,7 @@
}
}
}
},
}
},
"responses": {
"200": {
Expand Down

0 comments on commit 74d697a

Please sign in to comment.