WorldCup Database Timeout

Dear folks, I am currently trying to complete the curriculum for the Relational databases however, it occured that the timer always runs out no matter how efficient I design my querrys.

I even copied code from finished curriculums to test if it is possible to complete the insert data querry.
Neither worked.

I already was resetting the project several times.
I deleted my CodeAlly Virtual machine and wrote the entire SQL from scratch.
I ran the tests now more than hundred times with different browsers, devices and it still does not work.
I would really appreciate if either the counter gets increased or one can tell me a faster alternative to CodeAlly I could use since it seems to me that the performance is currently very low.
If someone is interested in my insert data code please take a look to tell me if I made just a major mistake.
Best Regards Joel :slight_smile:

#! /bin/bash

if [[ $1 == "test" ]]
  PSQL="psql --username=postgres --dbname=worldcuptest -t --no-align -c"
  PSQL="psql --username=freecodecamp --dbname=worldcup -t --no-align -c"

# Do not change code above this line. Use the PSQL variable above to query your database.

cat games.csv | while IFS="," read year round winner opponent winner_goals opponent_goals
#Add teams to table
 if [[ $year != "year" ]]
  # get team_id
  team_opponent_id=$($PSQL "Select team_id from teams where name='$opponent'")
  #if not found team id in winner or opponent
  if [[ -z $team_opponent_id ]]
  #Add opponent when not in list
  Insert_opponent_team_result=$($PSQL "Insert into teams(name) Values('$opponent')")
  if [[ $Insert_opponent_team_result == 'INSERT 0 1' ]]
echo Inserted Team, $opponent
  team_winner_id=$($PSQL "Select team_id from teams where name='$winner'")
  #Add if winner not in list
  if [[ -z $team_winner_id ]]
  Insert_team_winner_result=$($PSQL "Insert into teams(name) Values('$winner')")
    if [[ $Insert_team_winner_result == 'INSERT 0 1' ]]
echo Inserted Team, $winner

#Add Games to Table
#check for opponent and winner id
team_opponent_id=$($PSQL "Select team_id from teams where name='$opponent'")
team_winner_id=$($PSQL "Select team_id from teams where name='$winner'")
#check if game id exists
game_id=$($PSQL "Select game_id from games where winner_id='$team_winner_id' and opponent_id='$team_opponent_id'")
  if [[ -z $game_id ]]
insert_game_result=$($PSQL "Insert into games(year,round,winner_id,opponent_id,winner_goals,opponent_goals) Values('$year','$round','$team_winner_id','$team_opponent_id','$winner_goals','$opponent_goals')") 

  if [[ $insert_game_result == 'INSERT 0 1' ]]
echo Inserted Year: $year round: $round winner: $team_winner_id opponent: $team_opponent_id winner goals: $winner_goals oppnent goals: $opponent_goals

Do you have an sql file I could use, so I don’t have to build the database from scratch? Then I’ll test the bash script for you and see if I can get it passing.

Sure I have all the files in my Github.

@JoeCodity, I got your code to pass.

You need to change your filename because it is incorrect (should be

The real problem though is that the tests run so slow that the default timeout for Mocha (20000ms) kept being exceeded.

If you find the package.json file and edit the timeout to 50000 (as you’ll see I have done), the tests should pass within a couple of attempts.

1 Like

Thank you very much, I also tried to increase the time but I did not find this configuration.
It works now, I have completed the course now.
Have a nice day :slight_smile:

A post was split to a new topic: Relational Databases: Salon Appointment Scheduler