Changes between Version 21 and Version 22 of AdvancedReports


Ignore:
Timestamp:
03/10/22 19:01:18 (2 years ago)
Author:
191215
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v21 v22  
    178178left join users us on
    179179        us.id = ar.user_id;
     180}}}
     181
     182== Детален приказ на статистики за артисти кои имаат менаџери
     183{{{#!sql
     184select
     185        m.user_id as manager_id,
     186        a.user_id as artists_id,
     187        u.name,
     188        a.city,
     189        a.country,
     190        at2.name as artist_type,
     191        (
     192                select
     193                        count(distinct asg.genre_id)
     194                from artist_sings_genres asg
     195                where asg.artist_id = a.user_id
     196        ) as num_genres,
     197        (
     198                select
     199                        count(*)
     200                from offers o
     201                where o.artist_id = a.user_id
     202        ) as num_offers,
     203        (
     204                select
     205                        count(*)
     206                from offers o
     207                join transactions t on t.offer_id = o.id
     208                where o.artist_id = a.user_id
     209        ) as num_completed_offers,
     210        (
     211                select
     212                        count(distinct e.id)
     213                from offers o
     214                join events e on e.id = o.event_id and
     215                                                e.event_date < now()
     216                where o.artist_id = a.user_id
     217        ) as num_completed_events,
     218        (
     219                select
     220                        count(distinct e.id)
     221                from offers o
     222                join events e on e.id = o.event_id and
     223                                                e.event_date > now()
     224                where o.artist_id = a.user_id
     225        ) as num_upcoming_events,
     226        (
     227                select
     228                        count(*) filter(where r.rating > 3)
     229                from reviews r
     230                where r.artist_id = a.user_id
     231        ) as num_positive_reviews,
     232        (
     233                select
     234                        count(*) filter(where r.rating <= 3)
     235                from reviews r
     236                where r.artist_id = a.user_id
     237        ) as num_negative_reviews,
     238        (
     239                select
     240                        count(distinct e.organizer_id)
     241                from offers o
     242                join events e on e.id = o.event_id
     243                where o.artist_id = a.user_id
     244        ) as num_organizers,
     245        (
     246                select
     247                        count(t.id)
     248                from offers o
     249                left join transactions t on t.offer_id = o.id
     250                where o.artist_id = a.user_id
     251        ) as num_transactions
     252from managers m
     253join artists as a on
     254                                        a.manager_id = m.user_id and
     255                                        a.admin_verified_at is not null
     256join users as u on u.id = a.user_id                                     
     257join artist_types at2 on at2.id = a.artist_type_id
    180258}}}
    181259