Hello,
I am progressing through the Relational Database (Beta) certification and at this point I am stuck at the Salon Appointment Scheduler project. For some reason that I can not understand, the tests in Coad Road fail but the desired behavior of the program is achieved. Can you tell me what’s wrong up until this point? I am stuck at point ’ You should display a numbered list of the services you offer before the first prompt for input, each with the format #) <service> . For example, 1) cut , where 1 is the service_id’
Here’s the code so far:
#!/bin/bash
PSQL="psql -X --username=freecodecamp --dbname=salon --tuples-only -c"
echo -e "\n~~~~~ MY SALON ~~~~~\n"
SERVICE_SELECTION_MENU() {
if [[ $1 ]]
then
echo -e "\n$1"
fi
SERVICES=$($PSQL "SELECT service_id, name FROM services ORDER BY service_id")
echo "$SERVICES" | while read SERVICE_ID BAR SERVICE_NAME
do
echo "$SERVICE_ID) $SERVICE_NAME"
done
GET_DETAILS
}
GET_DETAILS() {
read SERVICE_ID_SELECTED
if [[ ! $SERVICE_ID_SELECTED =~ ^[0-9]+$ ]]
then
SERVICE_SELECTION_MENU "I could not find that service. What would you like today?"
else
SERVICE_SELECTED=$($PSQL "SELECT service_id FROM services WHERE service_id=$SERVICE_ID_SELECTED")
if [[ -z $SERVICE_SELECTED ]]
then
SERVICE_SELECTION_MENU "I could not find that service. What would you like today?"
fi
fi
}
SERVICE_SELECTION_MENU "Welcome to My Salon, how can I help you?\n"
I was able to resolve a similar issue by using code like this. I would give that a quick try - let us know if it works. If not, I will see if I can run your code and get it to pass. There’s been a few issues involving that test, so it will probably need to be changes to be more lenient.
Hello,
Tried the proposed solution but the same result happened - the output and behavior match the example.txt, but the tests fail to pass. Can you please help? Thank you!
Hello,
Thanks for taking the time to look into this.
I ran it once again and no results. What I find weird is that if I comment out the GET_DETAILS function call from within SERVICE_SELECTION_MENU function, it passes the test with the lists of services (as seen in screenshot). Really confuses me.
Also attached the dump of the database. Hope there’s a solution for this because I really enjoyed the course so far.
Thank you!
Sorry for the delay here @VictorB1996, this must have gotten lost in my notifications. Were you able to get anything figured out?
One of the user stories changed since this was posted after we found this bug. New user story: You should have at least three rows in your services table for the different services you offer, one with a service_id of 1
Basically, you just need to make sure one of your services has a service_id of 1. The tests input 1, so it doesn’t work unless that exists.