Calculate Point Rewards
Calculate both points_total and points_pending for all active users.
Calculation
points_total: the sum of all non-expired point transactions for a user, regardless of redemption status.points_pending: the sum of points that have been earned but not yet confirmed (e.g., from bookings not yet completed).
points_total = user.point_transactions.where(expired: false).sum(:points)
points_pending = user.point_transactions.where(confirmed: false, expired: false).sum(:points)
Do not base calculations on the
redeemedstatus orexpiry_datefield directly. Use theexpiredboolean flag instead.