File tree Expand file tree Collapse file tree
components/ChatVisualization Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 }}"
Original file line number Diff line number Diff line change 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 }}"
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments