Skip to content

Commit 9a0e497

Browse files
authored
Merge pull request #379 from SpiritFour/dev
Add free param back
2 parents 3c53664 + 57dbc94 commit 9a0e497

5 files changed

Lines changed: 40 additions & 6 deletions

File tree

.github/workflows/deployment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
2525
- uses: actions/setup-node@v3
2626
with:
27-
node-version: 18
27+
node-version: 20
2828
- uses: FirebaseExtended/action-hosting-deploy@v0
2929
with:
3030
repoToken: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/deployment-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
2525
- uses: actions/setup-node@v3
2626
with:
27-
node-version: 18
27+
node-version: 20
2828
- uses: FirebaseExtended/action-hosting-deploy@v0
2929
with:
3030
repoToken: "${{ secrets.GITHUB_TOKEN }}"

components/ChatVisualization/PdfDownloadPopup.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ export default {
263263
},
264264
downloadSample() {
265265
gtagEvent("sample_download", GTAG_PDF, 2);
266-
this.download(true);
266+
const query = (this.$route && this.$route.query) || {};
267+
this.download(!('free' in query));
267268
},
268269
workerResponseHandler: function (event) {
269270
const data = event.data;

utils/transformChatData.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class Chat {
115115
chatObject = [],
116116
groupAfter = 9,
117117
maxWordsWordCloud = 150,
118-
maxWordsEmojiCloud = 50000
118+
maxWordsEmojiCloud = 150
119119
) {
120120
// this one is the complete input
121121
this.chatObject = chatObject;
@@ -472,8 +472,20 @@ export class Chat {
472472
return this._allWords.then((x) => x.slice(0, this._maxWordsWordCloud));
473473
}
474474

475-
// New method to extract and count emojis, limited to 1000 emojis
476475
getEmojiCloudData() {
477-
return this._allWords.then((x) => x.slice(0, this._maxWordsEmojiCloud));
476+
return this._allWords.then((words) => {
477+
const emojiFrequencies = {};
478+
479+
words.forEach(({ word, freq }) => {
480+
onlyEmoji(word).forEach((emoji) => {
481+
emojiFrequencies[emoji] = (emojiFrequencies[emoji] || 0) + freq;
482+
});
483+
});
484+
485+
return Object.entries(emojiFrequencies)
486+
.sort((a, b) => b[1] - a[1])
487+
.slice(0, this._maxWordsEmojiCloud)
488+
.map(([word, freq]) => ({ word, freq }));
489+
});
478490
}
479491
}

utils/transformChatData.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* eslint-env jest */
2+
import { Chat } from "./transformChatData";
3+
4+
describe("Chat.getEmojiCloudData", () => {
5+
it("extracts and aggregates emojis before applying the display limit", async () => {
6+
const chat = Object.create(Chat.prototype);
7+
chat._maxWordsEmojiCloud = 2;
8+
chat._allWords = Promise.resolve([
9+
{ word: "common", freq: 10 },
10+
{ word: "hello😂", freq: 3 },
11+
{ word: "goodbye😂", freq: 2 },
12+
{ word: "wave👋", freq: 2 },
13+
{ word: "rare👍", freq: 1 },
14+
]);
15+
16+
await expect(chat.getEmojiCloudData()).resolves.toEqual([
17+
{ word: "😂", freq: 5 },
18+
{ word: "👋", freq: 2 },
19+
]);
20+
});
21+
});

0 commit comments

Comments
 (0)