| 317 | | u.full_name, |
| 318 | | u.email, |
| 319 | | a.city, |
| 320 | | a.country, |
| 321 | | a.price_per_hour, |
| 322 | | at2.name, |
| 323 | | coalesce(sum(t.stripe_price),0) as earnings, |
| 324 | | ( |
| 325 | | select |
| 326 | | count(o2.id) |
| 327 | | from offers o2 |
| 328 | | where o2.artist_id = a.user_id |
| 329 | | ) as num_offers, |
| 330 | | ( |
| 331 | | (5 * (select |
| 332 | | count(re.artist_id) |
| 333 | | from reviews re |
| 334 | | where |
| 335 | | re.rating = 5 and |
| 336 | | re.artist_id = a.user_id) + |
| 337 | | 4 * (select |
| 338 | | count(re.artist_id) |
| 339 | | from reviews re |
| 340 | | where |
| 341 | | re.rating = 4 and |
| 342 | | re.artist_id = a.user_id) + |
| 343 | | 3 * (select |
| 344 | | count(re.artist_id) |
| 345 | | from reviews re |
| 346 | | where |
| 347 | | re.rating = 3 and |
| 348 | | re.artist_id = a.user_id) + |
| 349 | | 2 * (select |
| 350 | | count(re.artist_id) |
| 351 | | from reviews re |
| 352 | | where |
| 353 | | re.rating = 2 and |
| 354 | | re.artist_id = a.user_id) + |
| 355 | | 1 * (select |
| 356 | | count(re.artist_id) |
| 357 | | from reviews re |
| 358 | | where |
| 359 | | re.rating = 1 and |
| 360 | | re.artist_id = a.user_id)) / |
| 361 | | ((select |
| 362 | | count(re.artist_id) |
| 363 | | from reviews re |
| 364 | | where |
| 365 | | re.artist_id = a.user_id)) |
| 366 | | ) |
| 367 | | as average_rating |
| | 317 | u."name" , |
| | 318 | u.email, |
| | 319 | a.city, |
| | 320 | a.country, |
| | 321 | a.price_per_hour, |
| | 322 | at2.name, |
| | 323 | coalesce(sum(t.stripe_price),0) as earnings, |
| | 324 | ( |
| | 325 | select |
| | 326 | count(o2.id) |
| | 327 | from offers o2 |
| | 328 | where o2.artist_id = a.user_id |
| | 329 | ) as num_offers, |
| | 330 | ( |
| | 331 | (5 * (select |
| | 332 | count(re.artist_id) |
| | 333 | from reviews re |
| | 334 | where |
| | 335 | re.rating = 5 and |
| | 336 | re.artist_id = a.user_id) + |
| | 337 | 4 * (select |
| | 338 | count(re.artist_id) |
| | 339 | from reviews re |
| | 340 | where |
| | 341 | re.rating = 4 and |
| | 342 | re.artist_id = a.user_id) + |
| | 343 | 3 * (select |
| | 344 | count(re.artist_id) |
| | 345 | from reviews re |
| | 346 | where |
| | 347 | re.rating = 3 and |
| | 348 | re.artist_id = a.user_id) + |
| | 349 | 2 * (select |
| | 350 | count(re.artist_id) |
| | 351 | from reviews re |
| | 352 | where |
| | 353 | re.rating = 2 and |
| | 354 | re.artist_id = a.user_id) + |
| | 355 | 1 * (select |
| | 356 | count(re.artist_id) |
| | 357 | from reviews re |
| | 358 | where |
| | 359 | re.rating = 1 and |
| | 360 | re.artist_id = a.user_id)) / |
| | 361 | ((select |
| | 362 | case when count(re.artist_id) > 0 |
| | 363 | then count(re.artist_id)::float |
| | 364 | else 1 |
| | 365 | end |
| | 366 | from reviews re |
| | 367 | where |
| | 368 | re.artist_id = a.user_id)) |
| | 369 | ) |
| | 370 | as average_rating |