Relational Databases: Salon Appointment Scheduler

I think I may be running into a timeout issue on the Salon sql/bash test. Is there a way to increase the timeout on that one? My code seems to be working…its super similar to the way the tutorial on the Bike Shop is so I don’t know if it’s something I did. There’s no package.json in the project folder of the Salon one.

My code seems to work fine compared to the example. Everything seems to be going into the SQL database, I even made all the text it gives you similar.

I’ve moved your question into a new topic as it relates to a different part of the certification.

Can you share your code please? I’ll have a look and see if it’s an issue with the testing environment or not.

Using the Preformatted Text Tool (</> icon or CTRL+e) will create two sets of backticks, between which you can post your code.

1 Like

Thanks IgorGetMeABrain!

Here’s my code:

#!/bin/bash
PSQL="psql -X --username=freecodecamp --dbname=salon --tuples-only -c"
echo -e "\n~~~~~ MY SALON ~~~~~\n"
echo -e "Please enter a service\n"
MAIN_MENU() {  
  # Get all services from db
  SERVICES_OFFERED=$($PSQL "SELECT * FROM services")
  # Take result of services offered, loop through them and echo them
  echo -e "$SERVICES_OFFERED" | while read SERVICE_ID BAR NAME
  do
    echo "$SERVICE_ID) $NAME"
  done
  # Read the customer selection and use it as a reference for the service_id in the services table
  read SERVICE_ID_SELECTED
  SERVICE_ID_SELECTED_LOOKUP=$($PSQL "SELECT service_id FROM services WHERE service_id="$SERVICE_ID_SELECTED"")
  # if service_id isn't in the services table, loop back to main menu
  if [[ -z $SERVICE_ID_SELECTED_LOOKUP ]]
  then
    MAIN_MENU 
  # otherwise ask for the phone number of the customer  
  else 
    echo -e "\nWhat's your phone number?"
    read CUSTOMER_PHONE
    CUSTOMER_NAME_LOOKUP=$($PSQL "SELECT name FROM customers WHERE phone = '$CUSTOMER_PHONE'")
    # if customer phone isn't in customers table, prompt for their name and add phone & name to db. Otherwise skip this step and go to service add function
    if [[ -z $CUSTOMER_NAME_LOOKUP ]]
    then
      echo -e "\nI don't have a record for that phone number, what's your name?"
      read CUSTOMER_NAME
      INSERT_CUSTOMER_INFO=$($PSQL "INSERT INTO customers(phone,name) VALUES('$CUSTOMER_PHONE', '$CUSTOMER_NAME')")
      SERVICE_TIME
    else 
      SERVICE_TIME
    fi
  fi
}
#service adding function
SERVICE_TIME() {
  CUSTOMER_NAME_DBLOOKUP=$($PSQL "SELECT name FROM customers WHERE phone='$CUSTOMER_PHONE'") # checks for customer name in case name wasn't in customers table already
  echo -e "\nWhat time would you like your cut,$CUSTOMER_NAME_DBLOOKUP?"
  read SERVICE_TIME # promp for a string that holds the service time
  CUSTOMER_ID_LOOKUP=$($PSQL "SELECT customer_id FROM customers WHERE phone='$CUSTOMER_PHONE'") # look up the customer Id number from customers table
  #insert customerID, ServiceID, time into appointments table
  INSERT_APPOINTMENT_INFO=$($PSQL "INSERT INTO appointments(customer_id, service_id, time) VALUES('$CUSTOMER_ID_LOOKUP','$SERVICE_ID_SELECTED_LOOKUP','$SERVICE_TIME')")
  echo "I have put you down for a cut at $SERVICE_TIME,$CUSTOMER_NAME_DBLOOKUP."
  EXIT
}

EXIT() {
  echo -e "\nThank you for stopping in.\n"
}

MAIN_MENU


I’m working right now but I’ll have a look in a bit and get back to you!

1 Like

Ok, your project passed immediately as soon as I made one change.

Untitled

You can use a sed command to change the timeout value in the highlighted code block in the utils.js file from 1000 to 20000 (as I have done):

sed 's/1000/20000/' -i /home/codeally/project/.freeCodeCamp/test/utils.js

Paste this command into your terminal and then run the tests and your project should pass hopefully.

2 Likes

That worked, thanks so much!!!

I think this should be added in here since both world cup and salon appointment challenge need this solution to pass the challenge