bug fix: after and before search flags should not be inclusive of the selected date (#9327)
* fix for date based flag support to make the after and before flags not inclusive of the selected date * updated search posts tests using date flags to take into account new non inclusive of the selected date behavior of those flags
Этот коммит содержится в:
коммит произвёл
Elias Nahum
родитель
e742ba7d51
Коммит
effa9d33fc
@@ -1581,19 +1581,24 @@ func TestSearchPostsWithDateFlags(t *testing.T) {
|
|||||||
resultCount = resultCount + 1
|
resultCount = resultCount + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if resultCount != 3 {
|
if resultCount != 2 {
|
||||||
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
||||||
}
|
}
|
||||||
|
|
||||||
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-02", false)
|
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-02", false)
|
||||||
if len(posts.Order) != 2 {
|
if len(posts.Order) != 1 {
|
||||||
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
||||||
}
|
}
|
||||||
|
|
||||||
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-02", false)
|
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-02", false)
|
||||||
if len(posts.Order) != 2 {
|
if len(posts.Order) != 0 {
|
||||||
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-01", false)
|
||||||
|
if len(posts.Order) != 1 {
|
||||||
|
t.Fatalf("wrong number of posts returned %v", len(posts.Order))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFileInfosForPost(t *testing.T) {
|
func TestGetFileInfosForPost(t *testing.T) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
|
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
|
||||||
@@ -27,13 +28,19 @@ type SearchParams struct {
|
|||||||
// Returns the epoch timestamp of the start of the day specified by SearchParams.AfterDate
|
// Returns the epoch timestamp of the start of the day specified by SearchParams.AfterDate
|
||||||
func (p *SearchParams) GetAfterDateMillis() int64 {
|
func (p *SearchParams) GetAfterDateMillis() int64 {
|
||||||
date := ParseDateFilterToTime(p.AfterDate)
|
date := ParseDateFilterToTime(p.AfterDate)
|
||||||
return GetStartOfDayMillis(date, p.TimeZoneOffset)
|
// travel forward 1 day
|
||||||
|
oneDay := time.Hour * 24
|
||||||
|
afterDate := date.Add(oneDay)
|
||||||
|
return GetStartOfDayMillis(afterDate, p.TimeZoneOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the epoch timestamp of the end of the day specified by SearchParams.BeforeDate
|
// Returns the epoch timestamp of the end of the day specified by SearchParams.BeforeDate
|
||||||
func (p *SearchParams) GetBeforeDateMillis() int64 {
|
func (p *SearchParams) GetBeforeDateMillis() int64 {
|
||||||
date := ParseDateFilterToTime(p.BeforeDate)
|
date := ParseDateFilterToTime(p.BeforeDate)
|
||||||
return GetEndOfDayMillis(date, p.TimeZoneOffset)
|
// travel back 1 day
|
||||||
|
oneDay := time.Hour * -24
|
||||||
|
beforeDate := date.Add(oneDay)
|
||||||
|
return GetEndOfDayMillis(beforeDate, p.TimeZoneOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the epoch timestamps of the start and end of the day specified by SearchParams.OnDate
|
// Returns the epoch timestamps of the start and end of the day specified by SearchParams.OnDate
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user