File tree Expand file tree Collapse file tree 3 files changed +76
-384
lines changed
src/attachment-preprocessing Expand file tree Collapse file tree 3 files changed +76
-384
lines changed Original file line number Diff line number Diff line change 2929 "ffmpeg-static" : " ^5.2.0" ,
3030 "hashids" : " ^2.3.0" ,
3131 "morgan" : " ^1.10.0" ,
32- "nano" : " ^8 .0.0 " ,
32+ "nano" : " ^ 9 .0.5 " ,
3333 "pouchdb" : " 8.0.1" ,
3434 "winston" : " ^3.17.0" ,
3535 "winston-daily-rotate-file" : " ^5.0.0"
Original file line number Diff line number Diff line change @@ -34,15 +34,24 @@ export function postProcessCourse(courseID: string): void {
3434
3535 const crsString = `coursedb-${ courseID } ` ;
3636
37- CouchDB . db . follow (
38- crsString ,
39- {
40- feed : 'continuous' ,
41- db : crsString ,
42- include_docs : false ,
43- } ,
44- filterFactory ( courseID )
45- ) ;
37+ // Get database instance
38+ const db = CouchDB . use ( crsString ) ;
39+
40+ const courseFilter = filterFactory ( courseID ) ;
41+
42+ db . changesReader
43+ . start ( {
44+ // feed: 'continuous',
45+ includeDocs : false ,
46+ } )
47+ . on ( 'change' , ( change : nano . DatabaseChangesResultItem ) => {
48+ courseFilter ( change ) . catch ( ( e ) => {
49+ logger . error ( `Error in CourseFilter for ${ courseID } : ${ e } ` ) ;
50+ } ) ;
51+ } )
52+ . on ( 'error' , ( err : Error ) => {
53+ logger . error ( `Error in changes feed for ${ crsString } : ${ err } ` ) ;
54+ } ) ;
4655 } catch ( e ) {
4756 logger . error ( `Error in postProcessCourse: ${ e } ` ) ;
4857 }
@@ -77,7 +86,6 @@ function filterFactory(courseID: string) {
7786 const courseDatabase = CouchDB . use < DocForProcessing > ( `coursedb-${ courseID } ` ) ;
7887
7988 return async function filterChanges (
80- error : any ,
8189 changeItem : nano . DatabaseChangesResultItem
8290 ) {
8391 try {
You can’t perform that action at this time.
0 commit comments