Changes between Version 2 and Version 3 of TopPerformingComponents


Ignore:
Timestamp:
01/29/26 03:49:07 (10 days ago)
Author:
233051
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TopPerformingComponents

    v2 v3  
    1 = Complex DB Reports (SQL, Stored Procedures, Relational Algebra) =
    2 
    3 ===  Top Performing Components in Highly-Rated Builds ===
     1==  Top Performing Components in Highly-Rated Builds ==
    42
    53Report on which specific components appear most frequently in builds that have received a high average user rating (4.5 stars or higher) within the last year.
     
    86
    97{{{
    10 SELECT
     8CREATE OR REPLACE FUNCTION get_report_top_components()
     9    RETURNS TABLE (
     10                      type TEXT,
     11                      brand TEXT,
     12                      name TEXT,
     13                      usage_count BIGINT,
     14                      avg_build_rating NUMERIC
     15                  )
     16    LANGUAGE sql
     17AS $$
     18SELECT
    1119    c.type,
    1220    c.brand,
     
    1523    AVG(rb.value) AS avg_build_rating
    1624FROM components c
    17 JOIN build_component bc ON c.id = bc.component_id
    18 JOIN build b ON bc.build_id = b.id
    19 JOIN rating_build rb ON b.id = rb.build_id
     25         JOIN build_component bc ON c.id = bc.component_id
     26         JOIN build b ON bc.build_id = b.id
     27         JOIN rating_build rb ON b.id = rb.build_id
    2028WHERE b.created_at >= CURRENT_DATE - INTERVAL '1 year'
    2129GROUP BY c.type, c.brand, c.name
    22 HAVING avg_build_rating >= 4.5
     30HAVING AVG(rb.value) >= 4.5
    2331ORDER BY usage_count DESC, avg_build_rating DESC
    24 LIMIT 20;
     32LIMIT 15;
     33$$;
    2534}}}
    2635