Cumfiesta.24.06.16.ryan.reid.the.rise.of.the.cu... Here

await prisma.$transaction([ prisma.trendingContent.update( where: id: contentId , data: [type === 'like' ? 'likes' : type === 'share' ? 'shares' : 'views']: increment: 1 ), prisma.userInteraction.create( data: userId: req.user.id, contentId, type ) ]);

@@index([trendScore(sort: Desc)]) @@index([contentType, category])

enum Category MOVIES MUSIC VIRAL GAMING TV CumFiesta.24.06.16.Ryan.Reid.The.Rise.Of.The.Cu...

// POST /api/trending/:id/interact router.post('/:id/interact', async (req, res) => const type = req.body; // 'like', 'share', 'view' const contentId = req.params.id;

const fetchTrending = async () => setLoading(true); const res = await fetch( /api/trending/feed?limit=15&offset=$page * 15 ); const newItems = await res.json(); setItems(prev => [...prev, ...newItems.data]); setLoading(false); ; await prisma

createdAt DateTime @default(now()) updatedAt DateTime @updatedAt

return ( <div className="max-w-4xl mx-auto px-4 py-8"> /* Category Pills */ <div className="flex gap-2 overflow-x-auto pb-4 mb-6 sticky top-0 bg-white z-10"> ['All', 'Viral', 'Movies', 'Music', 'Gaming'].map(cat => ( <button key=cat className="px-4 py-2 rounded-full bg-gray-100 hover:bg-gray-200 whitespace-nowrap"> cat </button> )) </div> prisma.userInteraction.create( data: userId: req.user.id

# Gravity factor (newer content gets boost) gravity = 1.5 if hours_since_publish < 24 else 1.8

// Trigger async recalc of trendScore queue.add('recalc-trending', contentId );

// Add user-specific interaction status if (req.user) for (const item of trendingContent) item.userLiked = await prisma.userLike.findUnique( where: userId_contentId: userId: req.user.id, contentId: item.id ) !== null;

# Apply recency bonus if hours_since_publish < 2: score *= 1.5 return round(score, 6) // GET /api/trending/feed router.get('/feed', async (req, res) => { const limit = 20, offset = 0, contentType, category = req.query; const whereClause = {}; if (contentType) whereClause.contentType = contentType; if (category) whereClause.category = category;