FIX: display warning when user is tracking too many topics

FEATURE: allow admins to bump up number of tracked topics if needed
using max_tracked_new_unread
This commit is contained in:
Sam 2015-08-25 15:40:50 +10:00
parent 4e37bcc3e2
commit 00e59bdc62
7 changed files with 19 additions and 1 deletions

View File

@ -95,6 +95,10 @@ const controllerOpts = {
return this.get('model.filter') === 'new' && this.get('model.topics.length') > 0;
}.property('model.filter', 'model.topics.length'),
tooManyTracked: function(){
return Discourse.TopicTrackingState.current().tooManyTracked();
}.property(),
showDismissAtTop: function() {
return (this.isFilterPage(this.get('model.filter'), 'new') ||
this.isFilterPage(this.get('model.filter'), 'unread')) &&

View File

@ -237,6 +237,10 @@ const TopicTrackingState = Discourse.Model.extend({
.length;
},
tooManyTracked() {
return this.initialStatesLength >= Discourse.SiteSettings.max_tracked_new_unread;
},
resetNew() {
const self = this;
Object.keys(this.states).forEach(function (id) {
@ -308,6 +312,7 @@ TopicTrackingState.reopenClass({
instance = Discourse.TopicTrackingState.create({ messageBus, currentUser });
instance.loadStates(data);
instance.initialStatesLength = data && data.length;
instance.establishChannels();
return instance;
},

View File

@ -1,3 +1,7 @@
{{#if tooManyTracked}}
<div class="alert alert-info">{{i18n 'topics.too_many_tracked'}}</div>
{{/if}}
{{#if redirectedReason}}
<div class="alert alert-info">{{redirectedReason}}</div>
{{/if}}

View File

@ -166,7 +166,7 @@ SQL
sql << " AND topics.id = :topic_id"
end
sql << " ORDER BY topics.bumped_at DESC ) SELECT * FROM x LIMIT 500"
sql << " ORDER BY topics.bumped_at DESC ) SELECT * FROM x LIMIT #{SiteSetting.max_tracked_new_unread.to_i}"
SqlBuilder.new(sql)
.map_exec(TopicTrackingState, user_id: user_id, topic_id: topic_id)

View File

@ -936,6 +936,7 @@ en:
current_user: 'go to your user page'
topics:
too_many_tracked: "Warning: you have too many tracked new and unread topics, clear some using \"Dismiss New\" or \"Dismiss Posts\""
bulk:
reset_read: "Reset Read"
delete: "Delete Topics"

View File

@ -946,6 +946,7 @@ en:
active_user_rate_limit_secs: "How frequently we update the 'last_seen_at' field, in seconds"
verbose_localization: "Show extended localization tips in the UI"
max_tracked_new_unread: "Cap the total of new + unread topics per user, this protects database and client from very large payloads for some users tracking thousands of topics"
previous_visit_timeout_hours: "How long a visit lasts before we consider it the 'previous' visit, in hours"
rate_limit_create_topic: "After creating a topic, users must wait (n) seconds before creating another topic."

View File

@ -748,6 +748,9 @@ developer:
migrate_to_new_scheme:
hidden: true
default: false
max_tracked_new_unread:
default: 1000
client: true
embedding:
feed_polling_enabled: