NickA02 / SOTestingEnv

This project aims to create a web-based coding platform specifically tailored for Science Olympiad programming events.
2 stars 0 forks source link

Updated ES Scripting for team manipulation #33

Closed NickA02 closed 3 weeks ago

NickA02 commented 3 weeks ago

The title says it all! Updated functionality to see, modify, and add teams to the database via scripting and files.

Functions added are shown below, which is the same documentation that I added to the ReadME:

create_team_table

Description

Generates new team entries with unique identifiers based on a specified prefix and saves them to the database and a CSV file. The script takes care of password generation for each team and saves the updated team data back to the specified file. If the CSV file doesn’t exist, it will be created with the appropriate columns.

The script does not update any changes from the file, so anything in the file but not in the database will be reverted similar to the teams_to_csv script.

This command follows these rules:

Command

python3 -m backend.script.create_team_table <prefix> <number_of_teams> <date> <start_time> <end_time> <file_path>

Arguments

Argument Description
prefix Alphabetic prefix for team names. Each new team name will start with this prefix, followed by a unique number.
number_of_teams Number of new teams to create. This must be an integer.
date Date for team activities in the format mm/dd/yyyy.
start_time Start time for team activities in HH:MM format, on the specified date.
end_time End time for team activities in HH:MM format, on the specified date.
file_path Path to the CSV file where the updated team information will be saved. If the file does not exist, it will be created with default columns. Must have a .csv extension. DEFAULT: es_files/teams.csv

load_teams

Description

Loads a local teams.csv table into the database. This command will take care of password generation for teams as they are initialized and add them to the csv file. No password overwriting occurs in this script.

This command is safe... meaning it follows these rules: Where a team is identified by it's team number...

  1. Any team in the database but NOT in the file will be added to the file
  2. Any team in the file but NOT in the database will be added to the database
  3. Any team in both the file and database will update the database to the file's fields (if there are changes)

Command

python3 -m backend.script.load_teams <file_path>

Arguments

Argument Description
file_path File containing updated team information. Upon completing, this file is altered to show the current state of the team table in the database

teams_to_csv

Description

Updates or generates a teams.csv file containing the current state of the database.

This command is NOT safe... meaning any changes in the teams.csv file will be deleted!

Command

python3 -m backend.script.teams_to_csv <file_path>

Arguments

Argument Description
file_path OPTIONAL. File to be filled with team table information. Upon completing, this file is altered or generated to show the current state of the team table in the database. Default: es_files/teams.csv

teams_to_database

Description

Updates the teams table in the database to match the teams.csv file provided.

This command is NOT safe... meaning any changes and deletions in the teams.csv will be perminant!

This command is safe... meaning it follows these rules: Where a team is identified by it's team number...

  1. Any team in the database but NOT in the file will be DELETED from the database
  2. Any team in the file but NOT in the database will be ADDED to the database
  3. Any team present in both will be UPDATED according the file's specifications

Command

python3 -m backend.script.teams_to_database <file_path>

Arguments

Argument Description
file_path File containing updated team information. Upon successful completion, the database will be updated to the file's specifications.

reset_unique_words

Description

The unique_word_list is our current tool for password generation. As more teams are made and more passwords are generated, the word list depletes. This function resets only the word list so that new passwords can be generated.

Command

python3 -m backend.script.reset_unique_words

Arguments

NA

reset_teams

Description

Will permenantly delete ALL DATA in the team table of the database.

Command

python3 -m backend.script.reset_teams

Arguments

NA