create type swh_language_repartition_signature as (
lang languages,
count bigint,
percent text
);
create or replace function swh_content_language_repartition()
returns setof swh_language_repartition_signature
language plpgsql
as $$
declare
total real;
begin
select count(id) from content_language into total;
return query
select lang, count(id) as count, to_char((100.0 * count(id) / total), '999.99') as percent
from content_language
group by lang
order by count desc;
end
$$;
--
softwareheritage=> select count(*) from content_language;
count
---------
3410460
(1 row)
softwareheritage=> select lang, count, percent from swh_content_language_repartition();
lang | count | percent
---------------------+--------+-----------
python | 555809 | 16.2972
javascript+lasso | 532420 | 15.6114
css+lasso | 338889 | 9.9368
c | 306009 | 8.9727
unknown | 304834 | 8.9382
xml | 254561 | 7.4641
objective-c | 180928 | 5.3051
javascript+php | 160430 | 4.7041
html | 108552 | 3.1829
c++ | 87474 | 2.5649
perl6 | 84078 | 2.4653
prolog | 76807 | 2.2521
genshi | 39621 | 1.1617
rexx | 32574 | .9551
velocity | 27073 | .7938
swig | 24998 | .7330
mason | 22898 | .6714
makefile | 21903 | .6422
bash | 20978 | .6151
perl | 18717 | .5488
xml+django/jinja | 18518 | .5430
restructuredtext | 17932 | .5258
vb.net | 17896 | .5247
ini | 13300 | .3900
scalate-server-page | 12930 | .3791
numpy | 12468 | .3656
actionscript-3 | 11240 | .3296
xml+php | 10121 | .2968
nix | 10113 | .2965
jasmin | 9873 | .2895
erb | 9204 | .2699
django/jinja | 8716 | .2556
objective-j | 7105 | .2083
xml+ruby | 6721 | .1971
s | 5283 | .1549
html+php | 4480 | .1314
coq | 3901 | .1144
ruby | 3760 | .1102
smali | 3732 | .1094
gas | 3558 | .1043
smarty | 2818 | .0826
groff | 2650 | .0777
matlab | 2376 | .0697
lasso | 2202 | .0646
hy | 2154 | .0632
html+django/jinja | 1642 | .0481
diff | 723 | .0212
rhtml | 692 | .0203
cmake | 593 | .0174
xml+lasso | 555 | .0163
xml+smarty | 554 | .0162
dtd | 495 | .0145
php | 478 | .0140
html+genshi | 322 | .0094
logos | 317 | .0093
javascript | 289 | .0085
python-3 | 255 | .0075
debian-sourcelist | 230 | .0067
xslt | 193 | .0057
tex | 165 | .0048
viml | 83 | .0024
html+smarty | 57 | .0017
qbasic | 48 | .0014
html+lasso | 46 | .0013
http | 23 | .0007
groovy | 22 | .0006
aspx-vb | 21 | .0006
xml+velocity | 20 | .0006
julia | 13 | .0004
coffeescript | 6 | .0002
logtalk | 5 | .0001
text-only | 3 | .0001
rebol | 2 | .0001
sql | 2 | .0001
go | 1 | .0000
reg | 1 | .0000
(76 rows)
# sql
softwareheritage=> select count(*) from content_language;
count
---------
3410460
(1 row)
create type swh_content_language_repartition_signature as (
lang languages,
count bigint,
percent text
);
create or replace function swh_content_language_repartition()
returns setof swh_content_language_repartition_signature
language plpgsql
as $$
declare
total real;
begin
select count(id) from content_language into total;
return query
select lang, count(id) as count, to_char((100.0 * count(id) / total), '999.99') as percent
from content_language
group by lang
order by count desc;
end
$$;