Fix
This commit is contained in:
@ -25,24 +25,6 @@ import {
|
|||||||
updateSetting,
|
updateSetting,
|
||||||
} from "./services/database.js";
|
} 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();
|
const app = new Hono();
|
||||||
|
|
||||||
// Basic Authentication middleware (if credentials are provided)
|
// Basic Authentication middleware (if credentials are provided)
|
||||||
@ -393,59 +375,70 @@ app.get("/api/admin/db-diagnostic", async (c) => {
|
|||||||
|
|
||||||
// 4. Check orphaned episodes
|
// 4. Check orphaned episodes
|
||||||
const orphanedEpisodes = db
|
const orphanedEpisodes = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT e.id, e.title, e.article_id
|
SELECT e.id, e.title, e.article_id
|
||||||
FROM episodes e
|
FROM episodes e
|
||||||
LEFT JOIN articles a ON e.article_id = a.id
|
LEFT JOIN articles a ON e.article_id = a.id
|
||||||
WHERE a.id IS NULL
|
WHERE a.id IS NULL
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.all() as any[];
|
.all() as any[];
|
||||||
|
|
||||||
// 5. Check orphaned articles
|
// 5. Check orphaned articles
|
||||||
const orphanedArticles = db
|
const orphanedArticles = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT a.id, a.title, a.feed_id
|
SELECT a.id, a.title, a.feed_id
|
||||||
FROM articles a
|
FROM articles a
|
||||||
LEFT JOIN feeds f ON a.feed_id = f.id
|
LEFT JOIN feeds f ON a.feed_id = f.id
|
||||||
WHERE f.id IS NULL
|
WHERE f.id IS NULL
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.all() as any[];
|
.all() as any[];
|
||||||
|
|
||||||
// 6. Check episodes with articles but feeds are inactive
|
// 6. Check episodes with articles but feeds are inactive
|
||||||
const episodesInactiveFeeds = db
|
const episodesInactiveFeeds = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT e.id, e.title, f.active, f.title as feed_title
|
SELECT e.id, e.title, f.active, f.title as feed_title
|
||||||
FROM episodes e
|
FROM episodes e
|
||||||
JOIN articles a ON e.article_id = a.id
|
JOIN articles a ON e.article_id = a.id
|
||||||
JOIN feeds f ON a.feed_id = f.id
|
JOIN feeds f ON a.feed_id = f.id
|
||||||
WHERE f.active = 0 OR f.active IS NULL
|
WHERE f.active = 0 OR f.active IS NULL
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.all() as any[];
|
.all() as any[];
|
||||||
|
|
||||||
// 7. Test the JOIN query
|
// 7. Test the JOIN query
|
||||||
const joinResult = db
|
const joinResult = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT COUNT(*) as count
|
SELECT COUNT(*) as count
|
||||||
FROM episodes e
|
FROM episodes e
|
||||||
JOIN articles a ON e.article_id = a.id
|
JOIN articles a ON e.article_id = a.id
|
||||||
JOIN feeds f ON a.feed_id = f.id
|
JOIN feeds f ON a.feed_id = f.id
|
||||||
WHERE f.active = 1
|
WHERE f.active = 1
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.get() as any;
|
.get() as any;
|
||||||
|
|
||||||
// 8. Sample feed details
|
// 8. Sample feed details
|
||||||
const sampleFeeds = db
|
const sampleFeeds = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT id, title, url, active, created_at
|
SELECT id, title, url, active, created_at
|
||||||
FROM feeds
|
FROM feeds
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.all() as any[];
|
.all() as any[];
|
||||||
|
|
||||||
// 9. Sample episode-article-feed chain
|
// 9. Sample episode-article-feed chain
|
||||||
const sampleChain = db
|
const sampleChain = db
|
||||||
.prepare(`
|
.prepare(
|
||||||
|
`
|
||||||
SELECT
|
SELECT
|
||||||
e.id as episode_id, e.title as episode_title,
|
e.id as episode_id, e.title as episode_title,
|
||||||
a.id as article_id, a.title as article_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
|
LEFT JOIN feeds f ON a.feed_id = f.id
|
||||||
ORDER BY e.created_at DESC
|
ORDER BY e.created_at DESC
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
`)
|
`,
|
||||||
|
)
|
||||||
.all() as any[];
|
.all() as any[];
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
Reference in New Issue
Block a user