mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
Improve specs.
This commit is contained in:
@ -10,7 +10,7 @@ class DraftSequence < ActiveRecord::Base
|
||||
c ||= DraftSequence.new(h)
|
||||
c.sequence ||= 0
|
||||
c.sequence += 1
|
||||
c.save
|
||||
c.save!
|
||||
exec_sql("DELETE FROM drafts WHERE user_id = :user_id AND draft_key = :draft_key AND sequence < :sequence", draft_key: key, user_id: user_id, sequence: c.sequence)
|
||||
c.sequence
|
||||
end
|
||||
@ -23,8 +23,7 @@ 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
|
||||
|
||||
r.length.zero? ? 0 : r[0][0].to_i
|
||||
r.length.zero? ? 0 : r[0][0]
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user