Skip to content

Commit

Permalink
Update project_company_stats metric to use HLL
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Gryglicki <[email protected]>
  • Loading branch information
lukaszgryglicki committed Jul 31, 2023
1 parent 6471c93 commit 9eb9014
Show file tree
Hide file tree
Showing 2 changed files with 430 additions and 22 deletions.
44 changes: 22 additions & 22 deletions metrics/shared/project_company_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ select
from (
select 'Commits' as metric,
company,
count(distinct sha) as value
round(hll_cardinality(hll_add_agg(hll_hash_text(sha)))) as value
from
company_commits_data
group by
company
union select 'Committers' as metric,
company,
count(distinct actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(actor_id)))) as value
from
company_commits_data
group by
Expand All @@ -96,7 +96,7 @@ from (
when 'ForkEvent' then 'Forkers'
end as metric,
af.company_name as company,
count(distinct e.actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.actor_id)))) as value
from
gha_events e,
gha_actors_affiliations af
Expand All @@ -117,7 +117,7 @@ from (
af.company_name
union select 'Contributors' as metric,
af.company_name as company,
count(distinct e.actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.actor_id)))) as value
from
gha_events e,
gha_actors_affiliations af
Expand All @@ -136,7 +136,7 @@ from (
af.company_name
union select 'Contributions' as metric,
af.company_name as company,
count(distinct e.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.id)))) as value
from
gha_events e,
gha_actors_affiliations af
Expand All @@ -155,7 +155,7 @@ from (
af.company_name
union select 'Repositories' as metric,
af.company_name as company,
count(distinct e.repo_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.repo_id)))) as value
from
gha_events e,
gha_actors_affiliations af
Expand All @@ -170,7 +170,7 @@ from (
af.company_name
union select 'Comments' as metric,
af.company_name as company,
count(distinct c.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.id)))) as value
from
gha_comments c,
gha_actors_affiliations af
Expand All @@ -185,7 +185,7 @@ from (
af.company_name
union select 'Commenters' as metric,
af.company_name as company,
count(distinct c.user_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.user_id)))) as value
from
gha_comments c,
gha_actors_affiliations af
Expand All @@ -200,7 +200,7 @@ from (
af.company_name
union select 'PR reviews' as metric,
af.company_name as company,
count(distinct c.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.id)))) as value
from
gha_reviews c,
gha_actors_affiliations af
Expand All @@ -215,7 +215,7 @@ from (
af.company_name
union select 'Issues' as metric,
af.company_name as company,
count(distinct i.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(i.id)))) as value
from
gha_issues i,
gha_actors_affiliations af
Expand All @@ -231,7 +231,7 @@ from (
af.company_name
union select 'PRs' as metric,
af.company_name as company,
count(distinct i.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(i.id)))) as value
from
gha_issues i,
gha_actors_affiliations af
Expand Down Expand Up @@ -262,12 +262,12 @@ from (
af.company_name
union select 'Commits' as metric,
'All',
count(distinct sha) as value
round(hll_cardinality(hll_add_agg(hll_hash_text(sha)))) as value
from
commits_data
union select 'Committers' as metric,
'All',
count(distinct actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(actor_id)))) as value
from
commits_data
union select case e.type
Expand All @@ -282,7 +282,7 @@ from (
when 'ForkEvent' then 'Forkers'
end as metric,
'All' as company,
count(distinct e.actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.actor_id)))) as value
from
gha_events e
where
Expand All @@ -297,7 +297,7 @@ from (
e.type
union select 'Contributors' as metric,
'All' as company,
count(distinct e.actor_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.actor_id)))) as value
from
gha_events e
where
Expand All @@ -309,7 +309,7 @@ from (
and (lower(e.dup_actor_login) {{exclude_bots}})
union select 'Contributions' as metric,
'All' as company,
count(distinct e.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.id)))) as value
from
gha_events e
where
Expand All @@ -321,39 +321,39 @@ from (
and (lower(e.dup_actor_login) {{exclude_bots}})
union select 'Repositories' as metric,
'All' as company,
count(distinct e.repo_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(e.repo_id)))) as value
from
gha_events e
where
{{period:e.created_at}}
and (lower(e.dup_actor_login) {{exclude_bots}})
union select 'Comments' as metric,
'All' as company,
count(distinct c.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.id)))) as value
from
gha_comments c
where
{{period:c.created_at}}
and (lower(c.dup_user_login) {{exclude_bots}})
union select 'Commenters' as metric,
'All' as company,
count(distinct c.user_id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.user_id)))) as value
from
gha_comments c
where
{{period:c.created_at}}
and (lower(c.dup_user_login) {{exclude_bots}})
union select 'PR reviews' as metric,
'All' as company,
count(distinct c.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(c.id)))) as value
from
gha_reviews c
where
{{period:c.submitted_at}}
and (lower(c.dup_user_login) {{exclude_bots}})
union select 'Issues' as metric,
'All' as company,
count(distinct i.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(i.id)))) as value
from
gha_issues i
where
Expand All @@ -362,7 +362,7 @@ from (
and (lower(i.dup_user_login) {{exclude_bots}})
union select 'PRs' as metric,
'All' as company,
count(distinct i.id) as value
round(hll_cardinality(hll_add_agg(hll_hash_bigint(i.id)))) as value
from
gha_issues i
where
Expand Down
Loading

0 comments on commit 9eb9014

Please sign in to comment.