DEV: Rails 5.2 upgrade and global gem upgrade

This updates tests to use latest rails 5 practice
and updates ALL dependencies that could be updated

Performance testing shows that performance has not regressed
if anything it is marginally faster now.
This commit is contained in:
Sam
2018-06-07 14:21:33 +10:00
parent 2bd905c632
commit 89ad2b5900
103 changed files with 900 additions and 864 deletions
+1 -7
View File
@@ -46,13 +46,7 @@ module Trashable
private
def trash_update(deleted_at, deleted_by_id)
# see: https://github.com/rails/rails/issues/8436
#
# Fixed in Rails 4
#
self.class.unscoped.where(id: self.id).update_all(deleted_at: deleted_at, deleted_by_id: deleted_by_id)
raw_write_attribute :deleted_at, deleted_at
raw_write_attribute :deleted_by_id, deleted_by_id
self.update_columns(deleted_at: deleted_at, deleted_by_id: deleted_by_id)
end
end
+4 -3
View File
@@ -166,13 +166,14 @@ class Invite < ActiveRecord::Base
group_ids
end
INVITE_ORDER = <<~SQL
SQL
def self.find_all_invites_from(inviter, offset = 0, limit = SiteSetting.invites_per_page)
Invite.where(invited_by_id: inviter.id)
.where('invites.email IS NOT NULL')
.includes(user: :user_stat)
.order('CASE WHEN invites.user_id IS NOT NULL THEN 0 ELSE 1 END',
'user_stats.time_read DESC',
'invites.redeemed_at DESC')
.order("CASE WHEN invites.user_id IS NOT NULL THEN 0 ELSE 1 END, user_stats.time_read DESC, invites.redeemed_at DESC")
.limit(limit)
.offset(offset)
.references('user_stats')
+9 -2
View File
@@ -654,11 +654,18 @@ class Post < ActiveRecord::Base
result = public_posts.where('posts.created_at >= ? AND posts.created_at <= ?', start_date, end_date)
.where(post_type: Post.types[:regular])
result = result.where('topics.category_id = ?', category_id) if category_id
result.group('date(posts.created_at)').order('date(posts.created_at)').count
result
.group('date(posts.created_at)')
.order('date(posts.created_at)')
.count
end
def self.private_messages_count_per_day(start_date, end_date, topic_subtype)
private_posts.with_topic_subtype(topic_subtype).where('posts.created_at >= ? AND posts.created_at <= ?', start_date, end_date).group('date(posts.created_at)').order('date(posts.created_at)').count
private_posts.with_topic_subtype(topic_subtype)
.where('posts.created_at >= ? AND posts.created_at <= ?', start_date, end_date)
.group('date(posts.created_at)')
.order('date(posts.created_at)')
.count
end
def reply_history(max_replies = 100, guardian = nil)
+1 -1
View File
@@ -217,7 +217,7 @@ class PostMover
attrs[:last_posted_at] = post.created_at
attrs[:last_post_user_id] = post.user_id
attrs[:bumped_at] = post.created_at unless post.no_bump
attrs[:updated_at] = 'now()'
attrs[:updated_at] = Time.now
destination_topic.update_columns(attrs)
end
end
+7 -2
View File
@@ -278,7 +278,7 @@ class Topic < ActiveRecord::Base
def ensure_topic_has_a_category
if category_id.nil? && (archetype.nil? || self.regular?)
self.category_id = SiteSetting.uncategorized_category_id
self.category_id = category&.id || SiteSetting.uncategorized_category_id
end
end
@@ -1334,7 +1334,12 @@ SQL
end
def self.private_message_topics_count_per_day(start_date, end_date, topic_subtype)
private_messages.with_subtype(topic_subtype).where('topics.created_at >= ? AND topics.created_at <= ?', start_date, end_date).group('date(topics.created_at)').order('date(topics.created_at)').count
private_messages
.with_subtype(topic_subtype)
.where('topics.created_at >= ? AND topics.created_at <= ?', start_date, end_date)
.group('date(topics.created_at)')
.order('date(topics.created_at)')
.count
end
def is_category_topic?
+1 -1
View File
@@ -844,7 +844,7 @@ class User < ActiveRecord::Base
if start_date && end_date
result = result.group("date(users.created_at)")
result = result.where("users.created_at >= ? AND users.created_at <= ?", start_date, end_date)
result = result.order('date(users.created_at)')
result = result.order("date(users.created_at)")
end
if group_id