feat/40-reroll-on-disinterest #54

Merged
kenobi merged 73 commits from feat/40-reroll-on-disinterest into master 2023-11-19 20:24:36 +01:00
Showing only changes of commit 296a490e93 - Show all commits

View File

@ -63,10 +63,12 @@ export default class VoteController {
}
return await message.delete()
}
public isAboveThreshold(vote: Vote): boolean {
const aboveThreshold = (vote.count - 1) >= 1
logger.debug(`${vote.movie} : ${vote.count} -> above: ${aboveThreshold}`)
return aboveThreshold
magnetotail marked this conversation as resolved Outdated

above WHAT threshold? What does it do??

above WHAT threshold? What does it do??
20da25f2bf9a473704f8b4660e5f05183679ba39

Mit einem Kommentar versehen und entsprechend deines vorschlags umbenannt

Mit einem Kommentar versehen und entsprechend deines vorschlags umbenannt
public hasAtLeastOneVote(vote: Vote): boolean {
magnetotail marked this conversation as resolved Outdated

threshold seems to be a magic number

threshold seems to be a magic number

Or rename method to "hasAtLeastOneVote"

Or rename method to "hasAtLeastOneVote"
296a490e935cbdb79b70d73d2df9bc12a5774c53

done

done
// subtracting the bots initial vote
const overOneVote = (vote.count - 1) >= 1
logger.debug(`${vote.movie} : ${vote.count} -> above: ${overOneVote}`)
return overOneVote
}
magnetotail marked this conversation as resolved Outdated

comment is misleading, voteinfo is also used to get the eventid and eventdate in line 93

comment is misleading, voteinfo is also used to get the eventid and eventdate in line 93
119343c916b023a926e534575ae803cdec5b9594
public async handleReroll(voteMessage: VoteMessage, guildId: string, requestId: string) {
//get movies that already had votes to give them a second chance
@ -74,7 +76,7 @@ export default class VoteController {
magnetotail marked this conversation as resolved Outdated

maybe extract this if-else to a method to keep code more compact

maybe extract this if-else to a method to keep code more compact

7d794a8001
done

7d794a8001a66d068f949c893d689a068c3caeed done
let movies: string[] = Array()
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 })
const newMovieCount: number = config.bot.random_movie_count - votedOnMovies.length
logger.info(`Fetching ${newMovieCount} from jellyfin`)