Changes between Version 13 and Version 14 of AdvancedReports


Ignore:
Timestamp:
08/05/26 11:02:56 (21 hours ago)
Author:
231136
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v13 v14  
    215215        COALESCE(COUNT(l.timestamp),0) AS listen_count
    216216    FROM artists a
    217     JOIN performs_at pa ON pa.artist_id=a.user_id
    218     JOIN musical_entities me ON me.released_by=pa.artist_id
     217    LEFT JOIN contributions c ON c.artist_id = a.user_id
     218    LEFT JOIN songs s ON s.id = c.musical_entity_id
    219219    LEFT JOIN listens l ON l.song_id=me.id
    220220    GROUP BY a.user_id
     
    228228    FROM events e
    229229    JOIN performs_at pa ON pa.event_id=e.event_id
    230     JOIN followersCount fc ON fc.user_id=pa.artist_id
     230    JOIN followersCount fc ON fc.user_id = pa.artist_id AND fc.event_id = e.event_id
    231231    JOIN listensCount lc ON lc.user_id=fc.user_id
    232232    JOIN users u ON u.user_id=lc.user_id
     
    262262(
    263263  (
    264     (artists a ⨝ (a.user_id = pa.artist_id) performs_at pa)
    265     ⨝ (pa.artist_id = me.released_by) musical_entities me
     264    (artists a ⟕ (a.user_id = c.artist_id) contributions c)
     265    ⟕ (pa.artist_id = me.released_by) songs s
    266266  )
    267267  ⟕ (me.id = l.song_id) listens l
     
    276276        ⨝ (e.event_id = pa.event_id) performs_at pa
    277277      )
    278       ⨝ (pa.artist_id = fc.user_id) FollowersCount fc
    279     )
    280     ⨝ ListensCount lc
    281   )
    282   ⨝ users u
     278      ⨝ (pa.artist_id = fc.user_id ∧ e.event_id = fc.event_id) FollowersCount fc
     279    )
     280    ⨝ (fc.user_id = lc.user_id) ListensCount lc
     281  )
     282  ⨝ (lc.user_id = u.user_id) users u
    283283)
    284284
     
    328328    SELECT
    329329        EXTRACT(MONTH FROM l.timestamp) AS month,
    330         a.user_id,COUNT(l.timestamp)AS count
     330        a.user_id,
     331        COUNT(l.timestamp)AS count
    331332    FROM listens l
    332333    JOIN one_year oy ON l.timestamp>=oy.year_start AND l.timestamp<=oy.year_end
    333     JOIN musical_entities me ON l.song_id=me.id
    334     JOIN artists a ON a.user_id=me.released_by
     334    JOIN contributions c ON c.musical_entity_id = l.song_id
     335    JOIN artists a ON a.user_id=c.artist_id
    335336    GROUP BY EXTRACT(MONTH FROM l.timestamp),a.user_id
    336337),
     
    391392      ⨝ (l.timestamp ≥ oy.year_start ∧ l.timestamp ≤ oy.year_end) OneYear oy
    392393    )
    393     ⨝ (l.song_id = me.id) musical_entities me
    394   )
    395   ⨝ (me.released_by = a.user_id) artists a
     394    ⨝ (l.song_id = c.musical_entity_id) contributions c
     395  )
     396  ⨝ (c.artist_id = a.user_id) artists a
    396397)
    397398
     
    462463    FROM listens l
    463464    JOIN one_month om ON l.timestamp between om.prev_period_start AND om.prev_period_end
    464     JOIN musical_entities me ON l.song_id = me.id
    465     RIGHT JOIN artists a ON a.user_id = me.released_by
     465    JOIN contributions c ON c.musical_entity_id = l.song_id
     466    RIGHT JOIN artists a ON a.user_id = c.artist_id
    466467    GROUP BY a.user_id
    467468    HAVING count(l.timestamp) > 0
     
    473474    FROM listens l
    474475    JOIN one_month om ON l.timestamp between om.this_period_start AND om.this_period_end
    475     JOIN musical_entities me ON l.song_id = me.id
    476     RIGHT JOIN artists a ON a.user_id = me.released_by
     476    JOIN contributions c ON c.musical_entity_id = l.song_id
     477    RIGHT JOIN artists a ON a.user_id = c.artist_id
    477478    GROUP BY a.user_id
    478479),
     
    524525        OneMonth om
    525526      )
    526       ⨝ (l.song_id = me.id) musical_entities me
    527     )
    528     ⟖ (me.released_by = a.user_id) artists a
     527      ⨝ (l.song_id = c.musical_entity_id) contributions c
     528    )
     529    ⟖ (c.artist_id = a.user_id) artists a
    529530  )
    530531)
     
    540541      OneMonth om
    541542    )
    542     ⨝ (l.song_id = me.id) musical_entities me
    543   )
    544   ⟖ (me.released_by = a.user_id) artists a
     543    ⨝ (l.song_id = c.musical_entity_id) contributions c
     544  )
     545  ⟖ (c.artist_id = a.user_id) artists a
    545546)
    546547