Improve blog post view counting to track unique visitors
Add `article_views` table and update logic in `server/routes.ts` and `server/storage.ts` to record and check IP hashes before incrementing view counts, ensuring unique visitor tracking. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: d8397246-0deb-4af1-ac00-7fcd2a5d3a42 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/8XlN305 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -26,6 +26,13 @@ export const insertArticleSchema = createInsertSchema(articles).omit({
|
||||
export type InsertArticle = z.infer<typeof insertArticleSchema>;
|
||||
export type Article = typeof articles.$inferSelect;
|
||||
|
||||
export const articleViews = pgTable("article_views", {
|
||||
id: serial("id").primaryKey(),
|
||||
articleId: integer("article_id").notNull(),
|
||||
ipHash: varchar("ip_hash", { length: 64 }).notNull(),
|
||||
viewedAt: timestamp("viewed_at").notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const dailyHoroscopes = pgTable("daily_horoscopes", {
|
||||
id: serial("id").primaryKey(),
|
||||
signIndex: integer("sign_index").notNull(),
|
||||
|
||||
Reference in New Issue
Block a user