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'),