-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/bonus points payments #785
Conversation
… feat/bonus-points-payments
WalkthroughThe changes in this pull request involve enhancements to the handling of GitHub issues and pull requests across multiple components and files. Key updates include the introduction of the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (6)
packages/web/src/pages/Honeypots/VaultDetailsPage/VaultDetailsPage.tsx (1)
The submissions section visibility should consider both issues and PRs
The current implementation in
VaultDetailsPage.tsx
only checks forsavedSubmissions?.length
(GitHub issues) while theVaultSubmissionsSection
component actually fetches and handles both issues and PRs throughuseGHIssues
anduseGHPRs
. The visibility condition should be updated to consider both types of submissions.
packages/web/src/pages/Honeypots/VaultDetailsPage/VaultDetailsPage.tsx
: Update the submissions section visibility check to include bothsavedSubmissions?.length
andpullRequests?.length
🔗 Analysis chain
Line range hint
95-102
: Review submissions section visibility logicThe current filtering logic only checks for the presence of issues (
savedSubmissions.length
). If PRs are also relevant for showing the submissions section, consider updating the condition to account for both.
From the search results, I can see that the
VaultSubmissionsSection
component uses both GitHub issues and PRs through the hooksuseGHIssues
anduseGHPRs
. Let me verify the PR-related logic:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check how submissions section visibility is handled in VaultSubmissionsSection rg -A 5 "VaultSubmissionsSection" --type ts --type tsxLength of output: 82
Script:
#!/bin/bash # Search for submissions-related components and logic rg -g '*.{ts,tsx}' -A 5 "VaultSubmissionsSection|submissions.*section"Length of output: 5502
Script:
#!/bin/bash # Look for submission types or interfaces ast-grep --pattern 'type $_ = { $$$submissions$$$}' ast-grep --pattern 'interface $_ { $$$submissions$$$}'Length of output: 110
Script:
#!/bin/bash # Search for submission-related state or props rg -g '*.{ts,tsx}' "savedSubmissions|pullRequests" -A 3Length of output: 5239
Script:
#!/bin/bash # Check the implementation of useGHPRs hook rg -g '*.{ts,tsx}' "useGHPRs" -B 5 -A 10Length of output: 6025
Script:
#!/bin/bash # Look for PR-related filtering logic ast-grep --pattern 'if ($$$PR$$$) { $$$ }'Length of output: 44
packages/web/src/pages/CommitteeTools/SubmissionsTool/submissionsService.api.ts (1)
254-258
: Rename variable 'issues' to 'prs' for clarityIn the
getGithubPRsFromVault
function, the variableissues
refers to an array of pull requests. Renaming it toprs
will improve code readability and reduce confusion.Apply this diff to update the variable name:
- const issues = res.data.githubPRs.map(mapGithubPRs) as GithubPR[]; + const prs = res.data.githubPRs.map(mapGithubPRs) as GithubPR[]; - return issues.filter((issue) => issue.createdBy === HATS_GITHUB_BOT_ID) ?? []; + return prs.filter((pr) => pr.createdBy === HATS_GITHUB_BOT_ID) ?? [];packages/shared/src/types/payout.ts (1)
71-71
: Consider using an enum for submission status.The string literal type for
bonusSubmissionStatus
could be replaced with an enum to ensure type safety and maintainability.+export enum BonusSubmissionStatus { + COMPLETE = "COMPLETE", + INCOMPLETE = "INCOMPLETE", + PENDING = "PENDING" +} export type GithubPR = { // ... other fields - bonusSubmissionStatus: "COMPLETE" | "INCOMPLETE" | "PENDING"; + bonusSubmissionStatus: BonusSubmissionStatus; // ... other fields };packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/PublicSubmissionCard/components/SplitPointsActions.tsx (1)
77-80
: Improve readability of status check logic.The nested conditions could be simplified for better maintainability.
- if (!isOpenToSubmissions) { - const isCompleted = linkedPRs.some((pr) => pr.bonusSubmissionStatus === "COMPLETE"); - return { can: false, reason: isCompleted ? t("issueAlreadyHaveValidSubmission") : t("oneSubmissionIsBeingReviewed") }; - } + if (isOpenToSubmissions) return { can: true }; + + const hasCompletedSubmission = linkedPRs.some((pr) => pr.bonusSubmissionStatus === "COMPLETE"); + return { + can: false, + reason: hasCompletedSubmission + ? t("issueAlreadyHaveValidSubmission") + : t("oneSubmissionIsBeingReviewed") + };packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx (2)
85-97
: Simplify status text logic.The nested conditional logic for status text could be simplified using a map or switch statement.
+ const getStatusText = (labels: string[], linkedSeverity?: string) => { + const statusMap = { + 'both': `COMPLETE (fix & test) -> ${linkedSeverity}`, + 'fix': `COMPLETE (fix) -> ${linkedSeverity}`, + 'test': `COMPLETE (test) -> ${linkedSeverity}`, + }; + + if (labels.includes('complete-fix') && labels.includes('complete-test')) return statusMap.both; + if (labels.includes('complete-fix')) return statusMap.fix; + if (labels.includes('complete-test')) return statusMap.test; + + return (ghIssue as GithubPR).bonusSubmissionStatus; + }; + - const getText = () => { - const labels = (ghIssue as GithubPR).labels; - if (labels.includes("complete-fix") && labels.includes("complete-test")) { - console.log(ghIssue); - return `COMPLETE (fix & test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; - } else if (labels.includes("complete-fix")) { - return `COMPLETE (fix) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; - } else if (labels.includes("complete-test")) { - return `COMPLETE (test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; - } - - return (ghIssue as GithubPR).bonusSubmissionStatus; - };
112-121
: Optimize repeated type assertions.Multiple type assertions to GithubIssue could be replaced with a single destructured assignment.
- {ghIssue && (ghIssue as GithubIssue)?.validLabels?.length > 0 && ( + {ghIssue && 'validLabels' in ghIssue && ghIssue.validLabels?.length > 0 && ( <> <span>{t("labeledAs")}:</span> <Pill textColor={severityColors[severityIndex ?? 0]} isSeverity - text={parseSeverityName((ghIssue as GithubIssue).validLabels[0])} + text={parseSeverityName(ghIssue.validLabels[0])} /> </> )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (13)
packages/shared/src/types/payout.ts
(3 hunks)packages/web/src/languages/en.json
(1 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutFormPage/PayoutFormPage.tsx
(1 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx
(6 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts
(2 hunks)packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx
(4 hunks)packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionsListPage.tsx
(11 hunks)packages/web/src/pages/CommitteeTools/SubmissionsTool/submissionsService.api.ts
(4 hunks)packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/PublicSubmissionCard/PublicSubmissionCard.tsx
(3 hunks)packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/PublicSubmissionCard/components/SplitPointsActions.tsx
(3 hunks)packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/VaultSubmissionsSection.tsx
(4 hunks)packages/web/src/pages/Honeypots/VaultDetailsPage/VaultDetailsPage.tsx
(2 hunks)packages/web/src/pages/Honeypots/VaultDetailsPage/hooks.ts
(2 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
- packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutFormPage/PayoutFormPage.tsx
- packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionsListPage.tsx
- packages/web/src/languages/en.json
🔇 Additional comments (11)
packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx (1)
1-1
: LGTM: Import changes are well-organized
The new imports for GitHub PR functionality are properly grouped and necessary for the feature implementation.
Also applies to: 11-16
packages/web/src/pages/Honeypots/VaultDetailsPage/VaultDetailsPage.tsx (1)
15-15
: Verify if useGHPRs import is needed
The AI summary mentions that both useGHIssues
and useGHPRs
are part of this change, but only useGHIssues
is imported. If PR functionality is needed, consider adding the useGHPRs
import.
packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts (1)
4-7
: Definition of BONUS_POINTS_CONSTRAINTS is correct.
The bonus point constraints are correctly defined with appropriate values for "fix" and "test" categories.
packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/PublicSubmissionCard/PublicSubmissionCard.tsx (4)
1-1
: Update import statement to include 'GithubPR'
The import statement correctly includes GithubPR
, which is necessary for handling linked pull requests.
13-13
: Add optional 'linkedPRs' prop to 'PublicSubmissionCardProps'
The optional linkedPRs
prop enhances the component to handle linked pull requests.
16-16
: Set default value for 'linkedPRs' parameter
Initializing linkedPRs
with an empty array ensures that the component functions correctly even if no PRs are passed.
47-47
: Pass 'linkedPRs' prop to 'SplitPointsActions' component
Passing linkedPRs
allows SplitPointsActions
to utilize linked PRs for its functionality.
packages/web/src/pages/Honeypots/VaultDetailsPage/hooks.ts (2)
Line range hint 12-19
: Rename 'useSavedSubmissions' to 'useGHIssues' for clarity
Renaming the hook to useGHIssues
more accurately reflects its purpose of fetching GitHub issues.
21-29
: Add 'useGHPRs' hook to fetch GitHub pull requests
The new useGHPRs
hook efficiently retrieves GitHub PRs associated with the vault.
packages/shared/src/types/payout.ts (2)
52-55
: LGTM: New fields enhance issue tracking capabilities.
The additional fields provide necessary metadata for tracking issue lifecycle and severity.
62-73
: Consider adding validation for linked issue references.
While the type structure is good, there's a potential for inconsistency between linkedIssueNumber
and linkedIssue
.
Let's verify the relationship between these fields:
.../components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx
Show resolved
Hide resolved
.../components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx
Outdated
Show resolved
Hide resolved
.../components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx
Outdated
Show resolved
Hide resolved
packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts
Outdated
Show resolved
Hide resolved
packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts
Outdated
Show resolved
Hide resolved
...ages/Honeypots/VaultDetailsPage/Sections/VaultSubmissionsSection/VaultSubmissionsSection.tsx
Show resolved
Hide resolved
...Page/Sections/VaultSubmissionsSection/PublicSubmissionCard/components/SplitPointsActions.tsx
Show resolved
Hide resolved
packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx
Outdated
Show resolved
Hide resolved
packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx
Outdated
Show resolved
Hide resolved
Deploying dapp with Cloudflare Pages
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (5)
packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx (1)
168-171
: Improve type safety and readability of GitHub reference handlingWhile the current implementation works, it can be improved for better maintainability and type safety.
Consider this refactor:
const selectedSubmission = isPayoutCreated ? beneficiaries[index]?.decryptedSubmission ?? beneficiarySubmission! : beneficiarySubmission!; +const getGithubReference = (submission: typeof selectedSubmission) => { + if (!submission) return null; + return ( + getGhIssueFromSubmission(submission, vaultGithubIssues) || + getGhPRFromSubmission(submission, vaultGithubPRs, vaultGithubIssues) + ); +}; <SubmissionCard inPayout submission={selectedSubmission} - ghIssue={ - getGhIssueFromSubmission(selectedSubmission, vaultGithubIssues) || - getGhPRFromSubmission(selectedSubmission, vaultGithubPRs, vaultGithubIssues) - } + ghIssue={getGithubReference(selectedSubmission)} />Benefits:
- Encapsulates GitHub reference logic in a reusable function
- Improves readability by reducing inline complexity
- Adds null check for better type safety
Also applies to: 185-188
packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts (2)
4-7
: Add JSDoc documentation for BONUS_POINTS_CONSTRAINTSConsider adding documentation to explain the purpose and usage of these bonus point percentages.
+/** + * Defines bonus point multipliers for different contribution types + * @property {number} fix - 10% bonus for providing a fix + * @property {number} test - 5% bonus for providing tests + */ const BONUS_POINTS_CONSTRAINTS = { fix: 0.1, // 10% test: 0.05, // 5% };
113-119
: Extract bonus points calculation to a separate functionThe bonus points calculation logic could be more maintainable if extracted to a dedicated function.
+function calculateBonusPoints(ghIssue: GithubPR, mainIssuePoints: string): number { + let totalMultiplier = 0; + + if (ghIssue.labels?.includes("complete-fix")) totalMultiplier += BONUS_POINTS_CONSTRAINTS.fix; + if (ghIssue.labels?.includes("complete-test")) totalMultiplier += BONUS_POINTS_CONSTRAINTS.test; + + return totalMultiplier * +mainIssuePoints; +} - let totalMultiplier = 0; - if (beneficiary.ghIssue?.labels?.includes("complete-fix")) totalMultiplier += BONUS_POINTS_CONSTRAINTS.fix; - if (beneficiary.ghIssue?.labels?.includes("complete-test")) totalMultiplier += BONUS_POINTS_CONSTRAINTS.test; - const complementaryPoints = totalMultiplier * +mainIssuePoints; + const complementaryPoints = calculateBonusPoints(beneficiary.ghIssue as GithubPR, mainIssuePoints);packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx (2)
40-42
: Move type guard to shared utilitiesThe
isGithubPR
type guard could be useful in other components. Consider moving it to a shared utility file.// Create new file: src/utils/github.utils.ts +export const isGithubPR = (issue: GithubIssue | GithubPR): issue is GithubPR => { + return "linkedIssueNumber" in issue; +}; // In SubmissionCard.tsx +import { isGithubPR } from 'utils/github.utils'; -const isGithubPR = (issue: GithubIssue | GithubPR): issue is GithubPR => { - return "linkedIssueNumber" in issue; -};
105-109
: Extract status colors to constantsThe color values should be extracted to named constants for better maintainability.
+const STATUS_COLORS = { + COMPLETE: '#3ee136', + IN_PROGRESS: '#bab441' +} as const; <Pill - textColor={(ghIssue as GithubPR).bonusSubmissionStatus === "COMPLETE" ? "#3ee136" : "#bab441"} + textColor={isGithubPR(ghIssue) && ghIssue.bonusSubmissionStatus === "COMPLETE" + ? STATUS_COLORS.COMPLETE + : STATUS_COLORS.IN_PROGRESS} isSeverity text={getText()} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx
(6 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/utils/autocalculateMultiPayout.ts
(2 hunks)packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx
(4 hunks)
🔇 Additional comments (2)
packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx (2)
123-127
:
Fix PR loading state handling
The PR loading logic should follow the same pattern as issue loading to prevent race conditions and duplicate requests.
Apply this fix:
const loadGhPRs = async () => {
+ if (vaultGithubPRs !== undefined || isLoadingGH) return;
+ setIsLoadingGH(true);
const ghPRs = await getGithubPRsFromVault(vault);
setVaultGithubPRs(ghPRs);
+ setIsLoadingGH(false);
};
-loadGhPRs();
+if (!beneficiarySubmission || !vault) return;
+loadGhPRs();
185-188
: Verify PR and Issue handling behavior
Let's verify the behavior when both PR and Issue references exist for a submission.
✅ Verification successful
Let me generate additional verification scripts to check the implementation details of the functions handling PR and Issue data:
Based on the code analysis, I can now provide a final response:
PR and Issue handling is correctly implemented with clear precedence
The code shows that:
getGhIssueFromSubmission
is checked first, followed bygetGhPRFromSubmission
in the OR condition- PRs are linked to Issues through
linkedIssueNumber
and maintain their relationship - When both exist, the Issue data is preserved while the PR adds complementary information (fix/test status)
The implementation ensures proper handling of both standalone Issues and PRs linked to Issues, with Issues taking precedence in the display hierarchy.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for submissions with both PR and Issue references
# Search for submissions with both PR and Issue references
ast-grep --pattern 'getGhIssueFromSubmission($submission, $_) || getGhPRFromSubmission($submission, $_, $_)'
# Check for any error handling or precedence documentation
rg -i "priority|precedence|order" -g "*.{md,ts,tsx}" -C 2
Length of output: 65916
Script:
#!/bin/bash
# Check implementation of getGhIssueFromSubmission and getGhPRFromSubmission functions
ast-grep --pattern 'function getGhIssueFromSubmission($submission, $_) {
$$$
}'
ast-grep --pattern 'function getGhPRFromSubmission($submission, $_, $_) {
$$$
}'
# Check for any comments or documentation about precedence
rg -i "issue.*pr|pr.*issue" -g "*.{ts,tsx}" -C 2
Length of output: 37204
if (beneficiary.severity.toLowerCase() === "complementary") { | ||
const mainIssueSev = (beneficiary.ghIssue as GithubPR).linkedIssue?.severity; | ||
const mainIssueSevInfo = constraints.find( | ||
(constraint) => constraint.severity.toLowerCase() === mainIssueSev?.toLowerCase() | ||
); | ||
const mainIssuePoints = mainIssueSevInfo?.points ? `${mainIssueSevInfo.points.value.first}` : "1"; | ||
|
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.
Add type guard and null checks for mainIssueSev
The current implementation has potential type safety issues. Consider adding proper type guards and null checks.
- const mainIssueSev = (beneficiary.ghIssue as GithubPR).linkedIssue?.severity;
+ if (!isGithubPR(beneficiary.ghIssue)) {
+ throw new Error('Expected GitHub PR for complementary submission');
+ }
+ const mainIssueSev = beneficiary.ghIssue.linkedIssue?.severity;
+ if (!mainIssueSev) {
+ throw new Error('Linked issue severity is required for complementary submission');
+ }
Where isGithubPR
is defined as:
function isGithubPR(issue: any): issue is GithubPR {
return issue && 'linkedIssue' in issue;
}
const getText = () => { | ||
const labels = (ghIssue as GithubPR).labels; | ||
if (labels.includes("complete-fix") && labels.includes("complete-test")) { | ||
return `COMPLETE (fix & test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | ||
} else if (labels.includes("complete-fix")) { | ||
return `COMPLETE (fix) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | ||
} else if (labels.includes("complete-test")) { | ||
return `COMPLETE (test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | ||
} | ||
|
||
return (ghIssue as GithubPR).bonusSubmissionStatus; | ||
}; |
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.
🛠️ Refactor suggestion
Simplify status text generation and remove type assertions
The status text generation logic can be improved in several ways:
- Remove type assertions using the type guard
- Extract string literals to constants
- Simplify the logic using a map or switch statement
+const LABEL_TYPES = {
+ FIX: 'complete-fix',
+ TEST: 'complete-test'
+} as const;
+
+const STATUS_MESSAGES = {
+ BOTH: (severity: string) => `COMPLETE (fix & test) -> ${severity}`,
+ FIX: (severity: string) => `COMPLETE (fix) -> ${severity}`,
+ TEST: (severity: string) => `COMPLETE (test) -> ${severity}`
+} as const;
+
const getText = () => {
- const labels = (ghIssue as GithubPR).labels;
+ if (!isGithubPR(ghIssue)) return '';
+ const { labels, linkedIssue, bonusSubmissionStatus } = ghIssue;
+ const severity = linkedIssue?.severity;
+
+ if (!severity) return bonusSubmissionStatus;
- if (labels.includes("complete-fix") && labels.includes("complete-test")) {
- return `COMPLETE (fix & test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`;
- } else if (labels.includes("complete-fix")) {
- return `COMPLETE (fix) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`;
- } else if (labels.includes("complete-test")) {
- return `COMPLETE (test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`;
- }
+ const hasFix = labels.includes(LABEL_TYPES.FIX);
+ const hasTest = labels.includes(LABEL_TYPES.TEST);
- return (ghIssue as GithubPR).bonusSubmissionStatus;
+ if (hasFix && hasTest) return STATUS_MESSAGES.BOTH(severity);
+ if (hasFix) return STATUS_MESSAGES.FIX(severity);
+ if (hasTest) return STATUS_MESSAGES.TEST(severity);
+
+ return bonusSubmissionStatus;
};
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const getText = () => { | |
const labels = (ghIssue as GithubPR).labels; | |
if (labels.includes("complete-fix") && labels.includes("complete-test")) { | |
return `COMPLETE (fix & test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | |
} else if (labels.includes("complete-fix")) { | |
return `COMPLETE (fix) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | |
} else if (labels.includes("complete-test")) { | |
return `COMPLETE (test) -> ${(ghIssue as GithubPR).linkedIssue?.severity}`; | |
} | |
return (ghIssue as GithubPR).bonusSubmissionStatus; | |
}; | |
const LABEL_TYPES = { | |
FIX: 'complete-fix', | |
TEST: 'complete-test' | |
} as const; | |
const STATUS_MESSAGES = { | |
BOTH: (severity: string) => `COMPLETE (fix & test) -> ${severity}`, | |
FIX: (severity: string) => `COMPLETE (fix) -> ${severity}`, | |
TEST: (severity: string) => `COMPLETE (test) -> ${severity}` | |
} as const; | |
const getText = () => { | |
if (!isGithubPR(ghIssue)) return ''; | |
const { labels, linkedIssue, bonusSubmissionStatus } = ghIssue; | |
const severity = linkedIssue?.severity; | |
if (!severity) return bonusSubmissionStatus; | |
const hasFix = labels.includes(LABEL_TYPES.FIX); | |
const hasTest = labels.includes(LABEL_TYPES.TEST); | |
if (hasFix && hasTest) return STATUS_MESSAGES.BOTH(severity); | |
if (hasFix) return STATUS_MESSAGES.FIX(severity); | |
if (hasTest) return STATUS_MESSAGES.TEST(severity); | |
return bonusSubmissionStatus; | |
}; |
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation
Chores