PERF: Avoid hitting DB when fetching draft sequence of bot user.

This commit is contained in:
Guo Xiang Tan
2020-05-12 13:56:24 +08:00
parent 39a2d90e0f
commit d301af39bd
2 changed files with 17 additions and 3 deletions

View File

@ -23,6 +23,8 @@ class DraftSequence < ActiveRecord::Base
user_id = user
user_id = user.id unless user.is_a?(Integer)
return nil if user_id < 0
# perf critical path
r, _ = DB.query_single('select sequence from draft_sequences where user_id = ? and draft_key = ?', user_id, key)
r.to_i