arches.io epoch.rb - a trick for remembering

07 May 2013

Make a file called epoch.rb in your project (I put mine in config/initializers). Use it to store constants that represent the times when big dev events happened. For example:

CART_RELEASE = Time.local(2013, 04, 22, 13, 45)

We released our shopping cart at 1:45pm on 4/22. Fast forward to today: some of our stats are messed up, for deals that were live across the cart release. I need to fix the stats, but I only want to do it for the affected deals. It's this simple:

Deal.where("starts_at < ? and ends_at > ?", CART_RELEASE, CART_RELEASE)

That was WAY easier than digging around in git.