Skip to content

Commit

Permalink
chore: remove multiplier logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Jun 18, 2024
1 parent 0d41663 commit 0d67eb6
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 104 deletions.
26 changes: 0 additions & 26 deletions src/handlers/shared/analytics.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/handlers/shared/get-multiplier-info.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/handlers/shared/get-user-multiplier.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { isParentIssue, getAvailableOpenedPullRequests, getAssignedIssues, addAs
import { calculateDurations } from "../../utils/shared";
import { checkTaskStale } from "./check-task-stale";
import { generateAssignmentComment } from "./generate-assignment-comment";
import { getMultiplierInfoToDisplay } from "./get-multiplier-info";
import structuredMetadata from "./structured-metadata";
import { assignTableComment } from "./table";

Expand Down Expand Up @@ -88,15 +87,11 @@ export async function start(context: Context, issue: Context["payload"]["issue"]
}

const isTaskStale = checkTaskStale(taskStaleTimeoutDuration, issue.created_at);
const { multiplierAmount, multiplierReason, totalPriceOfTask } = await getMultiplierInfoToDisplay(context, issue.labels);

await addCommentToIssue(
context,
[
assignTableComment({
multiplierAmount,
multiplierReason,
totalPriceOfTask,
isTaskStale,
daysElapsedSinceTaskCreation: assignmentComment.daysElapsedSinceTaskCreation,
taskDeadline: assignmentComment.deadline,
Expand Down
13 changes: 3 additions & 10 deletions src/handlers/shared/table.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export function assignTableComment({
taskDeadline,
registeredWallet,
multiplierAmount,
multiplierReason,
totalPriceOfTask,
isTaskStale,
daysElapsedSinceTaskCreation,
}: AssignTableCommentParams) {
Expand All @@ -25,18 +22,14 @@ export function assignTableComment({
<td>Registered Wallet</td>
<td>${registeredWallet}</td>
</tr>
${multiplierAmount ? `<tr><td>Payment Multiplier</td><td>${multiplierAmount}</td></tr>` : ``}
${multiplierReason ? `<tr><td>Multiplier Reason</td><td>${multiplierReason}</td></tr>` : ``}
${totalPriceOfTask ? `<tr><td>Total Price</td><td>${totalPriceOfTask}</td></tr>` : ``}
</table></code>`;
</table>
</code>
`;
}

interface AssignTableCommentParams {
taskDeadline: string | null;
registeredWallet: string;
multiplierAmount: number | null;
multiplierReason: string | null;
totalPriceOfTask: string | null;
isTaskStale: boolean;
daysElapsedSinceTaskCreation: number;
}
12 changes: 0 additions & 12 deletions src/utils/shared.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import ms from "ms";
import { Label } from "../types";

export function calculateLabelValue(label: string): number {
const matches = label.match(/\d+/);
const number = matches && matches.length > 0 ? parseInt(matches[0]) || 0 : 0;
if (label.toLowerCase().includes("priority")) return number;
if (label.toLowerCase().includes("minute")) return number * 0.002;
if (label.toLowerCase().includes("hour")) return number * 0.125;
if (label.toLowerCase().includes("day")) return 1 + (number - 1) * 0.25;
if (label.toLowerCase().includes("week")) return number + 1;
if (label.toLowerCase().includes("month")) return 5 + (number - 1) * 8;
return 0;
}

export function calculateDurations(labels: Label[]): number[] {
// from shortest to longest
const durations: number[] = [];
Expand Down

0 comments on commit 0d67eb6

Please sign in to comment.