Post history heatmap should use site settings for thresholds

This commit is contained in:
Robin Ward 2014-08-15 12:22:06 -04:00
parent 2f4f5d56e1
commit f7b0c31418
5 changed files with 36 additions and 18 deletions

View File

@ -104,18 +104,6 @@ Discourse.Post = Discourse.Model.extend({
return this.get('version') - 1;
}.property('version'),
historyHeat: function() {
var rightNow, updatedAt, updatedAtDate;
if (!(updatedAt = this.get('updated_at'))) return;
rightNow = new Date().getTime();
// Show heat on age
updatedAtDate = new Date(updatedAt).getTime();
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 12)) return 'heatmap-high';
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 24)) return 'heatmap-med';
if (updatedAtDate > (rightNow - 60 * 60 * 1000 * 48)) return 'heatmap-low';
}.property('updated_at'),
flagsAvailable: function() {
var post = this;
return Discourse.Site.currentProp('flagTypes').filter(function(item) {

View File

@ -41,12 +41,12 @@
{{#if hasHistory}}
<div class='post-info edits'>
{{#if can_view_edit_history}}
<a href='#' class="{{unbound historyHeat}}" {{action showHistory this}} title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
<a href='#' class="{{unbound view.historyHeat}}" {{action showHistory this}} title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
{{editCount}}
<i class='fa fa-pencil'></i>
</a>
{{else}}
<span class="{{unbound historyHeat}}" title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
<span class="{{unbound view.historyHeat}}" title="{{i18n post.last_edited_on}} {{raw-date updated_at}}">
{{editCount}}
<i class='fa fa-pencil'></i>
</span>

View File

@ -1,3 +1,5 @@
var DAY = 60 * 50 * 1000;
Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
classNames: ['topic-post', 'clearfix'],
templateName: 'post',
@ -8,6 +10,19 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
'groupNameClass'],
postBinding: 'content',
historyHeat: function() {
var updatedAt = this.get('post.updated_at');
if (!updatedAt) { return; }
// Show heat on age
var rightNow = new Date().getTime(),
updatedAtDate = new Date(updatedAt).getTime();
if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_low)) return 'heatmap-high';
if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_medium)) return 'heatmap-med';
if (updatedAtDate > (rightNow - DAY * Discourse.SiteSettings.history_hours_high)) return 'heatmap-low';
}.property('post.updated_at'),
postTypeClass: function() {
return this.get('post.post_type') === Discourse.Site.currentProp('post_types.moderator_action') ? 'moderator' : 'regular';
}.property('post.post_type'),

View File

@ -891,12 +891,16 @@ en:
topic_views_heat_high: "After this many views, the topic is strongly highlighted."
cold_age_days_low: "A topic this many days old is slightly highligted."
cold_age_days_medium: "A topic this many days old is slightly highligted."
cold_age_days_high: "A topic this many days old is slightly highligted."
cold_age_days_medium: "A topic this many days old is moderately highligted."
cold_age_days_high: "A topic this many days old is strongly highligted."
history_hours_low: "A post edited within this many hours is slightly highlighted"
history_hours_medium: "A topic with this likes:post ratio is moderately highlighted."
history_hours_high: "A topic with this likes:post ratio is strongly highlighted."
topic_post_like_heat_low: "A topic with this likes:post ratio is slightly highlighted."
topic_post_like_heat_medium: "A topic with this likes:post ratio is slightly highlighted."
topic_post_like_heat_high: "A topic with this likes:post ratio is slightly highlighted."
topic_post_like_heat_medium: "A topic with this likes:post ratio is moderately highlighted."
topic_post_like_heat_high: "A topic with this likes:post ratio is strongly highlighted."
faq_url: "If you have a FAQ hosted elsewhere that you want to use, provide the full URL here."
tos_url: "If you have a Terms of Service document hosted elsewhere that you want to use, provide the full URL here."

View File

@ -681,6 +681,17 @@ uncategorized:
client: true
default: 2.0
# History edit heat thresholds
history_hours_low:
client: true
default: 12
history_hours_medium:
client: true
default: 24
history_hours_high:
client: true
default: 48
# Cold map thresholds
cold_age_days_low:
client: true