Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create congratulations bot #5404

Merged
merged 10 commits into from
May 21, 2024
Prev Previous commit
Next Next commit
added team members + removed congratulate for first PR
  • Loading branch information
ady-beraud committed May 16, 2024
commit 7ca48d5a01994d5fb9c440fac20d031063690cef
47 changes: 42 additions & 5 deletions packages/twenty-utils/congratulate-dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,63 @@ const fetchContributorImage = async (username: string) => {
await fetch(apiUrl);
};

const getTeamMembers = async () => {
const org = 'twentyhq';
const team_slug = 'core-team';
const response = await danger.github.api.teams.listMembersInOrg({
org,
team_slug,
});
return response.data.map((user) => user.login);
};

const runCongratulate = async () => {
const pullRequest = danger.github.pr;
const userName = pullRequest.user.login;

const staticExcludedUsers = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up PR could you please cleanup the code and make sure we have one source of truth for that list of users? We don't want to have to modify it in different places

'dependabot',
'cyborch',
'emilienchvt',
'Samox',
'charlesBochet',
'gitstart-app',
'thaisguigon',
'lucasbordeau',
'magrinj',
'Weiko',
'gitstart-twenty',
'bosiraphael',
'martmull',
'FelixMalfait',
'thomtrp',
'Bonapara',
'nimraahmed',
'ady-beraud',
];

const teamMembers = await getTeamMembers();

const excludedUsers = new Set([...staticExcludedUsers, ...teamMembers]);

if (excludedUsers.has(userName)) {
return;
}

const { data: pullRequests } =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be posted on every PR? We want to discard the assignableUsers + a list (same as get-contributor activity / page.tsx - search 'nimraahmed' ; there should be just one source of truth for non-contributors)

await danger.github.api.rest.search.issuesAndPullRequests({
q: `is:pr author:${userName} is:closed repo:twentyhq/twenty`,
per_page: 2,
page: 1,
});

let stats;
const isFirstPR = pullRequests.total_count === 1;

if (!isFirstPR) {
stats = await fetchContributorStats(userName);
} else {
stats = { mergedPRsCount: 1, rank: 52 };
if (isFirstPR) {
return;
}

const stats = await fetchContributorStats(userName);
const contributorUrl = `https://twenty.com/contributors/${userName}`;

// Pre-fetch to trigger cloudflare cache
Expand Down