rename filter function

This commit is contained in:
kenobi 2023-11-18 18:14:56 +01:00
parent 66507cb08f
commit 296a490e93
1 changed files with 7 additions and 5 deletions

View File

@ -63,10 +63,12 @@ export default class VoteController {
} }
return await message.delete() return await message.delete()
} }
public isAboveThreshold(vote: Vote): boolean {
const aboveThreshold = (vote.count - 1) >= 1 public hasAtLeastOneVote(vote: Vote): boolean {
logger.debug(`${vote.movie} : ${vote.count} -> above: ${aboveThreshold}`) // subtracting the bots initial vote
return aboveThreshold const overOneVote = (vote.count - 1) >= 1
logger.debug(`${vote.movie} : ${vote.count} -> above: ${overOneVote}`)
return overOneVote
} }
public async handleReroll(voteMessage: VoteMessage, guildId: string, requestId: string) { public async handleReroll(voteMessage: VoteMessage, guildId: string, requestId: string) {
//get movies that already had votes to give them a second chance //get movies that already had votes to give them a second chance
@ -74,7 +76,7 @@ export default class VoteController {
let movies: string[] = Array() let movies: string[] = Array()
if (config.bot.reroll_retains_top_picks) { if (config.bot.reroll_retains_top_picks) {
const votedOnMovies = voteInfo.votes.filter(this.isAboveThreshold).filter(x => x.emote !== NONE_OF_THAT) const votedOnMovies = voteInfo.votes.filter(this.hasAtLeastOneVote).filter(x => x.emote !== NONE_OF_THAT)
logger.info(`Found ${votedOnMovies.length} with votes`, { requestId, guildId }) logger.info(`Found ${votedOnMovies.length} with votes`, { requestId, guildId })
const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length
logger.info(`Fetching ${newMovieCount} from jellyfin`) logger.info(`Fetching ${newMovieCount} from jellyfin`)