ignore deleted comment for activity sorting
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)},
|
||||
|
||||
Reference in New Issue
Block a user