Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/main' into development"
Browse files Browse the repository at this point in the history
This reverts commit 2024d88, reversing
changes made to 863b692.
  • Loading branch information
Topvennie committed May 16, 2024
1 parent 2024d88 commit f9353d6
Show file tree
Hide file tree
Showing 13 changed files with 684 additions and 474 deletions.
2 changes: 1 addition & 1 deletion backend/api/fixtures/large/large.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/api/fixtures/medium/medium.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/api/fixtures/small/small.json

Large diffs are not rendered by default.

54 changes: 22 additions & 32 deletions backend/api/seeders/seeder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import wraps
from random import choice, randint, sample
from time import time
from typing import Literal

from django.db import connection
from django.utils import timezone
Expand Down Expand Up @@ -179,13 +180,15 @@ def seed_courses(faker,
faker.paragraph(),
timezone.now().year + faker.random_int(min=year_dev_min, max=year_dev_max),
choice(faculties),
faker.sentence()
faker.sentence(),
faker.pybool(truth_probability=10)
] for _ in range(count)
]

# Insert courses
cursor.executemany(
"INSERT INTO api_course(name, description, academic_startyear, faculty_id, excerpt) VALUES (?, ?, ?, ?, ?)",
"INSERT INTO api_course(name, description, academic_startyear, faculty_id, excerpt, private_course) "
"VALUES (?, ?, ?, ?, ?, ?)",
courses
)

Expand Down Expand Up @@ -383,18 +386,21 @@ def seed_docker_images(faker, count: int = 50):
cursor.execute(sql="SELECT id FROM authentication_user").fetchall()
)

states = ["QUEUED", "BUILDING", "SUCCESS", "FAILED"]

docker_images = [
[
faker.file_name(category="image"),
faker.file_path(extension="", depth=faker.random_int(min=0, max=5)),
choice(users)[0],
True
True,
choice(states)[0]
]
for _ in range(count)
]

cursor.executemany(
"INSERT INTO api_dockerimage(name, file, owner_id, public) VALUES (?, ?, ?, ?)",
"INSERT INTO api_dockerimage(name, file, owner_id, public, state) VALUES (?, ?, ?, ?, ?)",
docker_images
)

Expand Down Expand Up @@ -433,7 +439,7 @@ def seed_structure_checks(faker, count: int = 1_500):
blocked_extensions.append([project, extension])

cursor.executemany(
"INSERT INTO api_structurecheck(id, name, project_id) VALUES (?, ?, ?)",
"INSERT INTO api_structurecheck(id, path, project_id) VALUES (?, ?, ?)",
structure_checks
)
cursor.executemany(
Expand Down Expand Up @@ -461,16 +467,19 @@ def seed_extra_checks(faker, count: int = 750):
extra_checks = [
[
choice(projects)[0],
faker.word(),
faker.boolean(chance_of_getting_true=50),
choice(docker_images)[0],
faker.file_path(extension="", depth=faker.random_int(min=0, max=5)),
faker.pyint(min_value=100, max_value=1000),
faker.pyint(min_value=10, max_value=1000),
faker.pyint(min_value=50, max_value=1024),
]
for _ in range(count)
]

cursor.executemany(
"INSERT INTO api_extracheck(project_id, show_log, docker_image_id, file, timeout) VALUES (?, ?, ?, ?, ?)",
"INSERT INTO api_extracheck(project_id, name, show_log, docker_image_id, file, time_limit, memory_limit) "
"VALUES (?, ?, ?, ?, ?, ?, ?)",
extra_checks
)

Expand All @@ -489,39 +498,19 @@ def seed_submissions(faker, count: int = 4_000):
[
faker.date_this_month(),
choice(groups),
faker.boolean(chance_of_getting_true=80)
faker.boolean(chance_of_getting_true=80),
faker.file_path(extension=faker.file_extension(), depth=faker.random_int(min=0, max=5))
]
for _ in range(count)
]

# Insert submissions
cursor.executemany(
"INSERT INTO api_submission(submission_time, group_id, is_valid) VALUES (?, ?, ?)",
"INSERT INTO api_submission(submission_time, group_id, is_valid, zip) VALUES (?, ?, ?, ?)",
submissions
)


@timer
def seed_submission_files(faker, count: int = 10_000):
"""Seed submission files into the database"""
with connection.cursor() as cursor:
submissions = list(
cursor.execute(sql="SELECT id FROM api_submission").fetchall()
)

files = [
[
choice(submissions)[0],
faker.file_path(extension=faker.file_extension(), depth=faker.random_int(min=0, max=5)),
]
]

cursor.executemany(
"INSERT INTO api_submissionfile(submission_id, file) VALUES (?, ?)",
files
)


@timer
def seed_submission_results(faker):
with connection.cursor() as cursor:
Expand All @@ -540,8 +529,9 @@ def seed_submission_results(faker):

check_result = ("QUEUED", "RUNNING", "SUCCESS", "FAILED")
error_structure = ("BLOCKED_EXTENSION", "OBLIGATED_EXTENSION_NOT_FOUND",
"OBLIGATED_DIRECTORY_NOT_FOUND", "UNASKED_DIRECTORY")
error_extra = ("TIMEOUT", "MEMORYLIMIT", "RUNTIMEERROR", "OUTPUTLIMIT", "INTERNALERROR", "UNKNOWN")
"FILE_DIR_NOT_FOUND")
error_extra = ("DOCKER_IMAGE_ERROR", "TIME_LIMIT", "MEMORY_LIMIT",
"CHECK_ERROR", "RUNTIME_ERROR", "UNKNOWN", "FAILED_STRUCTURE_CHECK")

results = []
structure_results = []
Expand Down
2 changes: 1 addition & 1 deletion backend/authentication/fixtures/large/large.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/authentication/fixtures/medium/medium.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/authentication/fixtures/small/small.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"model": "authentication.user", "pk": "0", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "JeremiahBrow", "is_staff": false, "email": "[email protected]", "first_name": "Jeremiah", "last_name": "Brown", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "1", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "ReneeAnderso", "is_staff": false, "email": "[email protected]", "first_name": "Renee", "last_name": "Anderson", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "10", "fields": {"last_login": "2024-04-19T10:14:42.514Z", "username": "MollyBarnes", "is_staff": false, "email": "[email protected]", "first_name": "Molly", "last_name": "Barnes", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.514Z", "faculties": []}}, {"model": "authentication.user", "pk": "11", "fields": {"last_login": "2024-04-19T10:14:42.514Z", "username": "StevenHunter", "is_staff": false, "email": "[email protected]", "first_name": "Steven", "last_name": "Hunter", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.514Z", "faculties": []}}, {"model": "authentication.user", "pk": "12", "fields": {"last_login": "2024-04-19T10:14:42.514Z", "username": "DanielLawson", "is_staff": false, "email": "[email protected]", "first_name": "Daniel", "last_name": "Lawson", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.514Z", "faculties": []}}, {"model": "authentication.user", "pk": "13", "fields": {"last_login": "2024-04-19T10:14:42.514Z", "username": "BrandonSando", "is_staff": false, "email": "[email protected]", "first_name": "Brandon", "last_name": "Sandoval", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.514Z", "faculties": []}}, {"model": "authentication.user", "pk": "14", "fields": {"last_login": "2024-04-19T10:14:42.514Z", "username": "MichaelJacob", "is_staff": false, "email": "[email protected]", "first_name": "Michael", "last_name": "Jacobs", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.514Z", "faculties": []}}, {"model": "authentication.user", "pk": "15", "fields": {"last_login": "2024-04-19T10:14:42.594Z", "username": "AprilCarlson", "is_staff": false, "email": "[email protected]", "first_name": "April", "last_name": "Carlson", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.594Z", "faculties": []}}, {"model": "authentication.user", "pk": "16", "fields": {"last_login": "2024-04-19T10:14:42.594Z", "username": "SierraThomas", "is_staff": false, "email": "[email protected]", "first_name": "Sierra", "last_name": "Thomas", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.594Z", "faculties": []}}, {"model": "authentication.user", "pk": "17", "fields": {"last_login": "2024-04-19T10:14:42.594Z", "username": "EricThomas", "is_staff": false, "email": "[email protected]", "first_name": "Eric", "last_name": "Thomas", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.594Z", "faculties": []}}, {"model": "authentication.user", "pk": "2", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "MarilynJohns", "is_staff": false, "email": "[email protected]", "first_name": "Marilyn", "last_name": "Johnson", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "3", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "JerryBurns", "is_staff": false, "email": "[email protected]", "first_name": "Jerry", "last_name": "Burns", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "4", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "KevinTorres", "is_staff": false, "email": "[email protected]", "first_name": "Kevin", "last_name": "Torres", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "5", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "JamesShannon", "is_staff": false, "email": "[email protected]", "first_name": "James", "last_name": "Shannon", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "6", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "BrandiSchult", "is_staff": false, "email": "[email protected]", "first_name": "Brandi", "last_name": "Schultz", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "7", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "JessicaHogan", "is_staff": false, "email": "[email protected]", "first_name": "Jessica", "last_name": "Hogan", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.362Z", "faculties": []}}, {"model": "authentication.user", "pk": "8", "fields": {"last_login": "2024-04-19T10:14:42.363Z", "username": "RachelMurphy", "is_staff": false, "email": "[email protected]", "first_name": "Rachel", "last_name": "Murphy", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.363Z", "faculties": []}}, {"model": "authentication.user", "pk": "9", "fields": {"last_login": "2024-04-19T10:14:42.363Z", "username": "CatherineBar", "is_staff": false, "email": "[email protected]", "first_name": "Catherine", "last_name": "Barrett", "last_enrolled": 2024, "create_time": "2024-04-19T10:14:42.363Z", "faculties": []}}, {"model": "authentication.faculty", "pk": "Bio-ingenieurswetenschappen", "fields": {"name": "faculties.bioscience_engineering"}}, {"model": "authentication.faculty", "pk": "Diergeneeskunde", "fields": {"name": "faculties.veterinary_medicine"}}, {"model": "authentication.faculty", "pk": "Economie_Bedrijfskunde", "fields": {"name": "faculties.economics_business_administration"}}, {"model": "authentication.faculty", "pk": "Farmaceutische_Wetenschappen", "fields": {"name": "faculties.pharmaceutical_sciences"}}, {"model": "authentication.faculty", "pk": "Geneeskunde_Gezondheidswetenschappen", "fields": {"name": "faculties.medicine_health_sciences"}}, {"model": "authentication.faculty", "pk": "Ingenieurswetenschappen_Architectuur", "fields": {"name": "faculties.engineering_architecture"}}, {"model": "authentication.faculty", "pk": "Letteren_Wijsbegeerte", "fields": {"name": "faculties.arts_philosophy"}}, {"model": "authentication.faculty", "pk": "Politieke_Sociale_Wetenschappen", "fields": {"name": "faculties.political_social_sciences"}}, {"model": "authentication.faculty", "pk": "Psychologie_PedagogischeWetenschappen", "fields": {"name": "faculties.psychology_educational_sciences"}}, {"model": "authentication.faculty", "pk": "Recht_Criminologie", "fields": {"name": "faculties.law_criminology"}}, {"model": "authentication.faculty", "pk": "Wetenschappen", "fields": {"name": "faculties.sciences"}}]
[{"model": "authentication.user", "pk": "0", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "ChristopherD", "is_staff": false, "email": "[email protected]", "first_name": "Christopher", "last_name": "Davis", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "1", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "AnthonyJohns", "is_staff": false, "email": "[email protected]", "first_name": "Anthony", "last_name": "Johnson", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "10", "fields": {"last_login": "2024-05-11T14:27:17.598Z", "username": "PaulChapman", "is_staff": false, "email": "[email protected]", "first_name": "Paul", "last_name": "Chapman", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.598Z", "faculties": []}}, {"model": "authentication.user", "pk": "11", "fields": {"last_login": "2024-05-11T14:27:17.598Z", "username": "JohnMarsh", "is_staff": false, "email": "[email protected]", "first_name": "John", "last_name": "Marsh", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.598Z", "faculties": []}}, {"model": "authentication.user", "pk": "12", "fields": {"last_login": "2024-05-11T14:27:17.598Z", "username": "AngelaLewis", "is_staff": false, "email": "[email protected]", "first_name": "Angela", "last_name": "Lewis", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.598Z", "faculties": []}}, {"model": "authentication.user", "pk": "13", "fields": {"last_login": "2024-05-11T14:27:17.598Z", "username": "JasonHernand", "is_staff": false, "email": "[email protected]", "first_name": "Jason", "last_name": "Hernandez", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.598Z", "faculties": []}}, {"model": "authentication.user", "pk": "14", "fields": {"last_login": "2024-05-11T14:27:17.598Z", "username": "PeterMelton", "is_staff": false, "email": "[email protected]", "first_name": "Peter", "last_name": "Melton", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.598Z", "faculties": []}}, {"model": "authentication.user", "pk": "15", "fields": {"last_login": "2024-05-11T14:27:17.679Z", "username": "RyanHughes", "is_staff": false, "email": "[email protected]", "first_name": "Ryan", "last_name": "Hughes", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.679Z", "faculties": []}}, {"model": "authentication.user", "pk": "16", "fields": {"last_login": "2024-05-11T14:27:17.679Z", "username": "VanessaHorto", "is_staff": false, "email": "[email protected]", "first_name": "Vanessa", "last_name": "Horton", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.679Z", "faculties": []}}, {"model": "authentication.user", "pk": "17", "fields": {"last_login": "2024-05-11T14:27:17.680Z", "username": "StephenBarbe", "is_staff": false, "email": "[email protected]", "first_name": "Stephen", "last_name": "Barber", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.680Z", "faculties": []}}, {"model": "authentication.user", "pk": "2", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "KristineMurp", "is_staff": false, "email": "[email protected]", "first_name": "Kristine", "last_name": "Murphy", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "3", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "SamanthaFisc", "is_staff": false, "email": "[email protected]", "first_name": "Samantha", "last_name": "Fischer", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "4", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "SabrinaMorri", "is_staff": false, "email": "[email protected]", "first_name": "Sabrina", "last_name": "Morris", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "5", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "DylanHayes", "is_staff": false, "email": "[email protected]", "first_name": "Dylan", "last_name": "Hayes", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "6", "fields": {"last_login": "2024-05-11T14:27:17.431Z", "username": "RodneyWeeks", "is_staff": false, "email": "[email protected]", "first_name": "Rodney", "last_name": "Weeks", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.431Z", "faculties": []}}, {"model": "authentication.user", "pk": "7", "fields": {"last_login": "2024-05-11T14:27:17.432Z", "username": "MatthewAnder", "is_staff": false, "email": "[email protected]", "first_name": "Matthew", "last_name": "Anderson", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.432Z", "faculties": []}}, {"model": "authentication.user", "pk": "8", "fields": {"last_login": "2024-05-11T14:27:17.432Z", "username": "KevinSmith", "is_staff": false, "email": "[email protected]", "first_name": "Kevin", "last_name": "Smith", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.432Z", "faculties": []}}, {"model": "authentication.user", "pk": "9", "fields": {"last_login": "2024-05-11T14:27:17.432Z", "username": "JoannaBriggs", "is_staff": false, "email": "[email protected]", "first_name": "Joanna", "last_name": "Briggs", "last_enrolled": 2024, "create_time": "2024-05-11T14:27:17.432Z", "faculties": []}}, {"model": "authentication.faculty", "pk": "Bio-ingenieurswetenschappen", "fields": {"name": "faculties.bioscience_engineering"}}, {"model": "authentication.faculty", "pk": "Diergeneeskunde", "fields": {"name": "faculties.veterinary_medicine"}}, {"model": "authentication.faculty", "pk": "Economie_Bedrijfskunde", "fields": {"name": "faculties.economics_business_administration"}}, {"model": "authentication.faculty", "pk": "Farmaceutische_Wetenschappen", "fields": {"name": "faculties.pharmaceutical_sciences"}}, {"model": "authentication.faculty", "pk": "Geneeskunde_Gezondheidswetenschappen", "fields": {"name": "faculties.medicine_health_sciences"}}, {"model": "authentication.faculty", "pk": "Ingenieurswetenschappen_Architectuur", "fields": {"name": "faculties.engineering_architecture"}}, {"model": "authentication.faculty", "pk": "Letteren_Wijsbegeerte", "fields": {"name": "faculties.arts_philosophy"}}, {"model": "authentication.faculty", "pk": "Politieke_Sociale_Wetenschappen", "fields": {"name": "faculties.political_social_sciences"}}, {"model": "authentication.faculty", "pk": "Psychologie_PedagogischeWetenschappen", "fields": {"name": "faculties.psychology_educational_sciences"}}, {"model": "authentication.faculty", "pk": "Recht_Criminologie", "fields": {"name": "faculties.law_criminology"}}, {"model": "authentication.faculty", "pk": "Wetenschappen", "fields": {"name": "faculties.sciences"}}]
Loading

0 comments on commit f9353d6

Please sign in to comment.