| | 1 | = UseCase11 - Leave a !VetClinic review |
| | 2 | ** Initiating actor: Client ** |
| | 3 | == Description |
| | 4 | A logged-in client can submit a review about a vet clinic in the system. A client can review a vet clinic only if the client has at least one completed (DONE) appointment at that clinic for at least one of their pets(he is the current owner). |
| | 5 | == Scenario |
| | 6 | 1. Client opens the clinics page. |
| | 7 | {{{ |
| | 8 | SELECT clinic_id, name, city, address |
| | 9 | FROM vet_clinics |
| | 10 | WHERE clinic_id = $1; |
| | 11 | }}} |
| | 12 | 2. Clicks the "Leave review" button. |
| | 13 | 3. Client enters rating, comment and submits. |
| | 14 | {{{ |
| | 15 | BEGIN; |
| | 16 | |
| | 17 | INSERT INTO reviews (reviewer_id, rating, comment, created_at) |
| | 18 | VALUES ($1, $2, $3, NOW()) |
| | 19 | RETURNING review_id; |
| | 20 | |
| | 21 | INSERT INTO clinic_reviews (review_id, target_clinic_id) |
| | 22 | VALUES ($4, $5); |
| | 23 | |
| | 24 | COMMIT; |
| | 25 | }}} |