mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -9,7 +9,7 @@ class TopicUser < ActiveRecord::Base
|
||||
|
||||
scope :tracking, lambda { |topic_id|
|
||||
where(topic_id: topic_id)
|
||||
.where("COALESCE(topic_users.notification_level, :regular) >= :tracking",
|
||||
.where("COALESCE(topic_users.notification_level, :regular) >= :tracking",
|
||||
regular: TopicUser.notification_levels[:regular],
|
||||
tracking: TopicUser.notification_levels[:tracking])
|
||||
}
|
||||
@ -159,22 +159,22 @@ SQL
|
||||
|
||||
unless attrs[:notification_level]
|
||||
category_notification_level = CategoryUser.where(user_id: user_id)
|
||||
.where("category_id IN (SELECT category_id FROM topics WHERE id = :id)", id: topic_id)
|
||||
.where("notification_level IN (:levels)", levels: [CategoryUser.notification_levels[:watching],
|
||||
.where("category_id IN (SELECT category_id FROM topics WHERE id = :id)", id: topic_id)
|
||||
.where("notification_level IN (:levels)", levels: [CategoryUser.notification_levels[:watching],
|
||||
CategoryUser.notification_levels[:tracking]])
|
||||
.order("notification_level DESC")
|
||||
.limit(1)
|
||||
.pluck(:notification_level)
|
||||
.first
|
||||
.order("notification_level DESC")
|
||||
.limit(1)
|
||||
.pluck(:notification_level)
|
||||
.first
|
||||
|
||||
tag_notification_level = TagUser.where(user_id: user_id)
|
||||
.where("tag_id IN (SELECT tag_id FROM topic_tags WHERE topic_id = :id)", id: topic_id)
|
||||
.where("notification_level IN (:levels)", levels: [CategoryUser.notification_levels[:watching],
|
||||
.where("tag_id IN (SELECT tag_id FROM topic_tags WHERE topic_id = :id)", id: topic_id)
|
||||
.where("notification_level IN (:levels)", levels: [CategoryUser.notification_levels[:watching],
|
||||
CategoryUser.notification_levels[:tracking]])
|
||||
.order("notification_level DESC")
|
||||
.limit(1)
|
||||
.pluck(:notification_level)
|
||||
.first
|
||||
.order("notification_level DESC")
|
||||
.limit(1)
|
||||
.pluck(:notification_level)
|
||||
.first
|
||||
|
||||
if category_notification_level && !(tag_notification_level && (tag_notification_level > category_notification_level))
|
||||
attrs[:notification_level] = category_notification_level
|
||||
@ -191,7 +191,6 @@ SQL
|
||||
TopicUser.notification_reasons[:auto_track_tag]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
unless attrs[:notification_level]
|
||||
@ -203,7 +202,7 @@ SQL
|
||||
end
|
||||
end
|
||||
|
||||
TopicUser.create(attrs.merge!(user_id: user_id, topic_id: topic_id, first_visited_at: now ,last_visited_at: now))
|
||||
TopicUser.create(attrs.merge!(user_id: user_id, topic_id: topic_id, first_visited_at: now , last_visited_at: now))
|
||||
end
|
||||
|
||||
def track_visit!(topic_id, user_id)
|
||||
@ -256,7 +255,7 @@ SQL
|
||||
|
||||
INSERT_TOPIC_USER_SQL_STAFF = INSERT_TOPIC_USER_SQL.gsub("highest_post_number", "highest_staff_post_number")
|
||||
|
||||
def update_last_read(user, topic_id, post_number, msecs, opts={})
|
||||
def update_last_read(user, topic_id, post_number, msecs, opts = {})
|
||||
return if post_number.blank?
|
||||
msecs = 0 if msecs.to_i < 0
|
||||
|
||||
@ -276,11 +275,12 @@ SQL
|
||||
# ... user visited the topic but did not read the posts
|
||||
#
|
||||
# 86400000 = 1 day
|
||||
rows = if user.staff?
|
||||
exec_sql(UPDATE_TOPIC_USER_SQL_STAFF,args).values
|
||||
else
|
||||
exec_sql(UPDATE_TOPIC_USER_SQL,args).values
|
||||
end
|
||||
rows =
|
||||
if user.staff?
|
||||
exec_sql(UPDATE_TOPIC_USER_SQL_STAFF, args).values
|
||||
else
|
||||
exec_sql(UPDATE_TOPIC_USER_SQL, args).values
|
||||
end
|
||||
|
||||
if rows.length == 1
|
||||
before = rows[0][1].to_i
|
||||
@ -332,7 +332,7 @@ SQL
|
||||
|
||||
end
|
||||
|
||||
def self.update_post_action_cache(opts={})
|
||||
def self.update_post_action_cache(opts = {})
|
||||
user_id = opts[:user_id]
|
||||
post_id = opts[:post_id]
|
||||
topic_id = opts[:topic_id]
|
||||
@ -412,7 +412,7 @@ SQL
|
||||
TopicUser.exec_sql(sql, user_id: user_id, count: count)
|
||||
end
|
||||
|
||||
def self.ensure_consistency!(topic_id=nil)
|
||||
def self.ensure_consistency!(topic_id = nil)
|
||||
update_post_action_cache(topic_id: topic_id)
|
||||
|
||||
# TODO this needs some reworking, when we mark stuff skipped
|
||||
|
Reference in New Issue
Block a user