mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add quarterly period to Top page
This commit is contained in:
@@ -106,6 +106,7 @@ const controllerOpts = {
|
|||||||
new: Discourse.computed.endWith('model.filter', 'new'),
|
new: Discourse.computed.endWith('model.filter', 'new'),
|
||||||
top: Em.computed.notEmpty('period'),
|
top: Em.computed.notEmpty('period'),
|
||||||
yearly: Em.computed.equal('period', 'yearly'),
|
yearly: Em.computed.equal('period', 'yearly'),
|
||||||
|
quarterly: Em.computed.equal('period', 'quarterly'),
|
||||||
monthly: Em.computed.equal('period', 'monthly'),
|
monthly: Em.computed.equal('period', 'monthly'),
|
||||||
weekly: Em.computed.equal('period', 'weekly'),
|
weekly: Em.computed.equal('period', 'weekly'),
|
||||||
daily: Em.computed.equal('period', 'daily'),
|
daily: Em.computed.equal('period', 'daily'),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const TITLE_SUBS = {
|
const TITLE_SUBS = {
|
||||||
all: 'all_time',
|
all: 'all_time',
|
||||||
yearly: 'this_year',
|
yearly: 'this_year',
|
||||||
|
quarterly: 'this_quarter',
|
||||||
monthly: 'this_month',
|
monthly: 'this_month',
|
||||||
daily: 'today',
|
daily: 'today',
|
||||||
};
|
};
|
||||||
@@ -13,6 +14,9 @@ export default Ember.Handlebars.makeBoundHelper(function (period, options) {
|
|||||||
case 'yearly':
|
case 'yearly':
|
||||||
dateString = moment().subtract(1, 'year').format(I18n.t('dates.long_with_year_no_time')) + " - " + moment().format(I18n.t('dates.long_with_year_no_time'));
|
dateString = moment().subtract(1, 'year').format(I18n.t('dates.long_with_year_no_time')) + " - " + moment().format(I18n.t('dates.long_with_year_no_time'));
|
||||||
break;
|
break;
|
||||||
|
case 'quarterly':
|
||||||
|
dateString = moment().subtract(3, 'month').format(I18n.t('dates.long_no_year_no_time')) + " - " + moment().format(I18n.t('dates.long_no_year_no_time'));
|
||||||
|
break;
|
||||||
case 'weekly':
|
case 'weekly':
|
||||||
dateString = moment().subtract(1, 'week').format(I18n.t('dates.long_no_year_no_time')) + " - " + moment().format(I18n.t('dates.long_no_year_no_time'));
|
dateString = moment().subtract(1, 'week').format(I18n.t('dates.long_no_year_no_time')) + " - " + moment().format(I18n.t('dates.long_no_year_no_time'));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class TopTopic < ActiveRecord::Base
|
|||||||
|
|
||||||
|
|
||||||
def self.periods
|
def self.periods
|
||||||
@@periods ||= [:all, :yearly, :monthly, :weekly, :daily].freeze
|
@@periods ||= [:all, :yearly, :quarterly, :monthly, :weekly, :daily].freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sort_orders
|
def self.sort_orders
|
||||||
@@ -183,6 +183,7 @@ class TopTopic < ActiveRecord::Base
|
|||||||
case period
|
case period
|
||||||
when :yearly then 1.year.ago
|
when :yearly then 1.year.ago
|
||||||
when :monthly then 1.month.ago
|
when :monthly then 1.month.ago
|
||||||
|
when :quarterly then 3.months.ago
|
||||||
when :weekly then 1.week.ago
|
when :weekly then 1.week.ago
|
||||||
when :daily then 1.day.ago
|
when :daily then 1.day.ago
|
||||||
end
|
end
|
||||||
@@ -221,24 +222,42 @@ end
|
|||||||
# daily_posts_count :integer default(0), not null
|
# daily_posts_count :integer default(0), not null
|
||||||
# daily_views_count :integer default(0), not null
|
# daily_views_count :integer default(0), not null
|
||||||
# daily_likes_count :integer default(0), not null
|
# daily_likes_count :integer default(0), not null
|
||||||
# yearly_score :float default(0.0)
|
|
||||||
# monthly_score :float default(0.0)
|
|
||||||
# weekly_score :float default(0.0)
|
|
||||||
# daily_score :float default(0.0)
|
# daily_score :float default(0.0)
|
||||||
|
# weekly_score :float default(0.0)
|
||||||
|
# monthly_score :float default(0.0)
|
||||||
|
# yearly_score :float default(0.0)
|
||||||
|
# all_score :float default(0.0)
|
||||||
|
# daily_op_likes_count :integer default(0), not null
|
||||||
|
# weekly_op_likes_count :integer default(0), not null
|
||||||
|
# monthly_op_likes_count :integer default(0), not null
|
||||||
|
# yearly_op_likes_count :integer default(0), not null
|
||||||
|
# quarterly_posts_count :integer default(0), not null
|
||||||
|
# quarterly_views_count :integer default(0), not null
|
||||||
|
# quarterly_likes_count :integer default(0), not null
|
||||||
|
# quarterly_score :float default(0.0)
|
||||||
|
# quarterly_op_likes_count :integer default(0), not null
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_top_topics_on_daily_likes_count (daily_likes_count)
|
# index_top_topics_on_daily_likes_count (daily_likes_count)
|
||||||
|
# index_top_topics_on_daily_op_likes_count (daily_op_likes_count)
|
||||||
# index_top_topics_on_daily_posts_count (daily_posts_count)
|
# index_top_topics_on_daily_posts_count (daily_posts_count)
|
||||||
# index_top_topics_on_daily_views_count (daily_views_count)
|
# index_top_topics_on_daily_views_count (daily_views_count)
|
||||||
# index_top_topics_on_monthly_likes_count (monthly_likes_count)
|
# index_top_topics_on_monthly_likes_count (monthly_likes_count)
|
||||||
|
# index_top_topics_on_monthly_op_likes_count (monthly_op_likes_count)
|
||||||
# index_top_topics_on_monthly_posts_count (monthly_posts_count)
|
# index_top_topics_on_monthly_posts_count (monthly_posts_count)
|
||||||
# index_top_topics_on_monthly_views_count (monthly_views_count)
|
# index_top_topics_on_monthly_views_count (monthly_views_count)
|
||||||
|
# index_top_topics_on_quarterly_likes_count (quarterly_likes_count)
|
||||||
|
# index_top_topics_on_quarterly_op_likes_count (quarterly_op_likes_count)
|
||||||
|
# index_top_topics_on_quarterly_posts_count (quarterly_posts_count)
|
||||||
|
# index_top_topics_on_quarterly_views_count (quarterly_views_count)
|
||||||
# index_top_topics_on_topic_id (topic_id) UNIQUE
|
# index_top_topics_on_topic_id (topic_id) UNIQUE
|
||||||
# index_top_topics_on_weekly_likes_count (weekly_likes_count)
|
# index_top_topics_on_weekly_likes_count (weekly_likes_count)
|
||||||
|
# index_top_topics_on_weekly_op_likes_count (weekly_op_likes_count)
|
||||||
# index_top_topics_on_weekly_posts_count (weekly_posts_count)
|
# index_top_topics_on_weekly_posts_count (weekly_posts_count)
|
||||||
# index_top_topics_on_weekly_views_count (weekly_views_count)
|
# index_top_topics_on_weekly_views_count (weekly_views_count)
|
||||||
# index_top_topics_on_yearly_likes_count (yearly_likes_count)
|
# index_top_topics_on_yearly_likes_count (yearly_likes_count)
|
||||||
|
# index_top_topics_on_yearly_op_likes_count (yearly_op_likes_count)
|
||||||
# index_top_topics_on_yearly_posts_count (yearly_posts_count)
|
# index_top_topics_on_yearly_posts_count (yearly_posts_count)
|
||||||
# index_top_topics_on_yearly_views_count (yearly_views_count)
|
# index_top_topics_on_yearly_views_count (yearly_views_count)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1669,6 +1669,8 @@ en:
|
|||||||
title: "All Time"
|
title: "All Time"
|
||||||
yearly:
|
yearly:
|
||||||
title: "Yearly"
|
title: "Yearly"
|
||||||
|
quarterly:
|
||||||
|
title: "Quarterly"
|
||||||
monthly:
|
monthly:
|
||||||
title: "Monthly"
|
title: "Monthly"
|
||||||
weekly:
|
weekly:
|
||||||
@@ -1677,6 +1679,7 @@ en:
|
|||||||
title: "Daily"
|
title: "Daily"
|
||||||
all_time: "All Time"
|
all_time: "All Time"
|
||||||
this_year: "Year"
|
this_year: "Year"
|
||||||
|
this_quarter: "Quarter"
|
||||||
this_month: "Month"
|
this_month: "Month"
|
||||||
this_week: "Week"
|
this_week: "Week"
|
||||||
today: "Today"
|
today: "Today"
|
||||||
|
|||||||
14
db/migrate/20150727210748_add_quarterly_to_top_topics.rb
Normal file
14
db/migrate/20150727210748_add_quarterly_to_top_topics.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class AddQuarterlyToTopTopics < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :top_topics, :quarterly_posts_count, :integer, default: 0, null: false
|
||||||
|
add_column :top_topics, :quarterly_views_count, :integer, default: 0, null: false
|
||||||
|
add_column :top_topics, :quarterly_likes_count, :integer, default: 0, null: false
|
||||||
|
add_column :top_topics, :quarterly_score, :float, default: 0.0
|
||||||
|
add_column :top_topics, :quarterly_op_likes_count, :integer, default: 0, null: false
|
||||||
|
|
||||||
|
add_index :top_topics, [:quarterly_posts_count]
|
||||||
|
add_index :top_topics, [:quarterly_views_count]
|
||||||
|
add_index :top_topics, [:quarterly_likes_count]
|
||||||
|
add_index :top_topics, [:quarterly_op_likes_count]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -49,6 +49,7 @@ export default {
|
|||||||
],
|
],
|
||||||
"periods":[
|
"periods":[
|
||||||
"yearly",
|
"yearly",
|
||||||
|
"quarterly",
|
||||||
"monthly",
|
"monthly",
|
||||||
"weekly",
|
"weekly",
|
||||||
"daily"
|
"daily"
|
||||||
|
|||||||
Reference in New Issue
Block a user