minor cleanup, using AR querying DSL over raw SQL in some places

This commit is contained in:
Gosha Arinich
2013-02-28 21:54:12 +03:00
parent 93a257707e
commit 6e5399d544
41 changed files with 230 additions and 341 deletions

View File

@@ -2,7 +2,7 @@ class DraftSequence < ActiveRecord::Base
def self.next!(user,key)
user_id = user
user_id = user.id unless user.class == Fixnum
h = {user_id: user_id, draft_key: key}
h = { user_id: user_id, draft_key: key }
c = DraftSequence.where(h).first
c ||= DraftSequence.new(h)
c.sequence ||= 0
@@ -20,10 +20,6 @@ class DraftSequence < ActiveRecord::Base
# perf critical path
r = exec_sql('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key).values
if r.length == 0
0
else
r[0][0].to_i
end
r.length.zero? ? 0 : r[0][0].to_i
end
end