From 83255d94d932aa718a9714f8e51c8d79b9c0f0ac Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 14 May 2018 16:26:14 +0200 Subject: [PATCH] DateGroupable is not used anymore --- app/models/concerns/date_groupable.rb | 52 --------------------------- app/models/topic.rb | 1 - app/models/user.rb | 1 - app/models/user_action.rb | 1 - 4 files changed, 55 deletions(-) delete mode 100644 app/models/concerns/date_groupable.rb diff --git a/app/models/concerns/date_groupable.rb b/app/models/concerns/date_groupable.rb deleted file mode 100644 index 03cdae08cf7..00000000000 --- a/app/models/concerns/date_groupable.rb +++ /dev/null @@ -1,52 +0,0 @@ -module DateGroupable extend ActiveSupport::Concern - class_methods do - def group_by_day(column) - group_by_unit(:day, column) - end - - def group_by_week(column) - group_by_unit(:week, column) - end - - def group_by_month(column) - group_by_unit(:month, column) - end - - def group_by_quarter(column) - group_by_unit(:quarter, column) - end - - def group_by_year(column) - group_by_unit(:year, column) - end - - def group_by_unit(aggregation_unit, column) - group("date_trunc('#{aggregation_unit}', #{column})::DATE") - .order("date_trunc('#{aggregation_unit}', #{column})::DATE") - end - - def aggregation_unit_for_period(start_date, end_date) - days = (start_date.to_date..end_date.to_date).count - - case - when days <= 40 - return :day - when days <= 210 # 30 weeks - return :week - when days <= 550 # ~18 months - return :month - when days <= 1461 # ~4 years - return :quarter - else - return :year - end - end - - def smart_group_by_date(column, start_date, end_date) - aggregation_unit = aggregation_unit_for_period(start_date, end_date) - - where("#{column} BETWEEN ? AND ?", start_date, end_date) - .group_by_unit(aggregation_unit, column) - end - end -end diff --git a/app/models/topic.rb b/app/models/topic.rb index e986d4ebdb2..4ee00680016 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -21,7 +21,6 @@ class Topic < ActiveRecord::Base include Searchable include LimitedEdit extend Forwardable - include DateGroupable def_delegator :featured_users, :user_ids, :featured_user_ids def_delegator :featured_users, :choose, :feature_topic_users diff --git a/app/models/user.rb b/app/models/user.rb index 2913c8acaed..2305cd32c38 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,6 @@ class User < ActiveRecord::Base include Roleable include HasCustomFields include SecondFactorManager - include DateGroupable # TODO: Remove this after 7th Jan 2018 self.ignored_columns = %w{email} diff --git a/app/models/user_action.rb b/app/models/user_action.rb index baa540c252f..20a3acde6cd 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -1,5 +1,4 @@ class UserAction < ActiveRecord::Base - include DateGroupable belongs_to :user belongs_to :target_post, class_name: "Post"