Skip to content

Commit

Permalink
feature: Use the time of pull_request last update instead for voting …
Browse files Browse the repository at this point in the history
…clock
  • Loading branch information
myyk committed May 29, 2023
1 parent 118647d commit 461ddb8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,3 @@ export async function closeVotingComment(
export async function commentToId(commit: Promise<Comment>): Promise<number> {
return (await commit).id
}

export async function commentToCreatedAt(
commit: Promise<Comment>
): Promise<Date> {
return (await commit).createdAt
}
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from './reactions'
import {
closeVotingComment,
commentToCreatedAt,
commentToId,
createVotingCommentBody,
findOrRecreateVotingComment,
Expand Down Expand Up @@ -72,10 +71,17 @@ async function startOrUpdateHelper(
issueNumber
)

// TODO: could consolidate this call as it's used elsewhere
const pullRequest = await octokit.rest.pulls.get({
owner,
repo,
pull_number: issueNumber
})

const votesPromise = weightedVoteTotaling(
reactionCountsPromise,
votersPromise,
commentToCreatedAt(comment)
Promise.resolve(new Date(pullRequest.data.updated_at))
)
const errorMessage = await evaluateVote(votingConfigPromise, votesPromise)

Expand Down
1 change: 1 addition & 0 deletions src/reactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function readReactionsCounts(
}

// add the author since they cannot review their own PR in Github
// TODO: could consolidate this call as it's used elsewhere
const pullRequest = await octokit.rest.pulls.get({
owner,
repo,
Expand Down

0 comments on commit 461ddb8

Please sign in to comment.