Revert "Mm 30807 granular data retention scaffold (#16891)" (#17437)

This reverts commit 3ea75332e7.
Этот коммит содержится в:
Agniva De Sarker
2021-04-18 22:41:50 +05:30
коммит произвёл GitHub
родитель 3a13987ee1
Коммит e0efdd708b
49 изменённых файлов: 984 добавлений и 5079 удалений

Просмотреть файл

@@ -97,7 +97,7 @@ func (a *App) GetAnalytics(name string, teamID string) (model.AnalyticsRows, *mo
var teamsCount int64
g.Go(func() error {
var err error
if teamsCount, err = a.Srv().Store.Team().AnalyticsTeamCount(nil); err != nil {
if teamsCount, err = a.Srv().Store.Team().AnalyticsTeamCount(false); err != nil {
return model.NewAppError("GetAnalytics", "app.team.analytics_team_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return nil

Просмотреть файл

@@ -365,7 +365,6 @@ type AppIface interface {
AcceptLanguage() string
AccountMigration() einterfaces.AccountMigrationInterface
ActivateMfa(userID, token string) *model.AppError
AddChannelsToRetentionPolicy(policyID string, channelIDs []string) *model.AppError
AddConfigListener(listener func(*model.Config, *model.Config)) string
AddDirectChannels(teamID string, user *model.User) *model.AppError
AddLdapPrivateCertificate(fileData *multipart.FileHeader) *model.AppError
@@ -381,7 +380,6 @@ type AppIface interface {
AddTeamMemberByInviteId(inviteId, userID string) (*model.TeamMember, *model.AppError)
AddTeamMemberByToken(userID, tokenID string) (*model.TeamMember, *model.AppError)
AddTeamMembers(teamID string, userIDs []string, userRequestorId string, graceful bool) ([]*model.TeamMemberWithError, *model.AppError)
AddTeamsToRetentionPolicy(policyID string, teamIDs []string) *model.AppError
AddUserToTeam(teamID string, userID string, userRequestorId string) (*model.Team, *model.TeamMember, *model.AppError)
AddUserToTeamByInviteId(inviteId string, userID string) (*model.Team, *model.TeamMember, *model.AppError)
AddUserToTeamByTeamId(teamID string, user *model.User) *model.AppError
@@ -454,7 +452,6 @@ type AppIface interface {
CreatePost(post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError)
CreatePostAsUser(post *model.Post, currentSessionId string, setOnline bool) (*model.Post, *model.AppError)
CreatePostMissingChannel(post *model.Post, triggerWebhooks bool) (*model.Post, *model.AppError)
CreateRetentionPolicy(policy *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError)
CreateRole(role *model.Role) (*model.Role, *model.AppError)
CreateScheme(scheme *model.Scheme) (*model.Scheme, *model.AppError)
CreateSession(session *model.Session) (*model.Session, *model.AppError)
@@ -496,7 +493,6 @@ type AppIface interface {
DeletePreferences(userID string, preferences model.Preferences) *model.AppError
DeleteReactionForPost(reaction *model.Reaction) *model.AppError
DeleteRemoteCluster(remoteClusterId string) (bool, *model.AppError)
DeleteRetentionPolicy(policyID string) *model.AppError
DeleteScheme(schemeId string) (*model.Scheme, *model.AppError)
DeleteSharedChannel(channelID string) (bool, error)
DeleteSharedChannelRemote(id string) (bool, error)
@@ -536,13 +532,17 @@ type AppIface interface {
GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError)
GetAllChannelsCount(opts model.ChannelSearchOpts) (int64, *model.AppError)
GetAllPrivateTeams() ([]*model.Team, *model.AppError)
GetAllPrivateTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError)
GetAllPrivateTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError)
GetAllPublicTeams() ([]*model.Team, *model.AppError)
GetAllPublicTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError)
GetAllPublicTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError)
GetAllRemoteClusters(filter model.RemoteClusterQueryFilter) ([]*model.RemoteCluster, *model.AppError)
GetAllRoles() ([]*model.Role, *model.AppError)
GetAllStatuses() map[string]*model.Status
GetAllTeams() ([]*model.Team, *model.AppError)
GetAllTeamsPage(offset int, limit int, opts *model.TeamSearch) ([]*model.Team, *model.AppError)
GetAllTeamsPageWithCount(offset int, limit int, opts *model.TeamSearch) (*model.TeamsWithCount, *model.AppError)
GetAllTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError)
GetAllTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError)
GetAnalytics(name string, teamID string) (model.AnalyticsRows, *model.AppError)
GetAudits(userID string, limit int) (model.Audits, *model.AppError)
GetAuditsPage(userID string, page int, perPage int) (model.Audits, *model.AppError)
@@ -563,10 +563,8 @@ type AppIface interface {
GetChannelMembersPage(channelID string, page, perPage int) (*model.ChannelMembers, *model.AppError)
GetChannelMembersTimezones(channelID string) ([]string, *model.AppError)
GetChannelPinnedPostCount(channelID string) (int64, *model.AppError)
GetChannelPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForChannelList, *model.AppError)
GetChannelUnread(channelID, userID string) (*model.ChannelUnread, *model.AppError)
GetChannelsByNames(channelNames []string, teamID string) ([]*model.Channel, *model.AppError)
GetChannelsForRetentionPolicy(policyID string, offset, limit int) (*model.ChannelsWithCount, *model.AppError)
GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError)
GetChannelsForSchemePage(scheme *model.Scheme, page int, perPage int) (model.ChannelList, *model.AppError)
GetChannelsForUser(teamID string, userID string, includeDeleted bool, lastDeleteAt int) (*model.ChannelList, *model.AppError)
@@ -579,6 +577,7 @@ type AppIface interface {
GetComplianceReport(reportId string) (*model.Compliance, *model.AppError)
GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError)
GetCookieDomain() string
GetDataRetentionPolicy() (*model.DataRetentionPolicy, *model.AppError)
GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError)
GetDeletedChannels(teamID string, offset int, limit int, userID string) (*model.ChannelList, *model.AppError)
GetEmoji(emojiId string) (*model.Emoji, *model.AppError)
@@ -594,7 +593,6 @@ type AppIface interface {
GetFlaggedPosts(userID string, offset int, limit int) (*model.PostList, *model.AppError)
GetFlaggedPostsForChannel(userID, channelID string, offset int, limit int) (*model.PostList, *model.AppError)
GetFlaggedPostsForTeam(userID, teamID string, offset int, limit int) (*model.PostList, *model.AppError)
GetGlobalRetentionPolicy() (*model.GlobalRetentionPolicy, *model.AppError)
GetGroup(id string) (*model.Group, *model.AppError)
GetGroupByName(name string, opts model.GroupSearchOpts) (*model.Group, *model.AppError)
GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError)
@@ -683,9 +681,6 @@ type AppIface interface {
GetRemoteClusterForUser(remoteID string, userID string) (*model.RemoteCluster, *model.AppError)
GetRemoteClusterService() (remotecluster.RemoteClusterServiceIFace, *model.AppError)
GetRemoteClusterSession(token string, remoteId string) (*model.Session, *model.AppError)
GetRetentionPolicies(offset, limit int) (*model.RetentionPolicyWithTeamAndChannelCountsList, *model.AppError)
GetRetentionPoliciesCount() (int64, *model.AppError)
GetRetentionPolicy(policyID string) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError)
GetRole(id string) (*model.Role, *model.AppError)
GetRoleByName(name string) (*model.Role, *model.AppError)
GetRolesByNames(names []string) ([]*model.Role, *model.AppError)
@@ -727,10 +722,8 @@ type AppIface interface {
GetTeamMembersByIds(teamID string, userIDs []string, restrictions *model.ViewUsersRestrictions) ([]*model.TeamMember, *model.AppError)
GetTeamMembersForUser(userID string) ([]*model.TeamMember, *model.AppError)
GetTeamMembersForUserWithPagination(userID string, page, perPage int) ([]*model.TeamMember, *model.AppError)
GetTeamPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForTeamList, *model.AppError)
GetTeamStats(teamID string, restrictions *model.ViewUsersRestrictions) (*model.TeamStats, *model.AppError)
GetTeamUnread(teamID, userID string) (*model.TeamUnread, *model.AppError)
GetTeamsForRetentionPolicy(policyID string, offset, limit int) (*model.TeamsWithCount, *model.AppError)
GetTeamsForScheme(scheme *model.Scheme, offset int, limit int) ([]*model.Team, *model.AppError)
GetTeamsForSchemePage(scheme *model.Scheme, page int, perPage int) ([]*model.Team, *model.AppError)
GetTeamsForUser(userID string) ([]*model.Team, *model.AppError)
@@ -844,7 +837,6 @@ type AppIface interface {
OriginChecker() func(*http.Request) bool
PatchChannel(channel *model.Channel, patch *model.ChannelPatch, userID string) (*model.Channel, *model.AppError)
PatchPost(postID string, patch *model.PostPatch) (*model.Post, *model.AppError)
PatchRetentionPolicy(patch *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError)
PatchRole(role *model.Role, patch *model.RolePatch) (*model.Role, *model.AppError)
PatchScheme(scheme *model.Scheme, patch *model.SchemePatch) (*model.Scheme, *model.AppError)
PatchTeam(teamID string, patch *model.TeamPatch) (*model.Team, *model.AppError)
@@ -881,7 +873,6 @@ type AppIface interface {
RegisterPluginCommand(pluginID string, command *model.Command) error
ReloadConfig() error
RemoveAllDeactivatedMembersFromChannel(channel *model.Channel) *model.AppError
RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError
RemoveConfigListener(id string)
RemoveCustomStatus(userID string) *model.AppError
RemoveDirectory(path string) *model.AppError
@@ -896,7 +887,6 @@ type AppIface interface {
RemoveSamlPublicCertificate() *model.AppError
RemoveTeamIcon(teamID string) *model.AppError
RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId string) *model.AppError
RemoveTeamsFromRetentionPolicy(policyID string, teamIDs []string) *model.AppError
RemoveUserFromChannel(userIDToRemove string, removerUserId string, channel *model.Channel) *model.AppError
RemoveUserFromTeam(teamID string, userID string, requestorId string) *model.AppError
RemoveUsersFromChannelNotMemberOfTeam(remover *model.User, channel *model.Channel, team *model.Team) *model.AppError
@@ -938,8 +928,8 @@ type AppIface interface {
SearchGroupChannels(userID, term string) (*model.ChannelList, *model.AppError)
SearchPostsInTeam(teamID string, paramsList []*model.SearchParams) (*model.PostList, *model.AppError)
SearchPostsInTeamForUser(terms string, userID string, teamID string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError)
SearchPrivateTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError)
SearchPublicTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError)
SearchPrivateTeams(term string) ([]*model.Team, *model.AppError)
SearchPublicTeams(term string) ([]*model.Team, *model.AppError)
SearchUserAccessTokens(term string) ([]*model.UserAccessToken, *model.AppError)
SearchUsers(props *model.UserSearch, options *model.UserSearchOptions) ([]*model.User, *model.AppError)
SearchUsersInChannel(channelID string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)

Просмотреть файл

@@ -1695,11 +1695,9 @@ func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*
opts.ExcludeChannelNames = a.DefaultChannelNames()
}
storeOpts := store.ChannelSearchOpts{
ExcludeChannelNames: opts.ExcludeChannelNames,
NotAssociatedToGroup: opts.NotAssociatedToGroup,
IncludeDeleted: opts.IncludeDeleted,
ExcludePolicyConstrained: opts.ExcludePolicyConstrained,
IncludePolicyID: opts.IncludePolicyID,
ExcludeChannelNames: opts.ExcludeChannelNames,
NotAssociatedToGroup: opts.NotAssociatedToGroup,
IncludeDeleted: opts.IncludeDeleted,
}
channels, err := a.Srv().Store.Channel().GetAllChannels(page*perPage, perPage, storeOpts)
if err != nil {
@@ -2469,20 +2467,17 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
opts.ExcludeChannelNames = a.DefaultChannelNames()
}
storeOpts := store.ChannelSearchOpts{
ExcludeChannelNames: opts.ExcludeChannelNames,
NotAssociatedToGroup: opts.NotAssociatedToGroup,
IncludeDeleted: opts.IncludeDeleted,
Deleted: opts.Deleted,
TeamIds: opts.TeamIds,
GroupConstrained: opts.GroupConstrained,
ExcludeGroupConstrained: opts.ExcludeGroupConstrained,
PolicyID: opts.PolicyID,
IncludePolicyID: opts.IncludePolicyID,
ExcludePolicyConstrained: opts.ExcludePolicyConstrained,
Public: opts.Public,
Private: opts.Private,
Page: opts.Page,
PerPage: opts.PerPage,
ExcludeChannelNames: opts.ExcludeChannelNames,
NotAssociatedToGroup: opts.NotAssociatedToGroup,
IncludeDeleted: opts.IncludeDeleted,
Deleted: opts.Deleted,
TeamIds: opts.TeamIds,
GroupConstrained: opts.GroupConstrained,
ExcludeGroupConstrained: opts.ExcludeGroupConstrained,
Public: opts.Public,
Private: opts.Private,
Page: opts.Page,
PerPage: opts.PerPage,
}
term = strings.TrimSpace(term)

Просмотреть файл

@@ -9,112 +9,10 @@ import (
"github.com/mattermost/mattermost-server/v5/model"
)
func (a *App) GetGlobalRetentionPolicy() (*model.GlobalRetentionPolicy, *model.AppError) {
func (a *App) GetDataRetentionPolicy() (*model.DataRetentionPolicy, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetGlobalRetentionPolicy")
return nil, model.NewAppError("App.GetDataRetentionPolicy", "ent.data_retention.generic.license.error", nil, "", http.StatusNotImplemented)
}
return a.DataRetention().GetGlobalPolicy()
}
func (a *App) GetRetentionPolicies(offset, limit int) (*model.RetentionPolicyWithTeamAndChannelCountsList, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetRetentionPolicies")
}
return a.DataRetention().GetPolicies(offset, limit)
}
func (a *App) GetRetentionPoliciesCount() (int64, *model.AppError) {
if a.DataRetention() == nil {
return 0, newLicenseError("GetRetentionPoliciesCount")
}
return a.DataRetention().GetPoliciesCount()
}
func (a *App) GetRetentionPolicy(policyID string) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetRetentionPolicy")
}
return a.DataRetention().GetPolicy(policyID)
}
func (a *App) CreateRetentionPolicy(policy *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("CreateRetentionPolicy")
}
return a.DataRetention().CreatePolicy(policy)
}
func (a *App) PatchRetentionPolicy(patch *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("PatchRetentionPolicy")
}
return a.DataRetention().PatchPolicy(patch)
}
func (a *App) DeleteRetentionPolicy(policyID string) *model.AppError {
if a.DataRetention() == nil {
return newLicenseError("DeleteRetentionPolicy")
}
return a.DataRetention().DeletePolicy(policyID)
}
func (a *App) GetTeamsForRetentionPolicy(policyID string, offset, limit int) (*model.TeamsWithCount, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetTeamsForRetentionPolicy")
}
return a.DataRetention().GetTeamsForPolicy(policyID, offset, limit)
}
func (a *App) AddTeamsToRetentionPolicy(policyID string, teamIDs []string) *model.AppError {
if a.DataRetention() == nil {
return newLicenseError("AddTeamsToRetentionPolicy")
}
return a.DataRetention().AddTeamsToPolicy(policyID, teamIDs)
}
func (a *App) RemoveTeamsFromRetentionPolicy(policyID string, teamIDs []string) *model.AppError {
if a.DataRetention() == nil {
return newLicenseError("RemoveTeamsFromRetentionPolicy")
}
return a.DataRetention().RemoveTeamsFromPolicy(policyID, teamIDs)
}
func (a *App) GetChannelsForRetentionPolicy(policyID string, offset, limit int) (*model.ChannelsWithCount, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetChannelsForRetentionPolicy")
}
return a.DataRetention().GetChannelsForPolicy(policyID, offset, limit)
}
func (a *App) AddChannelsToRetentionPolicy(policyID string, channelIDs []string) *model.AppError {
if a.DataRetention() == nil {
return newLicenseError("AddChannelsToRetentionPolicies")
}
return a.DataRetention().AddChannelsToPolicy(policyID, channelIDs)
}
func (a *App) RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError {
if a.DataRetention() == nil {
return newLicenseError("RemoveChannelsFromRetentionPolicy")
}
return a.DataRetention().RemoveChannelsFromPolicy(policyID, channelIDs)
}
func (a *App) GetTeamPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForTeamList, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetTeamPoliciesForUser")
}
return a.DataRetention().GetTeamPoliciesForUser(userID, offset, limit)
}
func (a *App) GetChannelPoliciesForUser(userID string, offset, limit int) (*model.RetentionPolicyForChannelList, *model.AppError) {
if a.DataRetention() == nil {
return nil, newLicenseError("GetChannelPoliciesForUser")
}
return a.DataRetention().GetChannelPoliciesForUser(userID, offset, limit)
}
func newLicenseError(methodName string) *model.AppError {
return model.NewAppError("App."+methodName, "ent.data_retention.generic.license.error",
nil, "", http.StatusNotImplemented)
return a.DataRetention().GetPolicy()
}

Просмотреть файл

@@ -606,7 +606,7 @@ func (*TestHelper) ResetEmojisMigration() {
}
func (th *TestHelper) CheckTeamCount(t *testing.T, expected int64) {
teamCount, err := th.App.Srv().Store.Team().AnalyticsTeamCount(nil)
teamCount, err := th.App.Srv().Store.Team().AnalyticsTeamCount(false)
require.NoError(t, err, "Failed to get team count.")
require.Equalf(t, teamCount, expected, "Unexpected number of teams. Expected: %v, found: %v", expected, teamCount)
}

Просмотреть файл

@@ -505,7 +505,7 @@ func TestImportImportTeam(t *testing.T) {
scheme2 := th.SetupTeamScheme()
// Check how many teams are in the database.
teamsCount, err := th.App.Srv().Store.Team().AnalyticsTeamCount(nil)
teamsCount, err := th.App.Srv().Store.Team().AnalyticsTeamCount(false)
require.NoError(t, err, "Failed to get team count.")
data := TeamImportData{

Просмотреть файл

@@ -26,7 +26,7 @@ var (
outputFile string
inputFile string
outputFileTemplate string
basicTypes = map[string]bool{"int": true, "uint": true, "string": true, "float": true, "bool": true, "byte": true, "int64": true, "uint64": true, "error": true}
basicTypes = map[string]bool{"int": true, "string": true, "float": true, "bool": true, "byte": true, "int64": true, "error": true}
textRegexp = regexp.MustCompile(`\w+$`)
)

Просмотреть файл

@@ -117,28 +117,6 @@ func (a *OpenTracingAppLayer) AddChannelMember(userID string, channel *model.Cha
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) AddChannelsToRetentionPolicy(policyID string, channelIDs []string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddChannelsToRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.AddChannelsToRetentionPolicy(policyID, channelIDs)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) AddConfigListener(listener func(*model.Config, *model.Config)) string {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddConfigListener")
@@ -480,28 +458,6 @@ func (a *OpenTracingAppLayer) AddTeamMembers(teamID string, userIDs []string, us
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) AddTeamsToRetentionPolicy(policyID string, teamIDs []string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddTeamsToRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.AddTeamsToRetentionPolicy(policyID, teamIDs)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) AddUserToChannel(user *model.User, channel *model.Channel, skipTeamMemberIntegrityCheck bool) (*model.ChannelMember, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddUserToChannel")
@@ -2192,28 +2148,6 @@ func (a *OpenTracingAppLayer) CreatePostMissingChannel(post *model.Post, trigger
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) CreateRetentionPolicy(policy *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.CreateRetentionPolicy(policy)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) CreateRole(role *model.Role) (*model.Role, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.CreateRole")
@@ -3222,28 +3156,6 @@ func (a *OpenTracingAppLayer) DeleteRemoteCluster(remoteClusterId string) (bool,
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) DeleteRetentionPolicy(policyID string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.DeleteRetentionPolicy(policyID)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) DeleteScheme(schemeId string) (*model.Scheme, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteScheme")
@@ -4352,6 +4264,50 @@ func (a *OpenTracingAppLayer) GetAllPrivateTeams() ([]*model.Team, *model.AppErr
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllPrivateTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllPrivateTeamsPage")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllPrivateTeamsPage(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllPrivateTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllPrivateTeamsPageWithCount")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllPrivateTeamsPageWithCount(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllPublicTeams")
@@ -4374,6 +4330,50 @@ func (a *OpenTracingAppLayer) GetAllPublicTeams() ([]*model.Team, *model.AppErro
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllPublicTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllPublicTeamsPage")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllPublicTeamsPage(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllPublicTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllPublicTeamsPageWithCount")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllPublicTeamsPageWithCount(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllRemoteClusters(filter model.RemoteClusterQueryFilter) ([]*model.RemoteCluster, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllRemoteClusters")
@@ -4457,7 +4457,7 @@ func (a *OpenTracingAppLayer) GetAllTeams() ([]*model.Team, *model.AppError) {
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllTeamsPage(offset int, limit int, opts *model.TeamSearch) ([]*model.Team, *model.AppError) {
func (a *OpenTracingAppLayer) GetAllTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllTeamsPage")
@@ -4469,7 +4469,7 @@ func (a *OpenTracingAppLayer) GetAllTeamsPage(offset int, limit int, opts *model
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllTeamsPage(offset, limit, opts)
resultVar0, resultVar1 := a.app.GetAllTeamsPage(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
@@ -4479,7 +4479,7 @@ func (a *OpenTracingAppLayer) GetAllTeamsPage(offset int, limit int, opts *model
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetAllTeamsPageWithCount(offset int, limit int, opts *model.TeamSearch) (*model.TeamsWithCount, *model.AppError) {
func (a *OpenTracingAppLayer) GetAllTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetAllTeamsPageWithCount")
@@ -4491,7 +4491,7 @@ func (a *OpenTracingAppLayer) GetAllTeamsPageWithCount(offset int, limit int, op
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetAllTeamsPageWithCount(offset, limit, opts)
resultVar0, resultVar1 := a.app.GetAllTeamsPageWithCount(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
@@ -5051,28 +5051,6 @@ func (a *OpenTracingAppLayer) GetChannelPinnedPostCount(channelID string) (int64
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetChannelPoliciesForUser(userID string, offset int, limit int) (*model.RetentionPolicyForChannelList, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelPoliciesForUser")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetChannelPoliciesForUser(userID, offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetChannelUnread(channelID string, userID string) (*model.ChannelUnread, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelUnread")
@@ -5117,28 +5095,6 @@ func (a *OpenTracingAppLayer) GetChannelsByNames(channelNames []string, teamID s
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetChannelsForRetentionPolicy(policyID string, offset int, limit int) (*model.ChannelsWithCount, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsForRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetChannelsForRetentionPolicy(policyID, offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetChannelsForScheme(scheme *model.Scheme, offset int, limit int) (model.ChannelList, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetChannelsForScheme")
@@ -5432,6 +5388,28 @@ func (a *OpenTracingAppLayer) GetCookieDomain() string {
return resultVar0
}
func (a *OpenTracingAppLayer) GetDataRetentionPolicy() (*model.DataRetentionPolicy, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDataRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetDataRetentionPolicy()
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDefaultProfileImage")
@@ -5823,28 +5801,6 @@ func (a *OpenTracingAppLayer) GetFlaggedPostsForTeam(userID string, teamID strin
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetGlobalRetentionPolicy() (*model.GlobalRetentionPolicy, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetGlobalRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetGlobalRetentionPolicy()
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetGroup(id string) (*model.Group, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetGroup")
@@ -7961,72 +7917,6 @@ func (a *OpenTracingAppLayer) GetRemoteClusterSession(token string, remoteId str
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetRetentionPolicies(offset int, limit int) (*model.RetentionPolicyWithTeamAndChannelCountsList, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetRetentionPolicies")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetRetentionPolicies(offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetRetentionPoliciesCount() (int64, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetRetentionPoliciesCount")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetRetentionPoliciesCount()
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetRetentionPolicy(policyID string) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetRetentionPolicy(policyID)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetRole(id string) (*model.Role, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetRole")
@@ -8982,28 +8872,6 @@ func (a *OpenTracingAppLayer) GetTeamMembersForUserWithPagination(userID string,
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetTeamPoliciesForUser(userID string, offset int, limit int) (*model.RetentionPolicyForTeamList, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamPoliciesForUser")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetTeamPoliciesForUser(userID, offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetTeamSchemeChannelRoles(teamID string) (guestRoleName string, userRoleName string, adminRoleName string, err *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamSchemeChannelRoles")
@@ -9070,28 +8938,6 @@ func (a *OpenTracingAppLayer) GetTeamUnread(teamID string, userID string) (*mode
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetTeamsForRetentionPolicy(policyID string, offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamsForRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.GetTeamsForRetentionPolicy(policyID, offset, limit)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) GetTeamsForScheme(scheme *model.Scheme, offset int, limit int) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamsForScheme")
@@ -11712,28 +11558,6 @@ func (a *OpenTracingAppLayer) PatchPost(postID string, patch *model.PostPatch) (
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) PatchRetentionPolicy(patch *model.RetentionPolicyWithTeamAndChannelIDs) (*model.RetentionPolicyWithTeamAndChannelCounts, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PatchRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.PatchRetentionPolicy(patch)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
ext.Error.Set(span, true)
}
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) PatchRole(role *model.Role, patch *model.RolePatch) (*model.Role, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PatchRole")
@@ -12506,28 +12330,6 @@ func (a *OpenTracingAppLayer) RemoveAllDeactivatedMembersFromChannel(channel *mo
return resultVar0
}
func (a *OpenTracingAppLayer) RemoveChannelsFromRetentionPolicy(policyID string, channelIDs []string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RemoveChannelsFromRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.RemoveChannelsFromRetentionPolicy(policyID, channelIDs)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) RemoveConfigListener(id string) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RemoveConfigListener")
@@ -12822,28 +12624,6 @@ func (a *OpenTracingAppLayer) RemoveTeamMemberFromTeam(teamMember *model.TeamMem
return resultVar0
}
func (a *OpenTracingAppLayer) RemoveTeamsFromRetentionPolicy(policyID string, teamIDs []string) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RemoveTeamsFromRetentionPolicy")
a.ctx = newCtx
a.app.Srv().Store.SetContext(newCtx)
defer func() {
a.app.Srv().Store.SetContext(origCtx)
a.ctx = origCtx
}()
defer span.Finish()
resultVar0 := a.app.RemoveTeamsFromRetentionPolicy(policyID, teamIDs)
if resultVar0 != nil {
span.LogFields(spanlog.Error(resultVar0))
ext.Error.Set(span, true)
}
return resultVar0
}
func (a *OpenTracingAppLayer) RemoveUserFromChannel(userIDToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.RemoveUserFromChannel")
@@ -13795,7 +13575,7 @@ func (a *OpenTracingAppLayer) SearchPostsInTeamForUser(terms string, userID stri
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) SearchPrivateTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError) {
func (a *OpenTracingAppLayer) SearchPrivateTeams(term string) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchPrivateTeams")
@@ -13807,7 +13587,7 @@ func (a *OpenTracingAppLayer) SearchPrivateTeams(searchOpts *model.TeamSearch) (
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.SearchPrivateTeams(searchOpts)
resultVar0, resultVar1 := a.app.SearchPrivateTeams(term)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))
@@ -13817,7 +13597,7 @@ func (a *OpenTracingAppLayer) SearchPrivateTeams(searchOpts *model.TeamSearch) (
return resultVar0, resultVar1
}
func (a *OpenTracingAppLayer) SearchPublicTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError) {
func (a *OpenTracingAppLayer) SearchPublicTeams(term string) ([]*model.Team, *model.AppError) {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SearchPublicTeams")
@@ -13829,7 +13609,7 @@ func (a *OpenTracingAppLayer) SearchPublicTeams(searchOpts *model.TeamSearch) ([
}()
defer span.Finish()
resultVar0, resultVar1 := a.app.SearchPublicTeams(searchOpts)
resultVar0, resultVar1 := a.app.SearchPublicTeams(term)
if resultVar1 != nil {
span.LogFields(spanlog.Error(resultVar1))

Просмотреть файл

@@ -76,7 +76,7 @@ func (s *Server) DoSecurityUpdateCheck() {
v.Set(PropSecurityActiveUserCount, strconv.FormatInt(ucr, 10))
}
if teamCount, err := s.Store.Team().AnalyticsTeamCount(nil); err == nil {
if teamCount, err := s.Store.Team().AnalyticsTeamCount(false); err == nil {
v.Set(PropSecurityTeamCount, strconv.FormatInt(teamCount, 10))
}

Просмотреть файл

@@ -1488,7 +1488,7 @@ func doCheckWarnMetricStatus(a *App) {
mlog.Debug("Error attempting to get active registered users.", mlog.Err(err0))
}
teamCount, err1 := a.Srv().Store.Team().AnalyticsTeamCount(nil)
teamCount, err1 := a.Srv().Store.Team().AnalyticsTeamCount(false)
if err1 != nil {
mlog.Debug("Error attempting to get number of teams.", mlog.Err(err1))
}

Просмотреть файл

@@ -879,8 +879,8 @@ func (a *App) GetAllTeams() ([]*model.Team, *model.AppError) {
return teams, nil
}
func (a *App) GetAllTeamsPage(offset int, limit int, opts *model.TeamSearch) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().GetAllPage(offset, limit, opts)
func (a *App) GetAllTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().GetAllPage(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllTeamsPage", "app.team.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -888,12 +888,12 @@ func (a *App) GetAllTeamsPage(offset int, limit int, opts *model.TeamSearch) ([]
return teams, nil
}
func (a *App) GetAllTeamsPageWithCount(offset int, limit int, opts *model.TeamSearch) (*model.TeamsWithCount, *model.AppError) {
totalCount, err := a.Srv().Store.Team().AnalyticsTeamCount(opts)
func (a *App) GetAllTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
totalCount, err := a.Srv().Store.Team().AnalyticsTeamCount(true)
if err != nil {
return nil, model.NewAppError("GetAllTeamsPageWithCount", "app.team.analytics_team_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
teams, err := a.Srv().Store.Team().GetAllPage(offset, limit, opts)
teams, err := a.Srv().Store.Team().GetAllPage(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllTeamsPageWithCount", "app.team.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -909,6 +909,27 @@ func (a *App) GetAllPrivateTeams() ([]*model.Team, *model.AppError) {
return teams, nil
}
func (a *App) GetAllPrivateTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().GetAllPrivateTeamPageListing(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllPrivateTeamsPage", "app.team.get_all_private_team_page_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return teams, nil
}
func (a *App) GetAllPrivateTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
totalCount, err := a.Srv().Store.Team().AnalyticsPrivateTeamCount()
if err != nil {
return nil, model.NewAppError("GetAllPrivateTeamsPageWithCount", "app.team.analytics_private_team_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
teams, err := a.Srv().Store.Team().GetAllPrivateTeamPageListing(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllPrivateTeamsPageWithCount", "app.team.get_all_private_team_page_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return &model.TeamsWithCount{Teams: teams, TotalCount: totalCount}, nil
}
func (a *App) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().GetAllTeamListing()
if err != nil {
@@ -918,25 +939,46 @@ func (a *App) GetAllPublicTeams() ([]*model.Team, *model.AppError) {
return teams, nil
}
func (a *App) GetAllPublicTeamsPage(offset int, limit int) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().GetAllTeamPageListing(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllPublicTeamsPage", "app.team.get_all_team_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return teams, nil
}
func (a *App) GetAllPublicTeamsPageWithCount(offset int, limit int) (*model.TeamsWithCount, *model.AppError) {
totalCount, err := a.Srv().Store.Team().AnalyticsPublicTeamCount()
if err != nil {
return nil, model.NewAppError("GetAllPublicTeamsPageWithCount", "app.team.analytics_public_team_count.app_error", nil, err.Error(), http.StatusInternalServerError)
}
teams, err := a.Srv().Store.Team().GetAllPublicTeamPageListing(offset, limit)
if err != nil {
return nil, model.NewAppError("GetAllPublicTeamsPageWithCount", "app.team.get_all_private_team_listing.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return &model.TeamsWithCount{Teams: teams, TotalCount: totalCount}, nil
}
// SearchAllTeams returns a team list and the total count of the results
func (a *App) SearchAllTeams(searchOpts *model.TeamSearch) ([]*model.Team, int64, *model.AppError) {
if searchOpts.IsPaginated() {
teams, count, err := a.Srv().Store.Team().SearchAllPaged(searchOpts)
teams, count, err := a.Srv().Store.Team().SearchAllPaged(searchOpts.Term, searchOpts)
if err != nil {
return nil, 0, model.NewAppError("SearchAllTeams", "app.team.search_all_team.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return teams, count, nil
}
results, err := a.Srv().Store.Team().SearchAll(searchOpts)
results, err := a.Srv().Store.Team().SearchAll(searchOpts.Term, searchOpts)
if err != nil {
return nil, 0, model.NewAppError("SearchAllTeams", "app.team.search_all_team.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return results, int64(len(results)), nil
}
func (a *App) SearchPublicTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().SearchOpen(searchOpts)
func (a *App) SearchPublicTeams(term string) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().SearchOpen(term)
if err != nil {
return nil, model.NewAppError("SearchPublicTeams", "app.team.search_open_team.app_error", nil, err.Error(), http.StatusInternalServerError)
}
@@ -944,8 +986,8 @@ func (a *App) SearchPublicTeams(searchOpts *model.TeamSearch) ([]*model.Team, *m
return teams, nil
}
func (a *App) SearchPrivateTeams(searchOpts *model.TeamSearch) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().SearchPrivate(searchOpts)
func (a *App) SearchPrivateTeams(term string) ([]*model.Team, *model.AppError) {
teams, err := a.Srv().Store.Team().SearchPrivate(term)
if err != nil {
return nil, model.NewAppError("SearchPrivateTeams", "app.team.search_private_team.app_error", nil, err.Error(), http.StatusInternalServerError)
}