@@ -8,7 +8,7 @@ const user = require.main.require('./src/user');
88
99function formatPosts ( posts ) {
1010 return posts
11- . map ( ( post ) => `User ${ post . username } :\n${ post . content } ` )
11+ . map ( post => `User ${ post . username } :\n${ post . content } ` )
1212 . join ( '\n---\n' ) ;
1313}
1414
@@ -17,7 +17,6 @@ function chunkPosts(posts, maxTokensPerChunk = 3000) {
1717 let currentChunk = [ ] ;
1818 let currentTokens = 0 ;
1919
20- // eslint-disable-next-line no-restricted-syntax
2120 for ( const post of posts ) {
2221 const estimatedTokens = Math . ceil ( post . content . length / 4 ) + 10 ;
2322 if ( currentTokens + estimatedTokens > maxTokensPerChunk ) {
@@ -59,7 +58,7 @@ async function summarizeChunk(chunk, openai, settings) {
5958 return response . choices [ 0 ] . message . content . trim ( ) ;
6059}
6160
62- exports . summarizeTopic = async function ( tid , openai , settings ) {
61+ exports . summarizeTopic = async function ( tid , openai , settings ) {
6362 const allPids = await topics . getPids ( tid ) ;
6463
6564 const userMap = { } ;
@@ -68,11 +67,11 @@ exports.summarizeTopic = async function(tid, openai, settings) {
6867
6968 await batch . processArray ( allPids , async function ( pids ) {
7069 let postData = await posts . getPostsFields ( pids , [ 'uid' , 'content' , 'deleted' ] ) ;
71- postData = postData . filter ( ( p ) => ! p . deleted ) ;
70+ postData = postData . filter ( p => ! p . deleted ) ;
7271 const missingUids = [ ] ;
7372 postData . forEach ( ( p ) => {
7473 if ( ! userMap . hasOwnProperty ( p . uid ) ) {
75- missingUids . push ( p . uid )
74+ missingUids . push ( p . uid ) ;
7675 }
7776 } ) ;
7877 const userData = await user . getUsersFields ( missingUids , [ 'username' ] ) ;
@@ -86,7 +85,7 @@ exports.summarizeTopic = async function(tid, openai, settings) {
8685 const chunks = chunkPosts ( postData ) ;
8786
8887 chunkSummaries . push ( ...await Promise . all ( chunks . map ( async ( chunk ) => {
89- return summarizeChunk ( chunk , openai , settings )
88+ return summarizeChunk ( chunk , openai , settings ) ;
9089 } ) ) ) ;
9190 } , {
9291 batch : 500 ,
@@ -96,7 +95,7 @@ exports.summarizeTopic = async function(tid, openai, settings) {
9695 return chunkSummaries [ 0 ] ;
9796 }
9897 // Final summary from all summaries
99- const finalInput = chunkSummaries . join ( " \n\n" ) ;
98+ const finalInput = chunkSummaries . join ( ' \n\n' ) ;
10099 if ( ! finalInput ) {
101100 return '' ;
102101 }
@@ -118,6 +117,6 @@ exports.summarizeTopic = async function(tid, openai, settings) {
118117 return finalResponse . choices [ 0 ] . message . content . trim ( ) ;
119118} ;
120119
121- exports . clearTopicSummary = async function ( tids ) {
122- await db . deleteObjectFields ( tids . map ( ( tid ) => `topic:${ tid } ` ) , [ 'openai:summary' ] ) ;
120+ exports . clearTopicSummary = async function ( tids ) {
121+ await db . deleteObjectFields ( tids . map ( tid => `topic:${ tid } ` ) , [ 'openai:summary' ] ) ;
123122} ;
0 commit comments