pingcap / ossinsight-lite

🚧[WIP] Yet another customizable free GitHub stats dashboard based on TiDB Serverless: https://ossinsight-lite.vercel.app, hand-drawn style.
https://ossinsight-lite.vercel.app
Apache License 2.0
383 stars 121 forks source link

Most used language chart is misleading #109

Open 634750802 opened 1 year ago

634750802 commented 1 year ago

https://github.com/pingcap/ossinsight-lite/blob/main/collections/contribution-most-used-languages/template.sql

WITH languages AS (
    SELECT language, COUNT(*) as count
    FROM pull_requests pr
    JOIN repos r on pr.repo_id = r.id
    WHERE pr.user_id = (SELECT id FROM curr_user LIMIT 1) AND r.language IS NOT NULL
    GROUP BY language
    ORDER BY count DESC
), total AS (
    SELECT SUM(count) as total FROM languages
)
SELECT language, count, ROUND(count * 100.0 / total, 2) as precentage
FROM languages, total
ORDER BY count DESC

In fact, this is the contributed repo's main language but not user pushed language of code.