@@ -2,10 +2,10 @@ import CouchDB, { useOrCreateDB } from '../couchdb/index.js';
22import nano from 'nano' ;
33import { normalize } from './normalize.js' ;
44import AsyncProcessQueue , { Result } from '../utils/processQueue.js' ;
5- import { COURSE_DB_LOOKUP } from '../client-requests/course-requests.js' ;
65import logger from '../logger.js' ;
6+ import { CourseLookup } from '@vue-skuilder/db' ;
77
8- // @ts -ignore
8+ // @ts -expect-error [todo]
99const Q = new AsyncProcessQueue < AttachmentProcessingRequest , Result > (
1010 processDocAttachments
1111) ;
@@ -64,16 +64,14 @@ export function postProcessCourse(courseID: string): void {
6464export default async function postProcess ( ) : Promise < void > {
6565 try {
6666 logger . info ( `Following all course databases for changes...` ) ;
67- const lookupDB = await useOrCreateDB ( COURSE_DB_LOOKUP ) ;
68- const courses = await lookupDB . list ( {
69- include_docs : true ,
70- } ) ;
7167
72- for ( const course of courses . rows ) {
68+ const courses = await CourseLookup . allCourses ( ) ;
69+
70+ for ( const course of courses ) {
7371 try {
74- postProcessCourse ( course . id ) ;
72+ postProcessCourse ( course . _id ) ;
7573 } catch ( e ) {
76- logger . error ( `Error processing course ${ course . id } : ${ e } ` ) ;
74+ logger . error ( `Error processing course ${ course . _id } : ${ e } ` ) ;
7775 throw e ;
7876 }
7977 }
@@ -181,7 +179,7 @@ async function processDocAttachments(
181179 doc [ 'processed' ] = true ;
182180 }
183181
184- const resp : any = await courseDatabase . insert ( doc ) ;
182+ const resp = ( await courseDatabase . insert ( doc ) ) as unknown as Result ;
185183 resp . status = 'ok' ;
186184
187185 logger . info ( `Processing request reinsert result: ${ JSON . stringify ( resp ) } ` ) ;
0 commit comments