…onsistency, and ref typing
- Strip NULL actor IDs from array before slicing in grouped notifications CTE
using array_remove(), ensuring we get up to 3 real actors
- Reorder JS mapping to zip arrays first then filter nulls, preserving index
alignment between actorIds, actorDisplayNames, and actorAvatarUrls
- Add migration 0054 to update vote_counts trigger fallback from NOW() to
MIN(votes.created_at), matching the backfill logic and preventing hot_score
drift when previously-backfilled entities receive new votes
- Fix useRef type parameter to include null for consistency with RefObject type
https://claude.ai/code/session_017BNXBJR7yWabEhFCeKk9Pz
Summary
This PR fixes an inconsistency in hot score calculations for vote counts by ensuring the
update_vote_countstrigger uses the same fallback logic as the backfill migration.Key Changes
update_vote_countstrigger to useMIN(votes.created_at)as the fallback timestamp instead ofNOW()when no existing feed_items row exists. This ensures consistency with the backfill logic in migration 0053.ORDER Bclause was present.Implementation Details
The issue occurred because when a previously-backfilled entity received a new vote, the trigger would recalculate the hot_score using the current timestamp (
NOW()) instead of preserving the original earliest vote time. This caused hot_score values to be inconsistent depending on whether they were calculated during backfill or during subsequent vote updates. By usingMIN(votes.created_at)as the fallback in both places, we ensure deterministic and consistent hot_score calculations across all scenarios.https://claude.ai/code/session_017BNXBJR7yWabEhFCeKk9Pz