removed usless access modifiers specified in models

This commit is contained in:
Akshay 2014-08-19 07:28:21 +05:30
parent 1a2070b4d9
commit 9d11ccc42e
13 changed files with 61 additions and 87 deletions

View file

@ -194,14 +194,13 @@ class AdminDashboardData
I18n.t(i18n_key)
end
end
def self.report_access_password_removal
$redis.setex access_password_removal_key, 172_800, 'dashboard.access_password_removal'
end
private
def self.access_password_removal_key
'dash-data:access_password_removal'
end
def self.access_password_removal_key
'dash-data:access_password_removal'
end
end

View file

@ -35,14 +35,13 @@ class CategoryFeaturedTopic < ActiveRecord::Base
end
end
private
def self.fake_admin
# fake an admin
admin = User.new
admin.admin = true
admin.id = -1
admin
end
def self.fake_admin
# fake an admin
admin = User.new
admin.admin = true
admin.id = -1
admin
end
end

View file

@ -60,8 +60,6 @@ class CategoryUser < ActiveRecord::Base
end
end
private
def self.apply_default_to_topic(topic, level, reason)
# Can not afford to slow down creation of topics when a pile of users are watching new topics, reverting to SQL for max perf here
sql = <<SQL

View file

@ -27,8 +27,6 @@ class Draft < ActiveRecord::Base
end
end
protected
def self.find_draft(user, key)
if user.is_a?(User)
find_by(user_id: user.id, draft_key: key)

View file

@ -85,8 +85,6 @@ class ErrorLog
end
end
private
def self.sanitize_backtrace(trace)
re = Regexp.new(/^#{Regexp.escape(Rails.root.to_s)}/)
trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }

View file

@ -80,8 +80,6 @@ class GlobalSetting
@data.keys
end
private
def self.parse(file)
provider = self.new(file)
provider.read

View file

@ -12,9 +12,6 @@ class LocaleSiteSetting < EnumSiteSetting
end
end
private
@lock = Mutex.new
def self.supported_locales

View file

@ -26,10 +26,6 @@ class PluginStore
PluginStoreRow.where(plugin_name: plugin_name, key: key).destroy_all
end
protected
def self.determine_type(value)
value.is_a?(Hash) || value.is_a?(Array) ? "JSON" : value.class.to_s
end

View file

@ -431,8 +431,6 @@ class PostAction < ActiveRecord::Base
PostActionType.types[post_action.post_action_type_id]
end
protected
def self.target_moderators
Group[:moderators].name
end

View file

@ -9,8 +9,6 @@ class S3RegionSiteSetting < EnumSiteSetting
@values ||= valid_values.sort.map {|x| {name: x, value: x} }
end
private
def self.valid_values
[ '',
'us-east-1',

View file

@ -28,25 +28,24 @@ class TopTopic < ActiveRecord::Base
TopTopic.refresh_older!
end
private
def self.periods
@@periods ||= [:yearly, :monthly, :weekly, :daily].freeze
def self.periods
@@periods ||= [:yearly, :monthly, :weekly, :daily].freeze
end
def self.sort_orders
@@sort_orders ||= [:posts, :views, :likes].freeze
end
def self.update_counts_and_compute_scores_for(period)
TopTopic.sort_orders.each do |sort|
TopTopic.send("update_#{sort}_count_for", period)
end
TopTopic.compute_top_score_for(period)
end
def self.sort_orders
@@sort_orders ||= [:posts, :views, :likes].freeze
end
def self.update_counts_and_compute_scores_for(period)
TopTopic.sort_orders.each do |sort|
TopTopic.send("update_#{sort}_count_for", period)
end
TopTopic.compute_top_score_for(period)
end
def self.remove_invisible_topics
exec_sql("WITH category_definition_topic_ids AS (
def self.remove_invisible_topics
exec_sql("WITH category_definition_topic_ids AS (
SELECT COALESCE(topic_id, 0) AS id FROM categories
), invisible_topic_ids AS (
SELECT id
@ -59,11 +58,11 @@ class TopTopic < ActiveRecord::Base
)
DELETE FROM top_topics
WHERE topic_id IN (SELECT id FROM invisible_topic_ids)",
private_message: Archetype::private_message)
end
private_message: Archetype::private_message)
end
def self.add_new_visible_topics
exec_sql("WITH category_definition_topic_ids AS (
def self.add_new_visible_topics
exec_sql("WITH category_definition_topic_ids AS (
SELECT COALESCE(topic_id, 0) AS id FROM categories
), visible_topics AS (
SELECT t.id
@ -78,11 +77,11 @@ class TopTopic < ActiveRecord::Base
)
INSERT INTO top_topics (topic_id)
SELECT id FROM visible_topics",
private_message: Archetype::private_message)
end
private_message: Archetype::private_message)
end
def self.update_posts_count_for(period)
sql = "SELECT topic_id, GREATEST(COUNT(*), 1) AS count
def self.update_posts_count_for(period)
sql = "SELECT topic_id, GREATEST(COUNT(*), 1) AS count
FROM posts
WHERE created_at >= :from
AND deleted_at IS NULL
@ -91,20 +90,20 @@ class TopTopic < ActiveRecord::Base
AND user_id <> #{Discourse.system_user.id}
GROUP BY topic_id"
TopTopic.update_top_topics(period, "posts", sql)
end
TopTopic.update_top_topics(period, "posts", sql)
end
def self.update_views_count_for(period)
sql = "SELECT topic_id, COUNT(*) AS count
def self.update_views_count_for(period)
sql = "SELECT topic_id, COUNT(*) AS count
FROM topic_views
WHERE viewed_at >= :from
GROUP BY topic_id"
TopTopic.update_top_topics(period, "views", sql)
end
TopTopic.update_top_topics(period, "views", sql)
end
def self.update_likes_count_for(period)
sql = "SELECT topic_id, GREATEST(SUM(like_count), 1) AS count
def self.update_likes_count_for(period)
sql = "SELECT topic_id, GREATEST(SUM(like_count), 1) AS count
FROM posts
WHERE created_at >= :from
AND deleted_at IS NULL
@ -112,11 +111,11 @@ class TopTopic < ActiveRecord::Base
AND post_type = #{Post.types[:regular]}
GROUP BY topic_id"
TopTopic.update_top_topics(period, "likes", sql)
end
TopTopic.update_top_topics(period, "likes", sql)
end
def self.compute_top_score_for(period)
sql = <<-SQL
def self.compute_top_score_for(period)
sql = <<-SQL
WITH top AS (
SELECT CASE
WHEN topics.created_at < :from THEN 0
@ -131,29 +130,29 @@ class TopTopic < ActiveRecord::Base
FROM top
WHERE top_topics.topic_id = top.topic_id
AND #{period}_score <> top.score
SQL
SQL
exec_sql(sql, from: start_of(period))
exec_sql(sql, from: start_of(period))
end
def self.start_of(period)
case period
when :yearly then 1.year.ago
when :monthly then 1.month.ago
when :weekly then 1.week.ago
when :daily then 1.day.ago
end
end
def self.start_of(period)
case period
when :yearly then 1.year.ago
when :monthly then 1.month.ago
when :weekly then 1.week.ago
when :daily then 1.day.ago
end
end
def self.update_top_topics(period, sort, inner_join)
exec_sql("UPDATE top_topics
def self.update_top_topics(period, sort, inner_join)
exec_sql("UPDATE top_topics
SET #{period}_#{sort}_count = c.count
FROM top_topics tt
INNER JOIN (#{inner_join}) c ON tt.topic_id = c.topic_id
WHERE tt.topic_id = top_topics.topic_id
AND tt.#{period}_#{sort}_count <> c.count",
from: start_of(period))
end
from: start_of(period))
end
end

View file

@ -10,8 +10,6 @@ class TrustLevelSetting < EnumSiteSetting
@values ||= valid_values.map {|x| {name: x.to_s, value: x} }
end
private
def self.valid_values
TrustLevel.levels.values.sort
end

View file

@ -271,8 +271,6 @@ SQL
self.synchronize_starred
end
protected
def self.update_like_count(user_id, action_type, delta)
if action_type == LIKE
UserStat.where(user_id: user_id).update_all("likes_given = likes_given + #{delta.to_i}")