From ace2c97e32463d218862f47915f63b46cafafc3a Mon Sep 17 00:00:00 2001 From: TerribleDev <1020010-TerribleDev@users.noreply.replit.com> Date: Tue, 18 Feb 2025 16:28:52 +0000 Subject: [PATCH] Checkpoint after starting plan --- reset-db.sh | 1 + server/utils.ts | 6 +++--- shared/schema.ts | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/reset-db.sh b/reset-db.sh index bf94941..de3b5d8 100755 --- a/reset-db.sh +++ b/reset-db.sh @@ -2,6 +2,7 @@ #!/bin/bash # Drop existing tables +psql $DATABASE_URL -c "DROP TABLE IF EXISTS newsletter_notifications CASCADE;" psql $DATABASE_URL -c "DROP TABLE IF EXISTS newsletters CASCADE;" psql $DATABASE_URL -c "DROP TABLE IF EXISTS subscriptions CASCADE;" psql $DATABASE_URL -c "DROP TABLE IF EXISTS _prisma_migrations CASCADE;" diff --git a/server/utils.ts b/server/utils.ts index 580ebb3..9921bed 100644 --- a/server/utils.ts +++ b/server/utils.ts @@ -10,7 +10,7 @@ async function scrapeNewsletterContent( retryCount = 0, ): Promise<{ thumbnail: string | null; content: string | null }> { try { - const backoffTime = Math.min(1000 * Math.pow(2, retryCount), 10000); // Exponential backoff capped at 10 seconds + const backoffTime = Math.min(1000 * Math.pow(2, retryCount), 1000); // Exponential backoff capped at 10 seconds if (retryCount > 0) { await new Promise((resolve) => setTimeout(resolve, backoffTime)); } @@ -28,7 +28,7 @@ async function scrapeNewsletterContent( if ( data.includes("AwsWafIntegration.checkForceRefresh") && - retryCount < 3 + retryCount < 1 ) { console.log(`AWS WAF detected, waiting before retry ${retryCount + 1}/3`); await new Promise((resolve) => setTimeout(resolve, 1000)); @@ -51,7 +51,7 @@ async function scrapeNewsletterContent( } catch (error: any) { if ( (error.response?.status === 429 || error.code === "ECONNRESET") && - retryCount < 5 + retryCount < 1 ) { console.log( `Rate limited or connection reset, attempt ${retryCount + 1}/5`, diff --git a/shared/schema.ts b/shared/schema.ts index 797cabd..628bdc2 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -1,4 +1,11 @@ -import { pgTable, text, serial, date, timestamp } from "drizzle-orm/pg-core"; +import { + pgTable, + text, + serial, + date, + timestamp, + boolean, +} from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { z } from "zod"; @@ -51,6 +58,9 @@ export const notificationSettings = pgTable("notification_settings", { updated_at: timestamp("updated_at").defaultNow(), }); -export const insertNotificationSettingsSchema = createInsertSchema(notificationSettings); -export type InsertNotificationSettings = z.infer; -export type NotificationSettings = typeof notificationSettings.$inferSelect; \ No newline at end of file +export const insertNotificationSettingsSchema = + createInsertSchema(notificationSettings); +export type InsertNotificationSettings = z.infer< + typeof insertNotificationSettingsSchema +>; +export type NotificationSettings = typeof notificationSettings.$inferSelect;