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);
|
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 runCongratulate = async () => {
|
||||||
const pullRequest = danger.github.pr;
|
const pullRequest = danger.github.pr;
|
||||||
const userName = pullRequest.user.login;
|
const userName = pullRequest.user.login;
|
||||||
|
const teamMembers = [
|
||||||
const staticExcludedUsers = [
|
|
||||||
'dependabot',
|
'dependabot',
|
||||||
'cyborch',
|
'cyborch',
|
||||||
'emilienchvt',
|
'emilienchvt',
|
||||||
@ -56,13 +45,11 @@ const runCongratulate = async () => {
|
|||||||
'Bonapara',
|
'Bonapara',
|
||||||
'nimraahmed',
|
'nimraahmed',
|
||||||
'ady-beraud',
|
'ady-beraud',
|
||||||
|
'Freebios',
|
||||||
|
'ijreilly',
|
||||||
];
|
];
|
||||||
|
|
||||||
const teamMembers = await getTeamMembers();
|
if (teamMembers.includes(userName)) {
|
||||||
|
|
||||||
const excludedUsers = new Set([...staticExcludedUsers, ...teamMembers]);
|
|
||||||
|
|
||||||
if (excludedUsers.has(userName)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { Background } from '@/app/_components/oss-friends/Background';
|
|||||||
import { ContentContainer } from '@/app/_components/oss-friends/ContentContainer';
|
import { ContentContainer } from '@/app/_components/oss-friends/ContentContainer';
|
||||||
import { findAll } from '@/database/database';
|
import { findAll } from '@/database/database';
|
||||||
import { pullRequestModel, userModel } from '@/database/model';
|
import { pullRequestModel, userModel } from '@/database/model';
|
||||||
|
import { TWENTY_TEAM_MEMBERS } from '@/shared-utils/listTeamMembers';
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: 'Twenty - Contributors',
|
title: 'Twenty - Contributors',
|
||||||
@ -30,17 +31,7 @@ const Contributors = async () => {
|
|||||||
|
|
||||||
const fitlerContributors = contributors
|
const fitlerContributors = contributors
|
||||||
.filter((contributor) => contributor.isEmployee === '0')
|
.filter((contributor) => contributor.isEmployee === '0')
|
||||||
.filter(
|
.filter((contributor) => !TWENTY_TEAM_MEMBERS.includes(contributor.id))
|
||||||
(contributor) =>
|
|
||||||
![
|
|
||||||
'dependabot',
|
|
||||||
'cyborch',
|
|
||||||
'emilienchvt',
|
|
||||||
'Samox',
|
|
||||||
'nimraahmed',
|
|
||||||
'gitstart-app',
|
|
||||||
].includes(contributor.id),
|
|
||||||
)
|
|
||||||
.map((contributor) => {
|
.map((contributor) => {
|
||||||
contributor.pullRequestCount = pullRequestByAuthor[contributor.id] || 0;
|
contributor.pullRequestCount = pullRequestByAuthor[contributor.id] || 0;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { findAll } from '@/database/database';
|
import { findAll } from '@/database/database';
|
||||||
import { pullRequestModel, userModel } from '@/database/model';
|
import { pullRequestModel, userModel } from '@/database/model';
|
||||||
|
import { TWENTY_TEAM_MEMBERS } from '@/shared-utils/listTeamMembers';
|
||||||
|
|
||||||
export const getContributorActivity = async (username: string) => {
|
export const getContributorActivity = async (username: string) => {
|
||||||
const contributors = await findAll(userModel);
|
const contributors = await findAll(userModel);
|
||||||
@ -15,28 +16,7 @@ export const getContributorActivity = async (username: string) => {
|
|||||||
const pullRequests = await findAll(pullRequestModel);
|
const pullRequests = await findAll(pullRequestModel);
|
||||||
const mergedPullRequests = pullRequests
|
const mergedPullRequests = pullRequests
|
||||||
.filter((pr) => pr.mergedAt !== null)
|
.filter((pr) => pr.mergedAt !== null)
|
||||||
.filter(
|
.filter((pr) => !TWENTY_TEAM_MEMBERS.includes(pr.authorId));
|
||||||
(pr) =>
|
|
||||||
![
|
|
||||||
'dependabot',
|
|
||||||
'cyborch',
|
|
||||||
'emilienchvt',
|
|
||||||
'Samox',
|
|
||||||
'charlesBochet',
|
|
||||||
'gitstart-app',
|
|
||||||
'thaisguigon',
|
|
||||||
'lucasbordeau',
|
|
||||||
'magrinj',
|
|
||||||
'Weiko',
|
|
||||||
'gitstart-twenty',
|
|
||||||
'bosiraphael',
|
|
||||||
'martmull',
|
|
||||||
'FelixMalfait',
|
|
||||||
'thomtrp',
|
|
||||||
'Bonapara',
|
|
||||||
'nimraahmed',
|
|
||||||
].includes(pr.authorId),
|
|
||||||
);
|
|
||||||
|
|
||||||
const contributorPullRequests = pullRequests.filter(
|
const contributorPullRequests = pullRequests.filter(
|
||||||
(pr) => pr.authorId === contributor.id,
|
(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