Skip to content

Commit

Permalink
Fixed congratulations bot (twentyhq#5532)
Browse files Browse the repository at this point in the history
- Fixed bot
- Added list of team members
  • Loading branch information
ady-beraud authored May 22, 2024
1 parent 40bd42e commit 4b25181
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 50 deletions.
21 changes: 4 additions & 17 deletions packages/twenty-utils/congratulate-dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@ 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 = [
const teamMembers = [
'dependabot',
'cyborch',
'emilienchvt',
Expand All @@ -56,13 +45,11 @@ const runCongratulate = async () => {
'Bonapara',
'nimraahmed',
'ady-beraud',
'Freebios',
'ijreilly',
];

const teamMembers = await getTeamMembers();

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

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

Expand Down
13 changes: 2 additions & 11 deletions packages/twenty-website/src/app/contributors/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Background } from '@/app/_components/oss-friends/Background';
import { ContentContainer } from '@/app/_components/oss-friends/ContentContainer';
import { findAll } from '@/database/database';
import { pullRequestModel, userModel } from '@/database/model';
import { TWENTY_TEAM_MEMBERS } from '@/shared-utils/listTeamMembers';

export const metadata = {
title: 'Twenty - Contributors',
Expand All @@ -30,17 +31,7 @@ const Contributors = async () => {

const fitlerContributors = contributors
.filter((contributor) => contributor.isEmployee === '0')
.filter(
(contributor) =>
![
'dependabot',
'cyborch',
'emilienchvt',
'Samox',
'nimraahmed',
'gitstart-app',
].includes(contributor.id),
)
.filter((contributor) => !TWENTY_TEAM_MEMBERS.includes(contributor.id))
.map((contributor) => {
contributor.pullRequestCount = pullRequestByAuthor[contributor.id] || 0;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { findAll } from '@/database/database';
import { pullRequestModel, userModel } from '@/database/model';
import { TWENTY_TEAM_MEMBERS } from '@/shared-utils/listTeamMembers';

export const getContributorActivity = async (username: string) => {
const contributors = await findAll(userModel);
Expand All @@ -15,28 +16,7 @@ export const getContributorActivity = async (username: string) => {
const pullRequests = await findAll(pullRequestModel);
const mergedPullRequests = pullRequests
.filter((pr) => pr.mergedAt !== null)
.filter(
(pr) =>
![
'dependabot',
'cyborch',
'emilienchvt',
'Samox',
'charlesBochet',
'gitstart-app',
'thaisguigon',
'lucasbordeau',
'magrinj',
'Weiko',
'gitstart-twenty',
'bosiraphael',
'martmull',
'FelixMalfait',
'thomtrp',
'Bonapara',
'nimraahmed',
].includes(pr.authorId),
);
.filter((pr) => !TWENTY_TEAM_MEMBERS.includes(pr.authorId));

const contributorPullRequests = pullRequests.filter(
(pr) => pr.authorId === contributor.id,
Expand Down
22 changes: 22 additions & 0 deletions packages/twenty-website/src/shared-utils/listTeamMembers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const TWENTY_TEAM_MEMBERS = [
'dependabot',
'cyborch',
'emilienchvt',
'Samox',
'charlesBochet',
'gitstart-app',
'thaisguigon',
'lucasbordeau',
'magrinj',
'Weiko',
'gitstart-twenty',
'bosiraphael',
'martmull',
'FelixMalfait',
'thomtrp',
'Bonapara',
'nimraahmed',
'ady-beraud',
'Freebios',
'ijreilly',
];

0 comments on commit 4b25181

Please sign in to comment.