|
@@ -12,11 +12,14 @@ async function getRandomEmotes(allowedTypes: ReactionType[], limit: number) {
|
|
|
let reactionEmotesRepo = getRepository(ReactionEmote);
|
|
|
|
|
|
let a = await reactionEmotesRepo.query(`
|
|
|
- select "reactionId"
|
|
|
- from reaction_emote
|
|
|
- where type in (${allowedTypes.map((s, i) => `$${i + 1}`).join(",")})
|
|
|
- order by random(), random()
|
|
|
- limit ${limit}`, allowedTypes) as ReactionEmote[];
|
|
|
+ select distinct on (type) type, "reactionId"
|
|
|
+ from
|
|
|
+ ( select *
|
|
|
+ from reaction_emote
|
|
|
+ where type in (${allowedTypes.map((s, i) => `$${i + 1}`).join(",")})
|
|
|
+ order by random(), random()
|
|
|
+ limit ${limit}
|
|
|
+ ) as sub`, allowedTypes) as ReactionEmote[];
|
|
|
|
|
|
return a;
|
|
|
}
|