Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Give Reward Points to Users

This script grants reward points to specific users for a campaign. Use it for one-time manual reward grants after validation from Product/CRM.

Safety notes

  • Run in controlled environment.
  • Validate user IDs before execution.
  • Keep a rollback list of created reward IDs.

Script

# How to run: rails runner give_reward_points.rb

rows = [
  '817882, 110, CNY Promo 2025 - Booking ID 4127737',
  '465633, 110, CNY Promo 2025 - Booking ID 4149207'
]

rows.each do |row|
  user_id, points, description = row.split(',').map(&:strip)

  reward = Reward.new(
    user_id: user_id.to_i,
    expiry_date: Date.today + 10.years,
    points_total: points.to_i,
    points_pending: 0,
    description: description,
    redeemed: false
  )
  reward.save!

  puts Reward.where(description: description).pluck(:id, :description)
end