[MM-44263] Only include user posts in post count (#20250)
* Fetch users only posts * Explicitly validate posts count before testing usage
Этот коммит содержится в:
@@ -2162,6 +2162,13 @@ func (s *SqlPostStore) AnalyticsPostCount(options *model.PostCountOptions) (int6
|
||||
Where(sq.Eq{"c.TeamId": options.TeamId})
|
||||
}
|
||||
|
||||
if options.UsersPostsOnly {
|
||||
query = query.Where(sq.And{
|
||||
sq.Eq{"p.Type": ""},
|
||||
sq.Expr("p.UserId NOT IN (SELECT UserId FROM Bots)"),
|
||||
})
|
||||
}
|
||||
|
||||
if options.MustHaveFile {
|
||||
query = query.Where(sq.Or{sq.NotEq{"p.FileIds": "[]"}, sq.NotEq{"p.Filenames": "[]"}})
|
||||
}
|
||||
|
||||
@@ -2163,7 +2163,7 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, r2, int64(2))
|
||||
|
||||
// total across teams with hastags and files
|
||||
// total across teams with hashtags and files
|
||||
r2, err = ss.Post().AnalyticsPostCount(&model.PostCountOptions{MustHaveFile: true, MustHaveHashtag: true})
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, r2, int64(1))
|
||||
@@ -2176,6 +2176,11 @@ func testPostCountsByDay(t *testing.T, ss store.Store) {
|
||||
r2, err = ss.Post().AnalyticsPostCount(&model.PostCountOptions{TeamId: t1.Id, ExcludeDeleted: true})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(5), r2)
|
||||
|
||||
// total users only posts for single team with the deleted post excluded
|
||||
r2, err = ss.Post().AnalyticsPostCount(&model.PostCountOptions{TeamId: t1.Id, ExcludeDeleted: true, UsersPostsOnly: true})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(3), r2)
|
||||
}
|
||||
|
||||
func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlStore) {
|
||||
|
||||
Ссылка в новой задаче
Block a user