Fixed congratulations bot (#5532)
- Fixed bot - Added list of team members
This commit is contained in:
@ -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',
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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',
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
@ -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,
|
||||
|
||||
22
packages/twenty-website/src/shared-utils/listTeamMembers.ts
Normal file
22
packages/twenty-website/src/shared-utils/listTeamMembers.ts
Normal file
@ -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',
|
||||
];
|
||||
Reference in New Issue
Block a user