Skip to content

Commit

Permalink
chore: paginate and knip fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Aug 6, 2024
1 parent f7e5244 commit 30ca585
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/handlers/shared/check-assignments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, IssueEvent } from "../../types";
import { Context } from "../../types";
import { getAppId } from "../../utils/shared";

export async function hasUserBeenUnassigned(context: Context): Promise<boolean> {
Expand All @@ -20,11 +20,11 @@ export async function hasUserBeenUnassigned(context: Context): Promise<boolean>
async function getAssignmentEvents(context: Context) {
const { repository, issue } = context.payload;
try {
const { data } = (await context.octokit.issues.listEventsForTimeline({
const data = await context.octokit.paginate(context.octokit.issues.listEventsForTimeline, {
owner: repository.owner.login,
repo: repository.name,
issue_number: issue.number,
})) as IssueEvent;
});

const events = data
.filter((event) => event.event === "assigned" || event.event === "unassigned")
Expand Down Expand Up @@ -53,7 +53,6 @@ async function getAssignmentEvents(context: Context) {
return new Date(a.createdAt || "").getTime() - new Date(b.createdAt || "").getTime();
});
} catch (error) {
const log = context.logger.error("Error while getting assignment events", { error: error as Error });
throw new Error(log?.logMessage.diff as string);
throw context.logger.error("Error while getting assignment events", { error: error as Error });
}
}
2 changes: 0 additions & 2 deletions src/types/payload.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { RestEndpointMethodTypes } from "@octokit/rest";

export type Issue = RestEndpointMethodTypes["issues"]["get"]["response"]["data"];
export type PullRequest = RestEndpointMethodTypes["pulls"]["list"]["response"]["data"][0];
export type Label = RestEndpointMethodTypes["issues"]["listLabelsOnIssue"]["response"]["data"][0];
export type Review = RestEndpointMethodTypes["pulls"]["listReviews"]["response"]["data"][0];
export type TimelineEventResponse = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"];
export type TimelineEvents = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"]["data"][0];
export type Assignee = Issue["assignee"];
export type IssueEvent = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"];
export type GitHubIssueSearch = RestEndpointMethodTypes["search"]["issuesAndPullRequests"]["response"]["data"];
export type Sender = { login: string; id: number };

Expand Down

0 comments on commit 30ca585

Please sign in to comment.