Skip to content

Commit 25ce869

Browse files
committed
feat: add log 2025 route with mock data
1 parent c7184fd commit 25ce869

2 files changed

Lines changed: 137 additions & 0 deletions

File tree

src/routes/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { UserPersonalizedDigest, UserPersonalizedDigestType } from '../entity';
1919
import { notifyGeneratePersonalizedDigest } from '../common';
2020
import { PersonalizedDigestFeatureConfig } from '../growthbook';
2121
import integrations from './integrations';
22+
import log from './log';
2223

2324
export default async function (fastify: FastifyInstance): Promise<void> {
2425
fastify.register(rss, { prefix: '/rss' });
@@ -38,6 +39,7 @@ export default async function (fastify: FastifyInstance): Promise<void> {
3839
fastify.register(automations, { prefix: '/auto' });
3940
fastify.register(sitemaps, { prefix: '/sitemaps' });
4041
fastify.register(integrations, { prefix: '/integrations' });
42+
fastify.register(log, { prefix: '/log' });
4143

4244
fastify.get('/robots.txt', (req, res) => {
4345
return res.type('text/plain').send(`User-agent: *

src/routes/log.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import { FastifyInstance } from 'fastify';
2+
3+
// Record types matching the webapp's RecordType enum
4+
const RecordType = {
5+
YEAR_ACTIVE: 'yearActive',
6+
STREAK: 'streak',
7+
CONSISTENT_DAY: 'consistentDay',
8+
BINGE_DAY: 'bingeDay',
9+
LONGEST_SESSION: 'longestSession',
10+
TOPIC_MARATHON: 'topicMarathon',
11+
LATE_NIGHT: 'lateNight',
12+
EARLY_MORNING: 'earlyMorning',
13+
GROWTH_MONTH: 'growthMonth',
14+
IMPROVED_TOPIC: 'improvedTopic',
15+
} as const;
16+
17+
// Mock data matching the webapp's LogData interface
18+
// TODO: Replace with actual data fetching logic
19+
const MOCK_LOG_DATA = {
20+
// Card 1: Total Impact
21+
totalPosts: 847,
22+
totalReadingTime: 62,
23+
daysActive: 234,
24+
totalImpactPercentile: 91,
25+
26+
// Card 2: When You Read
27+
peakDay: 'Thursday',
28+
readingPattern: 'night',
29+
patternPercentile: 8,
30+
activityHeatmap: Array(7)
31+
.fill(null)
32+
.map(() =>
33+
Array(24)
34+
.fill(0)
35+
.map(() => Math.floor(Math.random() * 10)),
36+
),
37+
38+
// Card 3: Topic Evolution
39+
topicJourney: [
40+
{ quarter: 'Q1', topics: ['Python', 'Django', 'REST APIs'] },
41+
{
42+
quarter: 'Q2',
43+
topics: ['Docker', 'Kubernetes', 'DevOps'],
44+
comment: '🔥 THE PIVOT QUARTER',
45+
},
46+
{ quarter: 'Q3', topics: ['Go', 'Concurrency', 'gRPC'] },
47+
{ quarter: 'Q4', topics: ['Rust', 'Systems', 'Memory Safety'] },
48+
],
49+
uniqueTopics: 47,
50+
evolutionPercentile: 23,
51+
52+
// Card 4: Favorite Sources
53+
topSources: [
54+
{
55+
name: 'dev.to',
56+
postsRead: 127,
57+
logoUrl:
58+
'https://daily-now-res.cloudinary.com/image/upload/t_logo,f_auto/v1/logos/devto',
59+
},
60+
{
61+
name: 'Hacker News',
62+
postsRead: 98,
63+
logoUrl:
64+
'https://daily-now-res.cloudinary.com/image/upload/t_logo,f_auto/v1/logos/hn',
65+
},
66+
{
67+
name: 'Pragmatic Engineer',
68+
postsRead: 64,
69+
logoUrl:
70+
'https://daily-now-res.cloudinary.com/image/upload/t_logo,f_auto/v1/logos/pragmaticengineer',
71+
},
72+
],
73+
uniqueSources: 89,
74+
sourcePercentile: 15,
75+
sourceLoyaltyName: 'dev.to',
76+
77+
// Card 5: Community Engagement
78+
upvotesGiven: 234,
79+
commentsWritten: 18,
80+
postsBookmarked: 89,
81+
upvotePercentile: 15,
82+
commentPercentile: 32,
83+
bookmarkPercentile: 20,
84+
85+
// Card 6: Your Contributions
86+
hasContributions: true,
87+
postsCreated: 12,
88+
totalViews: 8432,
89+
commentsReceived: 247,
90+
upvotesReceived: 892,
91+
reputationEarned: 1892,
92+
creatorPercentile: 8,
93+
94+
// Card 7: Records
95+
records: [
96+
{
97+
type: RecordType.STREAK,
98+
label: 'Longest Streak',
99+
value: '47 days',
100+
percentile: 6,
101+
},
102+
{
103+
type: RecordType.BINGE_DAY,
104+
label: 'Biggest Binge',
105+
value: '34 posts on Mar 12',
106+
percentile: 3,
107+
},
108+
{
109+
type: RecordType.LATE_NIGHT,
110+
label: 'Latest Night Read',
111+
value: '3:47 AM',
112+
},
113+
],
114+
115+
// Card 8: Archetype
116+
archetype: 'COLLECTOR',
117+
archetypeStat: 'Only 12% of developers read as late as you',
118+
archetypePercentile: 12,
119+
120+
// Card 9: Share
121+
globalRank: 12847,
122+
totalDevelopers: 487000,
123+
shareCount: 24853,
124+
};
125+
126+
export default async function (fastify: FastifyInstance): Promise<void> {
127+
fastify.get('/', async (req, res) => {
128+
if (!req.userId) {
129+
return res.status(401).send({ error: 'Unauthorized' });
130+
}
131+
132+
// TODO: Replace mock data with actual user data based on req.userId
133+
return res.send(MOCK_LOG_DATA);
134+
});
135+
}

0 commit comments

Comments
 (0)