Skip to content

Commit

Permalink
feat: export contributors metric (#1491)
Browse files Browse the repository at this point in the history
Signed-off-by: frank-zsy <[email protected]>
  • Loading branch information
frank-zsy authored Jan 11, 2024
1 parent 2129458 commit c474375
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 85 deletions.
172 changes: 90 additions & 82 deletions notebook/handbook.ipynb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/cron/tasks/monthly_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getRepoActivity, getRepoOpenrank, getUserActivity, getUserOpenrank, get
import { forEveryMonthByConfig, forEveryQuarterByConfig, forEveryYearByConfig, timeDurationConstants } from '../../metrics/basic';
import { getLogger, waitFor } from '../../utils';
import getConfig from '../../config';
import { chaossActiveDatesAndTimes, chaossBusFactor, chaossChangeRequestAge, chaossChangeRequestResolutionDuration, chaossChangeRequestResponseTime, chaossChangeRequestReviews, chaossChangeRequests, chaossChangeRequestsAccepted, chaossCodeChangeLines, chaossInactiveContributors, chaossIssueAge, chaossIssueResolutionDuration, chaossIssueResponseTime, chaossIssuesAndChangeRequestActive, chaossIssuesClosed, chaossIssuesNew, chaossNewContributors, chaossTechnicalFork } from '../../metrics/chaoss';
import { chaossActiveDatesAndTimes, chaossBusFactor, chaossChangeRequestAge, chaossChangeRequestResolutionDuration, chaossChangeRequestResponseTime, chaossChangeRequestReviews, chaossChangeRequests, chaossChangeRequestsAccepted, chaossCodeChangeLines, chaossContributors, chaossInactiveContributors, chaossIssueAge, chaossIssueResolutionDuration, chaossIssueResponseTime, chaossIssuesAndChangeRequestActive, chaossIssuesClosed, chaossIssuesNew, chaossNewContributors, chaossTechnicalFork } from '../../metrics/chaoss';
import { contributorEmailSuffixes, repoIssueComments, repoParticipants, repoStars } from '../../metrics/metrics';
import { getLabelData } from '../../label_data_utils';
import { EOL } from 'os';
Expand Down Expand Up @@ -295,6 +295,8 @@ const task: Task = {
{ targetKey: 'bus_factor_detail', ...arrayFieldOption })]);
// [CHAOSS] issues active
await processMetric(chaossIssuesAndChangeRequestActive, option, getField('count', { targetKey: 'issues_and_change_request_active' }));
// [CHAOSS] contributors
await processMetric(chaossContributors, option, [getField('count', { targetKey: 'contributors' }), getField('detail', { targetKey: 'contributors_detail', ...arrayFieldOption })]);
// [CHAOSS] new contributors
await processMetric(chaossNewContributors, option, [getField('new_contributors'), getField('detail', { targetKey: 'new_contributors_detail', ...arrayFieldOption })]);
// [CHAOSS] inactive contributors
Expand Down
6 changes: 4 additions & 2 deletions src/metrics/chaoss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,14 @@ SELECT
id,
${getTopLevelPlatform(config)},
argMax(name, time) AS name,
${getGroupArrayInsertAtClause(config, { key: 'contributors_count', value: 'count' })}
${getGroupArrayInsertAtClause(config, { key: 'contributors_count', value: 'count' })},
${getGroupArrayInsertAtClause(config, { key: 'detail', noPrecision: true, defaultValue: '[]' })}
FROM
(
SELECT
${getGroupTimeClause(config)},
${getGroupIdClause(config)},
groupArray(DISTINCT(issue_author_login)) AS detail,
COUNT(DISTINCT issue_author_id) AS count
FROM events
WHERE ${whereClauses.join(' AND ')}
Expand All @@ -855,7 +857,7 @@ GROUP BY id, platform
${getOutterOrderAndLimit(config, 'contributors_count')}`;

const result: any = await clickhouse.query(sql);
const ret = processQueryResult(result, ['count']);
const ret = processQueryResult(result, ['count', 'detail']);
return ret;
}

Expand Down

0 comments on commit c474375

Please sign in to comment.