Skip to content

Commit 3f1b872

Browse files
committed
use CourseLookup
1 parent 253f617 commit 3f1b872

File tree

1 file changed

+8
-10
lines changed
  • packages/express/src/attachment-preprocessing

1 file changed

+8
-10
lines changed

packages/express/src/attachment-preprocessing/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import CouchDB, { useOrCreateDB } from '../couchdb/index.js';
22
import nano from 'nano';
33
import { normalize } from './normalize.js';
44
import AsyncProcessQueue, { Result } from '../utils/processQueue.js';
5-
import { COURSE_DB_LOOKUP } from '../client-requests/course-requests.js';
65
import logger from '../logger.js';
6+
import { CourseLookup } from '@vue-skuilder/db';
77

8-
// @ts-ignore
8+
// @ts-expect-error [todo]
99
const Q = new AsyncProcessQueue<AttachmentProcessingRequest, Result>(
1010
processDocAttachments
1111
);
@@ -64,16 +64,14 @@ export function postProcessCourse(courseID: string): void {
6464
export 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

Comments
 (0)