Prevent duplicate article notifications by adjusting database seeding order
Modify the database seeding script to update article slugs and delete outdated articles before checking for new content, preventing duplicate push notifications for modified or removed posts. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 7240882d-b323-4f34-bc19-cfa3d41ea801 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/OPD8Ro3 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
d485717375
commit
1b3271c795
BIN
attached_assets/image_1772954248287.png
Normal file
BIN
attached_assets/image_1772954248287.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
@ -227,6 +227,24 @@ const seedArticles = [
|
||||
];
|
||||
|
||||
export async function seedDatabase() {
|
||||
await db.execute(sql`
|
||||
UPDATE articles SET
|
||||
slug = 'john-prisco-die-geschichte-eines-musikers'
|
||||
WHERE slug = 'john-prisco-die-geschichte-des-liedes'
|
||||
`);
|
||||
|
||||
await db.execute(sql`
|
||||
DELETE FROM articles WHERE slug = 'folx-stadl-sendung-12'
|
||||
`);
|
||||
|
||||
await db.execute(sql`
|
||||
UPDATE articles SET
|
||||
title = REPLACE(REPLACE(title, '„', '„'), '“', '"'),
|
||||
excerpt = REPLACE(REPLACE(excerpt, '„', '„'), '“', '"')
|
||||
WHERE title LIKE '%„%' OR title LIKE '%“%'
|
||||
OR excerpt LIKE '%„%' OR excerpt LIKE '%“%'
|
||||
`);
|
||||
|
||||
const validSlugs = new Set(seedArticles.map((a) => a.slug));
|
||||
const existing = await storage.getArticles();
|
||||
const existingSlugs = new Set(existing.map((a) => a.slug));
|
||||
@ -293,24 +311,6 @@ export async function seedDatabase() {
|
||||
if (updated > 0) {
|
||||
console.log("Database seeded: updated " + updated + " existing articles.");
|
||||
}
|
||||
|
||||
await db.execute(sql`
|
||||
UPDATE articles SET
|
||||
title = REPLACE(REPLACE(title, '„', '„'), '“', '“'),
|
||||
excerpt = REPLACE(REPLACE(excerpt, '„', '„'), '“', '“')
|
||||
WHERE title LIKE '%„%' OR title LIKE '%“%'
|
||||
OR excerpt LIKE '%„%' OR excerpt LIKE '%“%'
|
||||
`);
|
||||
|
||||
await db.execute(sql`
|
||||
UPDATE articles SET
|
||||
slug = 'john-prisco-die-geschichte-eines-musikers'
|
||||
WHERE slug = 'john-prisco-die-geschichte-des-liedes'
|
||||
`);
|
||||
|
||||
await db.execute(sql`
|
||||
DELETE FROM articles WHERE slug = 'folx-stadl-sendung-12'
|
||||
`);
|
||||
}
|
||||
|
||||
async function sendNewArticlePush(articles: typeof seedArticles) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user