Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed May 16, 2024
2 parents 863b692 + f320c99 commit 2024d88
Show file tree
Hide file tree
Showing 13 changed files with 474 additions and 684 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: 32 additions & 22 deletions backend/api/seeders/seeder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 @@ -180,15 +179,13 @@ 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.pybool(truth_probability=10)
faker.sentence()
] for _ in range(count)
]

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

Expand Down Expand Up @@ -386,21 +383,18 @@ 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,
choice(states)[0]
True
]
for _ in range(count)
]

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

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

cursor.executemany(
"INSERT INTO api_structurecheck(id, path, project_id) VALUES (?, ?, ?)",
"INSERT INTO api_structurecheck(id, name, project_id) VALUES (?, ?, ?)",
structure_checks
)
cursor.executemany(
Expand Down Expand Up @@ -467,19 +461,16 @@ 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=10, max_value=1000),
faker.pyint(min_value=50, max_value=1024),
faker.pyint(min_value=100, max_value=1000),
]
for _ in range(count)
]

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

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

# Insert submissions
cursor.executemany(
"INSERT INTO api_submission(submission_time, group_id, is_valid, zip) VALUES (?, ?, ?, ?)",
"INSERT INTO api_submission(submission_time, group_id, is_valid) 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 @@ -529,9 +540,8 @@ def seed_submission_results(faker):

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

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-05-11T14:27:17.431Z", "username": "ChristopherD", "is_staff": false, "email": "ChristopherD@ugent.be", "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": "AnthonyJohns@ugent.be", "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": "PaulChapman@ugent.be", "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": "JohnMarsh@ugent.be", "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": "AngelaLewis@ugent.be", "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": "JasonHernand@ugent.be", "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": "PeterMelton@ugent.be", "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": "RyanHughes@ugent.be", "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": "VanessaHorto@ugent.be", "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": "StephenBarbe@ugent.be", "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": "KristineMurp@ugent.be", "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": "SamanthaFisc@ugent.be", "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": "SabrinaMorri@ugent.be", "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": "DylanHayes@ugent.be", "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": "RodneyWeeks@ugent.be", "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": "MatthewAnder@ugent.be", "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": "KevinSmith@ugent.be", "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": "JoannaBriggs@ugent.be", "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"}}]
[{"model": "authentication.user", "pk": "0", "fields": {"last_login": "2024-04-19T10:14:42.362Z", "username": "JeremiahBrow", "is_staff": false, "email": "JeremiahBrow@ugent.be", "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": "ReneeAnderso@ugent.be", "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": "MollyBarnes@ugent.be", "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": "StevenHunter@ugent.be", "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": "DanielLawson@ugent.be", "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": "BrandonSando@ugent.be", "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": "MichaelJacob@ugent.be", "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": "AprilCarlson@ugent.be", "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": "SierraThomas@ugent.be", "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": "EricThomas@ugent.be", "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": "MarilynJohns@ugent.be", "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": "JerryBurns@ugent.be", "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": "KevinTorres@ugent.be", "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": "JamesShannon@ugent.be", "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": "BrandiSchult@ugent.be", "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": "JessicaHogan@ugent.be", "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": "RachelMurphy@ugent.be", "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": "CatherineBar@ugent.be", "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"}}]
Loading

0 comments on commit 2024d88

Please sign in to comment.