Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ubiquibot-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ price-multiplier: 1.5
# enabled: true
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you."
# helpMenu: true
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"
2 changes: 2 additions & 0 deletions src/bindings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
botDelay,
followUpTime,
disqualifyTime,
followUpReviewerTime,
} = await getWideConfig(context);

const publicKey = await getScalarKey(process.env.X25519_PRIVATE_KEY);
Expand Down Expand Up @@ -73,6 +74,7 @@ export const loadConfig = async (context: Context): Promise<BotConfig> => {
: timeRangeForMaxIssueEnabled,
followUpTime: ms(process.env.FOLLOW_UP_TIME || followUpTime),
disqualifyTime: ms(process.env.DISQUALIFY_TIME || disqualifyTime),
followUpReviewerTime: ms(process.env.FOLLOW_UP_REVIEWER_TIME || followUpReviewerTime),
},
supabase: {
url: process.env.SUPABASE_URL ?? "",
Expand Down
1 change: 1 addition & 0 deletions src/configs/ubiquibot-config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const DefaultConfig: MergedConfig = {
permitBaseUrl: "https://pay.ubq.fi",
botDelay: 100, // 100ms
followUpTime: "4 days",
followUpReviewerTime: "3 days",
disqualifyTime: "7 days",
newContributorGreeting: {
enabled: true,
Expand Down
24 changes: 22 additions & 2 deletions src/handlers/wildcard/unassign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getAllIssueComments,
getCommitsOnPullRequest,
getOpenedPullRequestsForAnIssue,
getRequestedReviewerStart,
getReviewRequests,
listAllIssuesForRepo,
removeAssignees,
Expand Down Expand Up @@ -36,7 +37,7 @@ const checkBountyToUnassign = async (issue: Issue): Promise<boolean> => {
const payload = context.payload as Payload;
const logger = getLogger();
const {
unassign: { followUpTime, disqualifyTime },
unassign: { followUpTime, disqualifyTime, followUpReviewerTime },
} = getBotConfig();
logger.info(`Checking the bounty to unassign, issue_number: ${issue.number}`);
const { unassignComment, askUpdate } = GLOBAL_STRINGS;
Expand All @@ -56,7 +57,26 @@ const checkBountyToUnassign = async (issue: Issue): Promise<boolean> => {

if (pullRequest.length > 0) {
const reviewRequests = await getReviewRequests(context, pullRequest[0].number, payload.repository.owner.login, payload.repository.name);
if (!reviewRequests || reviewRequests.users?.length > 0) {
if (!reviewRequests) return false;
if (reviewRequests.users?.length > 0) {
let msg = "";
for (const reviewer of reviewRequests.users) {
//check if reviewer has to be followed up with
const reviewRequestedAt = await getRequestedReviewerStart(reviewer.login);
if (!reviewRequestedAt) continue;

const currDate = new Date();
const expectedDate = new Date(reviewRequestedAt);
expectedDate.setTime(expectedDate.getTime() + followUpReviewerTime);

if (currDate >= expectedDate) {
msg += "@" + reviewer.login + " ";
}
}
if (!msg.includes("@")) return false;
msg += "Can you please review this pull request";
// the below function can also add comment to prs
await addCommentToIssue(msg, pullRequest[0].number);
return false;
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getAllIssueEvents = async () => {
// Fetch issue events
const response = await context.octokit.issues.listEvents({
owner: payload.repository.owner.login,
repo: payload.repository.full_name,
repo: payload.repository.name,
issue_number: payload.issue.number,
per_page: 100,
page: page_number,
Expand Down Expand Up @@ -658,6 +658,16 @@ export const getPullByNumber = async (context: Context, pull_number: number) =>
}
};

export async function getRequestedReviewerStart(user: string) {
const events = await getAllIssueEvents();
if (!events) return null;
const filteredEvents = events.filter((e) => e.event === "review_requested" && e.requested_reviewer?.login === user);
if (!filteredEvents) {
return null;
} else {
return events[events.length - 1].created_at;
}
}
// Get issues assigned to a username
export const getAssignedIssues = async (username: string) => {
const issuesArr = [];
Expand Down
2 changes: 2 additions & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const PayoutConfigSchema = Type.Object({

export const UnassignConfigSchema = Type.Object({
followUpTime: Type.Number(),
followUpReviewerTime: Type.Number(),
disqualifyTime: Type.Number(),
timeRangeForMaxIssue: Type.Number(),
timeRangeForMaxIssueEnabled: Type.Boolean(),
Expand Down Expand Up @@ -241,6 +242,7 @@ export const MergedConfigSchema = Type.Object({
permitBaseUrl: Type.String(),
botDelay: Type.Number(),
followUpTime: Type.String(),
followUpReviewerTime: Type.String(),
disqualifyTime: Type.String(),
});

Expand Down
1 change: 1 addition & 0 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export const getWideConfig = async (context: Context) => {
botDelay: mergedConfigData.botDelay,
followUpTime: mergedConfigData.followUpTime,
disqualifyTime: mergedConfigData.disqualifyTime,
followUpReviewerTime: mergedConfigData.followUpReviewerTime,
};

return configData;
Expand Down