Skip to content

Commit

Permalink
chore: any commit counts
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 15, 2024
1 parent 6157287 commit 9196ec8
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions src/helpers/get-assignee-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export async function getAssigneesActivityForIssue(context: Context, issue: List
issueEvents.push(...events);
}

return filterEvents(issueEvents, assigneeIds, context);
return filterEvents(issueEvents, assigneeIds);
}

function filterEvents(issueEvents: GitHubTimelineEvents[], assigneeIds: number[], context: Context) {
function filterEvents(issueEvents: GitHubTimelineEvents[], assigneeIds: number[]) {
const userIdMap = new Map<string, number>();

let assigneeEvents = [];
Expand All @@ -50,26 +50,22 @@ function filterEvents(issueEvents: GitHubTimelineEvents[], assigneeIds: number[]
createdAt = event.created_at;
} else if (event.event === "committed") {
const commitAuthor = "author" in event ? event.author : null;
const commitCommitter = "committer" in event ? event.committer : null;
const commitCommiter = "committer" in event ? event.committer : null;

if (commitAuthor && commitCommitter && commitAuthor.name === commitCommitter.name) {
actorLogin = commitAuthor.name.toLowerCase();
if (!userIdMap.has(actorLogin)) {
const { id, name } = parseGitHubEmail(commitAuthor.email);
actorLogin = name.toLowerCase();
userIdMap.set(actorLogin, id);
}
actorId = userIdMap.get(actorLogin);
createdAt = commitCommitter.date;
eventName = "committed";
if (commitAuthor || commitCommiter) {
assigneeEvents.push({
event: eventName,
created_at: createdAt,
});

continue;
}
}

if (actorId && assigneeIds.includes(actorId)) {
assigneeEvents.push({
event: eventName,
created_at: createdAt,
actor: actorLogin,
});
}
}
Expand All @@ -78,15 +74,3 @@ function filterEvents(issueEvents: GitHubTimelineEvents[], assigneeIds: number[]
return DateTime.fromISO(b.created_at).toMillis() - DateTime.fromISO(a.created_at).toMillis();
});
}

// [email protected]
function parseGitHubEmail(email: string) {
const idName = email.split("@")[0];

const [id, name] = idName.split("+");

return {
id: parseInt(id),
name,
};
}

0 comments on commit 9196ec8

Please sign in to comment.