Fix
This commit is contained in:
@ -25,24 +25,6 @@ import {
|
||||
updateSetting,
|
||||
} from "./services/database.js";
|
||||
|
||||
// Validate configuration on startup
|
||||
try {
|
||||
validateConfig();
|
||||
console.log("Admin panel configuration validated successfully");
|
||||
} catch (error) {
|
||||
console.error("Admin panel configuration validation failed:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Regenerate static files on startup
|
||||
try {
|
||||
const { regenerateStartupFiles } = await import("./services/podcast.js");
|
||||
await regenerateStartupFiles();
|
||||
} catch (error) {
|
||||
console.error("Failed to regenerate startup files on admin server:", error);
|
||||
// Don't exit - the admin server can still work without the regenerated files
|
||||
}
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
// Basic Authentication middleware (if credentials are provided)
|
||||
@ -393,59 +375,70 @@ app.get("/api/admin/db-diagnostic", async (c) => {
|
||||
|
||||
// 4. Check orphaned episodes
|
||||
const orphanedEpisodes = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT e.id, e.title, e.article_id
|
||||
FROM episodes e
|
||||
LEFT JOIN articles a ON e.article_id = a.id
|
||||
WHERE a.id IS NULL
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.all() as any[];
|
||||
|
||||
// 5. Check orphaned articles
|
||||
const orphanedArticles = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT a.id, a.title, a.feed_id
|
||||
FROM articles a
|
||||
LEFT JOIN feeds f ON a.feed_id = f.id
|
||||
WHERE f.id IS NULL
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.all() as any[];
|
||||
|
||||
// 6. Check episodes with articles but feeds are inactive
|
||||
const episodesInactiveFeeds = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT e.id, e.title, f.active, f.title as feed_title
|
||||
FROM episodes e
|
||||
JOIN articles a ON e.article_id = a.id
|
||||
JOIN feeds f ON a.feed_id = f.id
|
||||
WHERE f.active = 0 OR f.active IS NULL
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.all() as any[];
|
||||
|
||||
// 7. Test the JOIN query
|
||||
const joinResult = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT COUNT(*) as count
|
||||
FROM episodes e
|
||||
JOIN articles a ON e.article_id = a.id
|
||||
JOIN feeds f ON a.feed_id = f.id
|
||||
WHERE f.active = 1
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.get() as any;
|
||||
|
||||
// 8. Sample feed details
|
||||
const sampleFeeds = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT id, title, url, active, created_at
|
||||
FROM feeds
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 5
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.all() as any[];
|
||||
|
||||
// 9. Sample episode-article-feed chain
|
||||
const sampleChain = db
|
||||
.prepare(`
|
||||
.prepare(
|
||||
`
|
||||
SELECT
|
||||
e.id as episode_id, e.title as episode_title,
|
||||
a.id as article_id, a.title as article_title,
|
||||
@ -455,7 +448,8 @@ app.get("/api/admin/db-diagnostic", async (c) => {
|
||||
LEFT JOIN feeds f ON a.feed_id = f.id
|
||||
ORDER BY e.created_at DESC
|
||||
LIMIT 5
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.all() as any[];
|
||||
|
||||
db.close();
|
||||
|
Reference in New Issue
Block a user