initialize project with basic structure and dependencies
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { generateLabels } from "../utils/generateLabels";
|
||||
|
||||
export default defineNitroPlugin(async () => {
|
||||
generateLabels().catch((err) => {
|
||||
console.error("[labels] startup generation failed:", err?.message ?? err);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
||||
import { db } from "../db/index";
|
||||
import { resolve } from "path";
|
||||
|
||||
export default defineNitroPlugin(async () => {
|
||||
const migrationsFolder = resolve(process.cwd(), "drizzle");
|
||||
migrate(db, { migrationsFolder });
|
||||
console.log("[revisione] db migrations applied");
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { db } from "../db/index";
|
||||
import { courses } from "../db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { generateCourseInBackground } from "../utils/generateCourse";
|
||||
|
||||
export default defineNitroPlugin(async () => {
|
||||
console.log("[revisione] resumeGeneration plugin started");
|
||||
|
||||
try {
|
||||
const stuck = await db.query.courses.findMany({
|
||||
where: eq(courses.status, "processing"),
|
||||
});
|
||||
|
||||
console.log(`[revisione] query complete — found ${stuck.length} course(s)`);
|
||||
|
||||
if (stuck.length === 0) return;
|
||||
|
||||
console.log(`[revisione] found ${stuck.length} course(s) stuck in processing — resuming`);
|
||||
|
||||
for (const course of stuck) {
|
||||
console.log(`[revisione] resuming "${course.title}" (${course.id.slice(0, 8)})`);
|
||||
generateCourseInBackground(course.id).catch((err) => {
|
||||
console.error(`[revisione] background generation threw:`, err?.message ?? err);
|
||||
});
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error("[revisione] resumeGeneration plugin error:", err?.message ?? err);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user