Changes between Version 23 and Version 24 of AdvancedReports


Ignore:
Timestamp:
03/10/22 19:09:39 (2 years ago)
Author:
191151
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v23 v24  
    315315{{{#!sql
    316316select
    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
    368371from users u
    369372join artists a on
    370         a.user_id = u.id
     373        a.user_id = u.id
    371374join artist_types at2 on
    372         at2.id = a.artist_type_id
     375        at2.id = a.artist_type_id
    373376left join reviews r on
    374         r.artist_id = a.user_id
     377        r.artist_id = a.user_id
    375378left join offers o on
    376         o.artist_id = a.user_id
     379        o.artist_id = a.user_id
    377380left join transactions t on
    378         t.offer_id = o.id
     381        t.offer_id = o.id
    379382group by a.user_id, u.id, at2.id
    380383order by
    381         average_rating desc,
    382         earnings desc,
    383         num_offers asc;
     384        average_rating desc,
     385        earnings desc,
     386        num_offers asc;
    384387}}}
    385388