Martin Tithonium (tithonium) wrote,
Martin Tithonium
tithonium

This is so cheating. But balancing between readable code and using a function the way it's intended, I'll go for the former.

What I 'should' be doing:
@errors[:frequency] = true if Comment.find_by_sql(%Q[SELECT (now() - insert_time) as seconds FROM gmap_comments WHERE email="#{@user.email}" ORDER BY insert_time DESC LIMIT 1])[0].seconds < 180


What I /am/ doing:
@errors[:frequency] = true if Comment.count_by_sql(%Q[SELECT (now() - insert_time) FROM gmap_comments WHERE email="#{@user.email}" ORDER BY insert_time DESC LIMIT 1]) < 180



Of course, they'll have to go and change the way count_by_sql behaves in the next version, just to fuck with me.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 3 comments