ignore deleted comment for activity sorting

This commit is contained in:
Umputun
2019-09-03 16:39:14 -05:00
parent cdc1ae1e85
commit 7971ebe6f4
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -87,10 +87,10 @@ func (t *Tree) proc(comments []store.Comment, node *Node, rd *recurData, parentI
repComments := t.filter(comments, func(comment store.Comment) bool { return comment.ParentID == parentID })
for _, rc := range repComments {
if !rc.Timestamp.IsZero() && rc.Timestamp.After(rd.tsModified) {
if !rc.Timestamp.IsZero() && rc.Timestamp.After(rd.tsModified) && !rc.Deleted {
rd.tsModified = rc.Timestamp
}
if !rc.Timestamp.IsZero() && rc.Timestamp.Before(rd.tsCreated) {
if !rc.Timestamp.IsZero() && rc.Timestamp.Before(rd.tsCreated) && !rc.Deleted {
rd.tsCreated = rc.Timestamp
}
if !rc.Deleted {
+1
View File
@@ -105,6 +105,7 @@ func TestTreeSortNodes(t *testing.T) {
{ID: "21", ParentID: "2", Timestamp: time.Date(2017, 12, 25, 19, 47, 21, 0, time.UTC)},
{ID: "22", ParentID: "2", Timestamp: time.Date(2017, 12, 25, 19, 47, 22, 0, time.UTC)},
{ID: "4", Timestamp: time.Date(2017, 12, 25, 19, 47, 22, 0, time.UTC), Score: -2, Controversy: 7},
{ID: "19", ParentID: "4", Timestamp: time.Date(2019, 12, 25, 19, 46, 14, 0, time.UTC), Deleted: true},
{ID: "3", Timestamp: time.Date(2017, 12, 25, 19, 47, 22, 100, time.UTC)},
{ID: "6", Timestamp: time.Date(2017, 12, 25, 19, 47, 22, 200, time.UTC)},
{ID: "5", Deleted: true, Timestamp: time.Date(2017, 12, 25, 19, 47, 22, 150, time.UTC)},