Changes between Version 11 and Version 12 of AdvancedReports


Ignore:
Timestamp:
02/02/26 20:43:05 (4 days ago)
Author:
231136
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v11 v12  
    204204
    205205WITH followersCount AS (
    206     SELECT a.user_id AS artist,
     206    SELECT a.user_id,
    207207        pa.event_id,
    208208        COALESCE(COUNT(f.follower),0) AS followers
     
    214214listensCount AS (
    215215    SELECT
    216         a.user_id AS artist,
     216        a.user_id,
    217217        COALESCE(COUNT(l.timestamp),0) AS listen_count
    218218    FROM artists a
     
    230230    FROM events e
    231231    JOIN performs_at pa ON pa.event_id=e.event_id
    232     JOIN followersCount fc ON fc.artist=pa.artist_id
    233     JOIN listensCount lc ON lc.artist=fc.artist
    234     JOIN users u ON u.user_id=lc.artist
     232    JOIN followersCount fc ON fc.user_id=pa.artist_id
     233    JOIN listensCount lc ON lc.user_id=fc.user_id
     234    JOIN users u ON u.user_id=lc.user_id
    235235    WHERE not exists(
    236236        SELECT 1
    237237        FROM artists a
    238         JOIN followersCount fc1 ON a.user_id=fc1.artist
    239         JOIN listensCount lc1 ON lc1.artist=fc1.artist
     238        JOIN followersCount fc1 ON a.user_id=fc1.user_id
     239        JOIN listensCount lc1 ON lc1.user_id=fc1.user_id
    240240        WHERE fc.event_id=fc1.event_id
    241241            AND (fc.followers<fc1.followers
    242242                OR (fc.followers=fc1.followers AND lc.listen_count<lc1.listen_count)
    243                 OR (fc.followers=fc1.followers AND lc.listen_count=lc1.listen_count AND lc.artist<lc1.artist)
     243                OR (fc.followers=fc1.followers AND lc.listen_count=lc1.listen_count AND lc.user_id<lc1.user_id)
    244244                )
    245245);
     246
    246247}}}
    247248
    248249==== Релациона Алгебра
     250
    249251{{{
    250252FollowersCount <-
    251 γ artist := a.user_id,
     253γ user_id := a.user_id,
    252254  event_id := pa.event_id;
    253255  followers := COUNT(f.follower)
     
    258260
    259261ListensCount <-
    260 γ artist := a.user_id;
     262γ user_id := a.user_id;
    261263  listen_count := COUNT(l.timestamp)
    262264(
     
    276278        ⨝ (e.event_id = pa.event_id) performs_at pa
    277279      )
    278       ⨝ (pa.artist_id = fc.artist) FollowersCount fc
    279     )
    280     ⨝ (fc.artist = lc.artist) ListensCount lc
    281   )
    282   ⨝ (lc.artist = u.user_id) users u
     280      ⨝ (pa.artist_id = fc.user_id) FollowersCount fc
     281    )
     282    ⨝ ListensCount lc
     283  )
     284  ⨝ users u
    283285)
    284286
     
    289291    fc.followers < fc1.followers
    290292    ∨ (fc.followers = fc1.followers ∧ lc.listen_count < lc1.listen_count)
    291     ∨ (fc.followers = fc1.followers ∧ lc.listen_count = lc1.listen_count ∧ lc.artist < lc1.artist)
     293    ∨ (fc.followers = fc1.followers ∧ lc.listen_count = lc1.listen_count ∧ lc.user_id < lc1.user_id)
    292294  )
    293295(
     
    300302BaseResult − π attributes(BaseResult)
    301303(
    302   BaseResult ⨝ (BaseResult.artist = ToRemove.artist) ToRemove
     304  BaseResult ⨝ ToRemove
    303305)
    304306