Fix inaccuracies in thread stats.
When a post dies, we need to decrease the filecount too if it had a file. But if a post dies and its file was also deleted previously, we don't need to decrease the filecount twice. Just count the entire thread each thread update.
This commit is contained in:
parent
c925959370
commit
39a7aa3c81
@ -5041,7 +5041,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dialog = UI.dialog('thread-stats', 'bottom: 0; left: 0;', "<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div>");
|
this.dialog = UI.dialog('thread-stats', 'bottom: 0; left: 0;', "<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div>");
|
||||||
this.postCount = this.fileCount = 0;
|
|
||||||
this.postCountEl = $('#post-count', this.dialog);
|
this.postCountEl = $('#post-count', this.dialog);
|
||||||
this.fileCountEl = $('#file-count', this.dialog);
|
this.fileCountEl = $('#file-count', this.dialog);
|
||||||
this.fileLimit = (function() {
|
this.fileLimit = (function() {
|
||||||
@ -5064,40 +5063,30 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
var ID, post, _ref;
|
ThreadStats.thread = this;
|
||||||
_ref = this.posts;
|
|
||||||
for (ID in _ref) {
|
|
||||||
post = _ref[ID];
|
|
||||||
ThreadStats.postCount++;
|
|
||||||
if (post.file) {
|
|
||||||
ThreadStats.fileCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ThreadStats.update();
|
ThreadStats.update();
|
||||||
$.on(d, 'ThreadUpdate', ThreadStats.onUpdate);
|
$.on(d, 'ThreadUpdate', ThreadStats.update);
|
||||||
return $.add(d.body, ThreadStats.dialog);
|
return $.add(d.body, ThreadStats.dialog);
|
||||||
},
|
},
|
||||||
onUpdate: function(e) {
|
|
||||||
var post, _i, _len, _ref;
|
|
||||||
if (e.detail[404]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_ref = e.detail.newPosts;
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
post = _ref[_i];
|
|
||||||
ThreadStats.postCount++;
|
|
||||||
if (post.file) {
|
|
||||||
ThreadStats.fileCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ThreadStats.postCount -= e.detail.deletedPosts.length;
|
|
||||||
ThreadStats.fileCount -= e.detail.deletedFiles.length;
|
|
||||||
return ThreadStats.update();
|
|
||||||
},
|
|
||||||
update: function() {
|
update: function() {
|
||||||
this.postCountEl.textContent = ThreadStats.postCount;
|
var ID, fileCount, post, postCount, _ref;
|
||||||
this.fileCountEl.textContent = ThreadStats.fileCount;
|
postCount = 0;
|
||||||
return (ThreadStats.fileCount > ThreadStats.fileLimit ? $.addClass : $.rmClass)(ThreadStats.fileCountEl, 'warning');
|
fileCount = 0;
|
||||||
|
_ref = ThreadStats.thread.posts;
|
||||||
|
for (ID in _ref) {
|
||||||
|
post = _ref[ID];
|
||||||
|
if (post.isDead) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
postCount++;
|
||||||
|
if (!post.file || post.file.isDead) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fileCount++;
|
||||||
|
}
|
||||||
|
ThreadStats.postCountEl.textContent = postCount;
|
||||||
|
ThreadStats.fileCountEl.textContent = fileCount;
|
||||||
|
return (fileCount > ThreadStats.fileLimit ? $.addClass : $.rmClass)(ThreadStats.fileCountEl, 'warning');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3400,7 +3400,6 @@ ThreadStats =
|
|||||||
<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div>
|
<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@postCount = @fileCount = 0
|
|
||||||
@postCountEl = $ '#post-count', @dialog
|
@postCountEl = $ '#post-count', @dialog
|
||||||
@fileCountEl = $ '#file-count', @dialog
|
@fileCountEl = $ '#file-count', @dialog
|
||||||
@fileLimit = # XXX boards config, need up to date data on this, check browser
|
@fileLimit = # XXX boards config, need up to date data on this, check browser
|
||||||
@ -3416,24 +3415,21 @@ ThreadStats =
|
|||||||
name: 'Thread Stats'
|
name: 'Thread Stats'
|
||||||
cb: @node
|
cb: @node
|
||||||
node: ->
|
node: ->
|
||||||
for ID, post of @posts
|
ThreadStats.thread = @
|
||||||
ThreadStats.postCount++
|
|
||||||
ThreadStats.fileCount++ if post.file
|
|
||||||
ThreadStats.update()
|
ThreadStats.update()
|
||||||
$.on d, 'ThreadUpdate', ThreadStats.onUpdate
|
$.on d, 'ThreadUpdate', ThreadStats.update
|
||||||
$.add d.body, ThreadStats.dialog
|
$.add d.body, ThreadStats.dialog
|
||||||
onUpdate: (e) ->
|
|
||||||
return if e.detail[404]
|
|
||||||
for post in e.detail.newPosts
|
|
||||||
ThreadStats.postCount++
|
|
||||||
ThreadStats.fileCount++ if post.file
|
|
||||||
ThreadStats.postCount -= e.detail.deletedPosts.length
|
|
||||||
ThreadStats.fileCount -= e.detail.deletedFiles.length
|
|
||||||
ThreadStats.update()
|
|
||||||
update: ->
|
update: ->
|
||||||
@postCountEl.textContent = ThreadStats.postCount
|
postCount = 0
|
||||||
@fileCountEl.textContent = ThreadStats.fileCount
|
fileCount = 0
|
||||||
(if ThreadStats.fileCount > ThreadStats.fileLimit then $.addClass else $.rmClass) ThreadStats.fileCountEl, 'warning'
|
for ID, post of ThreadStats.thread.posts
|
||||||
|
continue if post.isDead
|
||||||
|
postCount++
|
||||||
|
continue if !post.file or post.file.isDead
|
||||||
|
fileCount++
|
||||||
|
ThreadStats.postCountEl.textContent = postCount
|
||||||
|
ThreadStats.fileCountEl.textContent = fileCount
|
||||||
|
(if fileCount > ThreadStats.fileLimit then $.addClass else $.rmClass) ThreadStats.fileCountEl, 'warning'
|
||||||
|
|
||||||
ThreadUpdater =
|
ThreadUpdater =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user