Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

revert(reddit): remove view count - Reddit disabled it permanently in 2018

spacesdrive5c95bdfce6d7
diff --git a/backend/services/reddit.js b/backend/services/reddit.js
index adab366..15a1d8b 100644
--- a/backend/services/reddit.js
+++ b/backend/services/reddit.js
@@ -83,7 +83,6 @@ export async function fetchRedditPosts(username, cookie, limit = 100) {
createdAt: p.created_utc ? new Date(p.created_utc * 1000).toISOString() : '',
flair: p.link_flair_text ?? '',
awardsCount: p.total_awards_received ?? 0,
- viewCount: typeof p.view_count === 'number' ? p.view_count : null,
}));
}
@@ -92,7 +91,6 @@ export function computeRedditAnalytics(profile, posts) {
fetchedPosts: 0, totalScore: 0, avgScore: 0, medianScore: 0,
totalComments: 0, avgComments: 0, avgUpvoteRatio: 0,
totalAwards: 0, avgAwards: 0,
- totalViews: null, avgViews: null, postsWithViews: 0,
topPosts: [], worstPosts: [], subredditBreakdown: [],
mediaTypeDistribution: {}, postsByDayOfWeek: [], postsByHour: [],
monthlyBreakdown: [], engagementTimeline: [],
@@ -111,13 +109,6 @@ export function computeRedditAnalytics(profile, posts) {
const avgComments = Math.round(totalComments / posts.length);
const avgAwards = parseFloat((totalAwards / posts.length).toFixed(2));
- const postsWithViews = posts.filter(p => p.viewCount !== null).length;
- const totalViews = postsWithViews > 0
- ? posts.reduce((s, p) => s + (p.viewCount ?? 0), 0)
- : null;
- const avgViews = postsWithViews > 0 && totalViews !== null
- ? Math.round(totalViews / postsWithViews)
- : null;
const avgUpvoteRatio = parseFloat(
(posts.reduce((s, p) => s + p.upvoteRatio, 0) / posts.length * 100).toFixed(1)
);
@@ -245,7 +236,6 @@ export function computeRedditAnalytics(profile, posts) {
totalScore, avgScore, medianScore,
totalComments, avgComments, avgUpvoteRatio,
totalAwards, avgAwards,
- totalViews, avgViews, postsWithViews,
topPosts: byScore.slice(0, 10),
worstPosts: byScore.slice(-5).reverse(),
subredditBreakdown,
diff --git a/frontend/src/features/analytics/reddit/RedditAnalytics.jsx b/frontend/src/features/analytics/reddit/RedditAnalytics.jsx
index c800b40..dac1057 100644
--- a/frontend/src/features/analytics/reddit/RedditAnalytics.jsx
+++ b/frontend/src/features/analytics/reddit/RedditAnalytics.jsx
@@ -20,7 +20,7 @@ import { fmtNum, fmtNumFull, fmtDate, timeAgo } from '../../../utils/formatters'
import {
ArrowLeft, RefreshCw, TrendingUp, MessageSquare, Award, BarChart2,
Calendar, Clock, Zap, Flame, Trophy, ExternalLink, FileText, Link2,
- Image, Video, Star, Eye,
+ Image, Video, Star,
} from 'lucide-react';
const REDDIT_COLORS = ['#FF4500', '#FF6534', '#FF8C00', '#FFA500', '#FFB347', '#FFC080'];
@@ -183,10 +183,10 @@ export default function RedditAnalytics() {
{/* KPI cards */}
<div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4">
- <StatCard icon={<TrendingUp />} label="Posts Fetched" value={fmtNum(a.fetchedPosts)} subtitle={`${a.postsLast30Days ?? 0} in the last 30 days`} gradient="orange" />
- <StatCard icon={<Eye />} label="Total Views" value={a.totalViews !== null ? fmtNum(a.totalViews) : 'N/A'} subtitle={a.totalViews !== null ? `Avg ${fmtNum(a.avgViews)} per post` : 'Reddit does not always expose views'} gradient="red" />
- <StatCard icon={<Award />} label="Total Score" value={fmtNum(a.totalScore)} subtitle={`Avg ${fmtNum(a.avgScore)} per post`} gradient="purple" />
- <StatCard icon={<MessageSquare />} label="Total Comments" value={fmtNum(a.totalComments)} subtitle={`Avg ${fmtNum(a.avgComments)} per post`} gradient="blue" />
+ <StatCard icon={<TrendingUp />} label="Posts Fetched" value={fmtNum(a.fetchedPosts)} subtitle={`${a.postsLast30Days ?? 0} in the last 30 days`} gradient="orange" />
+ <StatCard icon={<Award />} label="Total Score" value={fmtNum(a.totalScore)} subtitle={`Avg ${fmtNum(a.avgScore)} per post`} gradient="red" />
+ <StatCard icon={<MessageSquare />} label="Total Comments" value={fmtNum(a.totalComments)} subtitle={`Avg ${fmtNum(a.avgComments)} per post`} gradient="blue" />
+ <StatCard icon={<Star />} label="Awards Received" value={fmtNum(a.totalAwards ?? 0)} subtitle={`Avg ${a.avgAwards ?? 0} per post`} gradient="purple" />
</div>
{/* Score timeline + media type pie */}
@@ -261,8 +261,6 @@ export default function RedditAnalytics() {
{ label: 'Avg upvote ratio', value: `${a.avgUpvoteRatio ?? 0}%` },
{ label: 'Total comments', value: fmtNum(a.totalComments) },
{ label: 'Avg comments', value: fmtNum(a.avgComments) },
- { label: 'Awards received', value: fmtNum(a.totalAwards ?? 0) },
- { label: 'Avg awards / post', value: String(a.avgAwards ?? 0) },
].map(item => (
<div key={item.label} className="flex items-center justify-between">
<span className="text-sm text-muted-foreground">{item.label}</span>
@@ -380,7 +378,6 @@ export default function RedditAnalytics() {
<TableHead className="w-8">#</TableHead>
<TableHead>Post</TableHead>
<TableHead className="text-right">Score</TableHead>
- <TableHead className="text-right">Views</TableHead>
<TableHead className="text-right">Comments</TableHead>
<TableHead className="text-right">Upvote %</TableHead>
<TableHead className="text-right">Posted</TableHead>
@@ -405,7 +402,6 @@ export default function RedditAnalytics() {
</div>
</TableCell>
<TableCell className="text-right text-sm font-semibold tabular-nums text-orange-500">{fmtNum(post.score)}</TableCell>
- <TableCell className="text-right text-sm tabular-nums text-muted-foreground">{post.viewCount !== null ? fmtNum(post.viewCount) : <span className="text-xs">N/A</span>}</TableCell>
<TableCell className="text-right text-sm tabular-nums">{fmtNum(post.numComments)}</TableCell>
<TableCell className="text-right text-sm tabular-nums">{Math.round((post.upvoteRatio ?? 0) * 100)}%</TableCell>
<TableCell className="text-right text-xs text-muted-foreground">{fmtDate(post.createdAt)}</TableCell>
diff --git a/frontend/src/features/analytics/reddit/RedditPostsAll.jsx b/frontend/src/features/analytics/reddit/RedditPostsAll.jsx
index dcf3d50..3cb3fcd 100644
--- a/frontend/src/features/analytics/reddit/RedditPostsAll.jsx
+++ b/frontend/src/features/analytics/reddit/RedditPostsAll.jsx
@@ -14,7 +14,7 @@ import { api } from '../../../services/api';
import { fmtNum, fmtDate } from '../../../utils/formatters';
import {
Search, ExternalLink, TrendingUp, MessageSquare, FileText,
- Image, Video, Link2, Award, RefreshCw, Eye,
+ Image, Video, Link2, Award, RefreshCw,
} from 'lucide-react';
const MEDIA_TYPE_LABELS = { text: 'Text', image: 'Image', video: 'Video', link: 'Link' };
@@ -118,16 +118,11 @@ export default function RedditPostsAll() {
});
}, [posts, query, sort, accountFilter, subFilter]);
- const totals = useMemo(() => {
- const postsWithViews = filtered.filter(p => p.viewCount !== null);
- return {
- posts: filtered.length,
- score: filtered.reduce((s, p) => s + p.score, 0),
- comments: filtered.reduce((s, p) => s + p.numComments, 0),
- views: postsWithViews.length > 0 ? postsWithViews.reduce((s, p) => s + (p.viewCount ?? 0), 0) : null,
- postsWithViews: postsWithViews.length,
- };
- }, [filtered]);
+ const totals = useMemo(() => ({
+ posts: filtered.length,
+ score: filtered.reduce((s, p) => s + p.score, 0),
+ comments: filtered.reduce((s, p) => s + p.numComments, 0),
+ }), [filtered]);
if (redditAccounts.length === 0) {
return (
@@ -177,10 +172,9 @@ export default function RedditPostsAll() {
) : (
<>
{/* Summary stats */}
- <div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4">
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
<StatCard icon={<TrendingUp />} label="Posts Shown" value={fmtNum(totals.posts)} subtitle={`${posts.length} total fetched`} gradient="orange" />
- <StatCard icon={<Eye />} label="Total Views" value={totals.views !== null ? fmtNum(totals.views) : 'N/A'} subtitle={totals.views !== null ? `Across ${totals.postsWithViews} posts` : 'Reddit does not always expose views'} gradient="red" />
- <StatCard icon={<Award />} label="Combined Score" value={fmtNum(totals.score)} subtitle={filtered.length > 0 ? `Avg ${fmtNum(Math.round(totals.score / filtered.length))} per post` : ''} gradient="purple" />
+ <StatCard icon={<Award />} label="Combined Score" value={fmtNum(totals.score)} subtitle={filtered.length > 0 ? `Avg ${fmtNum(Math.round(totals.score / filtered.length))} per post` : ''} gradient="red" />
<StatCard icon={<MessageSquare />} label="Total Comments" value={fmtNum(totals.comments)} subtitle={filtered.length > 0 ? `Avg ${fmtNum(Math.round(totals.comments / filtered.length))} per post` : ''} gradient="blue" />
</div>
@@ -246,7 +240,6 @@ export default function RedditPostsAll() {
{redditAccounts.length > 1 && <TableHead className="w-36">Account</TableHead>}
<TableHead className="w-24">Type</TableHead>
<TableHead className="text-right w-24">Score</TableHead>
- <TableHead className="text-right w-24">Views</TableHead>
<TableHead className="text-right w-28">Comments</TableHead>
<TableHead className="text-right w-20">Upvote %</TableHead>
<TableHead className="text-right w-28">Date</TableHead>
@@ -256,7 +249,7 @@ export default function RedditPostsAll() {
<TableBody>
{filtered.length === 0 ? (
<TableRow>
- <TableCell colSpan={redditAccounts.length > 1 ? 10 : 9} className="text-center text-muted-foreground py-12">
+ <TableCell colSpan={redditAccounts.length > 1 ? 9 : 8} className="text-center text-muted-foreground py-12">
No posts match the current filters
</TableCell>
</TableRow>
@@ -307,9 +300,6 @@ export default function RedditPostsAll() {
<TableCell className="text-right text-sm font-semibold tabular-nums text-orange-500">
{fmtNum(post.score)}
</TableCell>
- <TableCell className="text-right text-sm tabular-nums text-muted-foreground">
- {post.viewCount !== null ? fmtNum(post.viewCount) : <span className="text-xs">N/A</span>}
- </TableCell>
<TableCell className="text-right text-sm tabular-nums">{fmtNum(post.numComments)}</TableCell>
<TableCell className="text-right text-sm tabular-nums">
{Math.round((post.upvoteRatio ?? 0) * 100)}%