this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

switch back to lua

alice 88004274 df30a01c

+6 -21
+1 -1
packages/backend/src/index.ts
··· 8 8 9 9 /* redis initialization */ 10 10 await redis.connect(); 11 - // await loadRedisScripts(); 11 + await loadRedisScripts(); 12 12 /* End Redis initialization */ 13 13 14 14 /* Jetstream initialization */
-1
packages/backend/src/lib/emojiNormalization.ts
··· 1 1 import fs from 'fs'; 2 2 3 3 import { codePointToEmoji, emojiToCodePoint, lowercaseObject } from './helpers.js'; 4 - import logger from './logger.js'; 5 4 import { Emoji, EmojiVariationSequence } from './types.js'; 6 5 7 6 // Load and parse normalization data
+3 -17
packages/backend/src/lib/emojiStats.ts
··· 92 92 await redis.incr(POSTS_WITHOUT_EMOJIS); 93 93 totalPostsWithoutEmojis.inc(); 94 94 } else { 95 - // Start of Selection 96 - const transaction = redis.multi(); 97 - transaction.incr('postsWithEmojis'); 98 - 99 - for (const emoji of normalizedEmojis) { 100 - transaction.zIncrBy('emojiStats', 1, emoji); 101 - transaction.incr('processedEmojis'); 102 - } 103 - 104 - for (const emoji of normalizedEmojis) { 105 - for (const lang of langs) { 106 - transaction.zIncrBy(lang, 1, emoji); 107 - transaction.zIncrBy('languageStats', 1, lang); 108 - } 109 - } 110 - 111 - await transaction.exec(); 95 + await redis.evalSha(SCRIPT_SHA, { 96 + arguments: [JSON.stringify(normalizedEmojis), JSON.stringify(Array.from(langs))], 97 + }); 112 98 113 99 incrementTotalEmojis(normalizedEmojis.length); 114 100 totalPostsWithEmojis.inc();
+2 -2
packages/backend/src/lib/lua/incrementEmojis.lua
··· 10 10 end 11 11 12 12 -- Increment per-language emoji counts and global language stats 13 - for _, lang in ipairs(langs) do 14 - for _, emoji in ipairs(emojis) do 13 + for _, emoji in ipairs(emojis) do 14 + for _, lang in ipairs(langs) do 15 15 redis.call('ZINCRBY', lang, 1, emoji) -- langKey being pt, ja, unknown, etc. 16 16 redis.call('ZINCRBY', 'languageStats', 1, lang) -- languageStats is the counter for per-language emoji count 17 17 end