Salon appointment scheduler

Tell us what’s happening:
Describe your issue in detail here.
Not able to clear this subtask:
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

Your code so far

MAIN_MENU(){

if [[ $1 ]]

then

echo -e "\n$1"

fi

Using while-read method

SERVICES=$($PSQL “SELECT * FROM services ORDER BY service_id”)

echo “$SERVICES” | while read SERVICE_ID BAR SERVICE_NAME

do

 echo "$SERVICE_ID) $SERVICE_NAME"

done

read SERVICE_ID_SELECTED

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36

Challenge: Build a Salon Appointment Scheduler

Link to the challenge:

Someone else had a problem with this task. Their script wasn’t finishing. The test runs your script and enters these values at each prompt: 'BadInput', '1', '555-5555', 'Test', 'FakeTime' . If you run your script and enter those values at each input, does the script finish? It needs to finish so the test can see the output.

Thanks a lot for solving this , I had chosen TIME as datatype for column time in appointments. I had to alter that to VARCHAR which allowed ‘11am’ in one of the test case as time input. Earlier TIME datatype did not allow script to finish for string values. Once I changed it to VARCHAR script ran successfully and I got all tick marks :smiley:

2 Likes

I’ve tested my script with the ‘BadInput’, ‘1’, ‘555-5555’, ‘Test’, ‘FakeTime’ sequence. But of course I will get an error for the FakeTime. In the absence of any directions in the project of how to deal with this *like a range/datatype test, I tried redirecting the error message to stderr.txt, like this:
INSERT_APPOINTMENT_RESULT=$($PSQL “INSERT INTO appointments (customer_id, service_id, time) VALUES ($CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’)”) 2> stderr.txt
but the error message will still be displayed on the terminal.
The script still finished and still prints the I’ve put you down for a cut at FakeTime message, but I get no checkmarks for the whole script (which otherwise seems to be perfect!!) when I hit run.
Can I get some help on this please?
Thanks

Can you share your script and a dump of your database @franegrao, I’ll take a look.

Hi Tom,
Thank you for offering to look at the code. I’ve been able to pass the test by changing the datatype of the the time column to varchar instead of time. Feels a bit like cheating to me although it likely was the intention of the person who designed the exercise.
OMG I’m just saw that guarav_t had the same epiphany!!! I guess I hadn’t read or understood his last post after he marked yours as solution.

1 Like