-
Notifications
You must be signed in to change notification settings - Fork 61
Conversation
Just rebuild this due to merge conflicts.
Database backup and schema backup: Archive.zip Will do some due diligence and verify the code to be mostly functional before pushing this through. |
@@ -31,7 +31,7 @@ jobs: | |||
env: | |||
SUPABASE_ACCESS_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_ACCESS_TOKEN || secrets.STAGING_SUPABASE_ACCESS_TOKEN }} | |||
SUPABASE_DB_PASSWORD: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_DB_PASSWORD || secrets.STAGING_SUPABASE_DB_PASSWORD }} | |||
PROJECT_ID: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_PROJECT_ID || secrets.STAGING_SUPABASE_PROJECT_ID }} | |||
SUPABASE_PROJECT_ID: ${{ github.ref == 'refs/heads/main' && secrets.PRODUCTION_SUPABASE_PROJECT_ID || secrets.STAGING_SUPABASE_PROJECT_ID }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update secret
LOG_ENVIRONMENT: "production" | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
X25519_PRIVATE_KEY: "QCDb30UHUkwJAGhLWC-R2N0PiEbd4vQY6qH2Wloybyo" | ||
APP_ID: ${{ secrets.APP_ID }} | ||
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | ||
WEBHOOK_PROXY_URL: ${{ secrets.WEBHOOK_PROXY_URL }} | ||
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} | ||
TEST_ORGANIZATION_NAME: ${{ secrets.TEST_ORGANIZATION_NAME }} | ||
TEST_REPOSITORY_NAME: ${{ secrets.TEST_REPOSITORY_NAME }} | ||
TEST_ADMIN_PAT: ${{ secrets.TEST_ADMIN_PAT }} | ||
TEST_OUTSIDE_COLLABORATOR_PAT: ${{ secrets.TEST_OUTSIDE_COLLABORATOR_PAT }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will probably need to be updated as I think I'll use a new database instance to drop all the old unused triggers/functions/enums etc from the old database.
access: new Access(client), | ||
wallet: new Wallet(client), | ||
user: new User(client), | ||
debit: new Settlement(client), | ||
settlement: new Settlement(client), | ||
label: new Label(client), | ||
super: new Super(client), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty major refactoring where I tried to associate an object to handle every interaction with a table of its namesake.
info: (msg: string, options?: JSON) => string; | ||
debug: (msg: string, options?: JSON) => string; | ||
warn: (msg: string, options?: JSON) => string; | ||
error: (msg: string, options?: JSON) => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we can throw
and return
logger.xxx() without being redundant and copying the string twice.
@@ -1,5 +1,5 @@ | |||
export const GLOBAL_STRINGS = { | |||
unassignComment: "Releasing the bounty back to dev pool because the allocated duration already ended!", | |||
unassignComment: "Releasing the task due to lack of updates.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed 'bounty' from the terminology everywhere to make this more widely appealing.
const sender = payload.sender.login; | ||
const repo = payload.repository; | ||
const permissionLevel = await getUserPermission(sender, context); | ||
const userCan = await isUserAdminOrBillingManager(sender, context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isUserAdminOrBillingManager
was incorrectly implemented. I fixed it.
import { Payload } from "../../../types"; | ||
|
||
export const setAccess = async (body: string) => { | ||
export async function setAccess(body: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traditional function declarations are superior for general use. The only time arrow functions should be used are for tiny functions that are inlined.
// export async function payout(body: string) { | ||
// const { payload: _payload } = getBotContext(); | ||
// const logger = getLogger(); | ||
// if (body != IssueCommentCommands.PAYOUT && body.replace(/`/g, "") != IssueCommentCommands.PAYOUT) { | ||
// logger.info(`Skipping to payout. body: ${body}`); | ||
// return; | ||
// } | ||
|
||
const payload = _payload as Payload; | ||
logger.info(`Received '/payout' command from user: ${payload.sender.login}`); | ||
const issue = (_payload as Payload).issue; | ||
if (!issue) { | ||
logger.info(`Skipping '/payout' because of no issue instance`); | ||
return; | ||
} | ||
// const payload = _payload as Payload; | ||
// logger.info(`Received '/payout' command from user: ${payload.sender.login}`); | ||
// const issue = (_payload as Payload).issue; | ||
// if (!issue) { | ||
// logger.info(`Skipping '/payout' because of no issue instance`); | ||
// return; | ||
// } | ||
|
||
const _labels = payload.issue?.labels; | ||
if (_labels?.some((e) => e.name.toLowerCase() === "Permitted".toLowerCase())) { | ||
logger.info(`Permit already generated for ${payload.issue?.number}`); | ||
return; | ||
} | ||
// const _labels = payload.issue?.labels; | ||
// if (_labels?.some((e) => e.name.toLowerCase() === "Permitted".toLowerCase())) { | ||
// logger.info(`Permit already generated for ${payload.issue?.number}`); | ||
// return; | ||
// } | ||
|
||
const IssueComments = await getAllIssueComments(issue.number); | ||
if (IssueComments.length === 0) { | ||
return `Permit generation failed due to internal GitHub Error`; | ||
} | ||
// const IssueComments = await getAllIssueComments(issue.number); | ||
// if (IssueComments.length === 0) { | ||
// return `Permit generation failed due to internal GitHub Error`; | ||
// } | ||
|
||
const hasPosted = IssueComments.find((e) => e.user.type === "Bot" && e.body.includes("https://pay.ubq.fi?claim")); | ||
if (hasPosted) { | ||
logger.info(`Permit already generated for ${payload.issue?.number}`); | ||
return; | ||
} | ||
// const hasPosted = IssueComments.find((e) => e.user.type === "Bot" && e.body.includes("https://pay.ubq.fi?claim")); | ||
// if (hasPosted) { | ||
// logger.info(`Permit already generated for ${payload.issue?.number}`); | ||
// return; | ||
// } | ||
|
||
// assign function incentivesCalculation to a variable | ||
const calculateIncentives = await incentivesCalculation(); | ||
// // assign function incentivesCalculation to a variable | ||
// const calculateIncentives = await incentivesCalculation(); | ||
|
||
const creatorReward = await calculateIssueCreatorReward(calculateIncentives); | ||
const assigneeReward = await calculateIssueAssigneeReward(calculateIncentives); | ||
const conversationRewards = await calculateIssueConversationReward(calculateIncentives); | ||
const pullRequestReviewersReward = await calculatePullRequestReviewsReward(calculateIncentives); | ||
// const creatorReward = await calculateIssueCreatorReward(calculateIncentives); | ||
// const assigneeReward = await calculateIssueAssigneeReward(calculateIncentives); | ||
// const conversationRewards = await calculateIssueConversationReward(calculateIncentives); | ||
// const pullRequestReviewersReward = await calculateReviewContributorRewards(calculateIncentives); | ||
|
||
return await handleIssueClosed(creatorReward, assigneeReward, conversationRewards, pullRequestReviewersReward, calculateIncentives); | ||
}; | ||
// return await handleIssueClosed(creatorReward, assigneeReward, conversationRewards, pullRequestReviewersReward, calculateIncentives); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure why I left this commented out. I have yet to see this used in production. Perhaps this was implemented incorrectly? Or else I'll need to review later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was never called anywhere.
resultMessage += `@${user}'s access levels are set as follows:\n | ||
Multiplier: ${multiplier}\n | ||
Reason: ${multiplier_reason}\n | ||
Labels: ${JSON.stringify(labels)}\n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Labels are now dynamic. I just listed the array here.
src/handlers/payout/action.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was a bit insane. I think I broke it apart into 14 separate files most of which are over a hundred lines of code long.
src/handlers/payout/shims.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should soon be consolidated elsewhere. This originally acted as my crutch while I was refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were collateral damage from find and replace nuking "bounty" from the codebase.
src/utils/web-assets.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vestige from partially implemented Telegram bot.
Still hacking away at this. Overtaking #644