Merge branch 'fix/reference-deleted-comment'
This commit is contained in:
commit
f2aedff1a3
@ -197,16 +197,19 @@ class Comments:
|
|||||||
return {'likes': likes + 1, 'dislikes': dislikes}
|
return {'likes': likes + 1, 'dislikes': dislikes}
|
||||||
return {'likes': likes, 'dislikes': dislikes + 1}
|
return {'likes': likes, 'dislikes': dislikes + 1}
|
||||||
|
|
||||||
def reply_count(self, url, after=0):
|
def reply_count(self, url, mode=5, after=0):
|
||||||
"""
|
"""
|
||||||
Return comment count for main thread and all reply threads for one url.
|
Return comment count for main thread and all reply threads for one url.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sql = [ 'SELECT comments.parent,count(*) FROM comments INNER JOIN threads ON',
|
sql = ['SELECT comments.parent,count(*)',
|
||||||
' threads.uri=? AND comments.tid=threads.id',
|
'FROM comments INNER JOIN threads ON',
|
||||||
' AND comments.mode = 1 AND comments.created>? GROUP BY comments.parent;']
|
' threads.uri=? AND comments.tid=threads.id AND',
|
||||||
|
' (? | comments.mode = ?) AND',
|
||||||
|
' comments.created > ?',
|
||||||
|
'GROUP BY comments.parent']
|
||||||
|
|
||||||
return dict(self.db.execute(sql, [url, after]).fetchall())
|
return dict(self.db.execute(sql, [url, mode, mode, after]).fetchall())
|
||||||
|
|
||||||
def count(self, *urls):
|
def count(self, *urls):
|
||||||
"""
|
"""
|
||||||
|
@ -41,15 +41,16 @@ require(["app/lib/ready", "app/config", "app/i18n", "app/api", "app/isso", "app/
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lastcreated = 0;
|
var lastcreated = 0;
|
||||||
var total_count = rv.total_replies;
|
var count = rv.total_replies;
|
||||||
rv.replies.forEach(function(commentObject) {
|
console.log(rv.replies);
|
||||||
isso.insert(commentObject, false);
|
rv.replies.forEach(function(comment) {
|
||||||
if(commentObject.created > lastcreated) {
|
isso.insert(comment, false);
|
||||||
lastcreated = commentObject.created;
|
if(comment.created > lastcreated) {
|
||||||
|
lastcreated = comment.created;
|
||||||
}
|
}
|
||||||
total_count = total_count + commentObject.total_replies;
|
count = count + comment.total_replies;
|
||||||
});
|
});
|
||||||
$("#isso-thread > h4").textContent = i18n.pluralize("num-comments", total_count);
|
$("#isso-thread > h4").textContent = i18n.pluralize("num-comments", count);
|
||||||
|
|
||||||
if(rv.hidden_replies > 0) {
|
if(rv.hidden_replies > 0) {
|
||||||
isso.insert_loader(rv, lastcreated);
|
isso.insert_loader(rv, lastcreated);
|
||||||
|
@ -223,6 +223,9 @@ class TestComments(unittest.TestCase):
|
|||||||
self.assertEqual(loads(r.data)['mode'], 4)
|
self.assertEqual(loads(r.data)['mode'], 4)
|
||||||
self.assertIn('/path/', self.app.db.threads)
|
self.assertIn('/path/', self.app.db.threads)
|
||||||
|
|
||||||
|
data = loads(client.get("/?uri=%2Fpath%2F").data)
|
||||||
|
self.assertEqual(data["total_replies"], 1)
|
||||||
|
|
||||||
self.assertEqual(self.get('/?uri=%2Fpath%2F&id=1').status_code, 200)
|
self.assertEqual(self.get('/?uri=%2Fpath%2F&id=1').status_code, 200)
|
||||||
self.assertEqual(self.get('/?uri=%2Fpath%2F&id=2').status_code, 200)
|
self.assertEqual(self.get('/?uri=%2Fpath%2F&id=2').status_code, 200)
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ class API(object):
|
|||||||
|
|
||||||
plain = request.args.get('plain', '0') == '0'
|
plain = request.args.get('plain', '0') == '0'
|
||||||
|
|
||||||
reply_counts = self.comments.reply_count(uri, args['after'])
|
reply_counts = self.comments.reply_count(uri, after=args['after'])
|
||||||
|
|
||||||
if args['limit'] == 0:
|
if args['limit'] == 0:
|
||||||
root_list = []
|
root_list = []
|
||||||
|
Loading…
Reference in New Issue
Block a user