MM-21552: Adding SaveMultiple to posts (#13766)
* Adding SaveMultiple to posts * Improving tests * fixing i18n * Fixing tests * Improving testing on top of Save and SaveMultiple * Fixing shadow variables * Addressing some PR comments * More clear update post test * Addressing some PR comments * Addressing some PR comments and simplifying the code * Improting replies in bulk too * Fixing reply count and processing last imported replies * Adding OverwriteMultiple to posts aggregating everything in the same transaction * Adding 2 pending tests to implement * Adding tests for overwrite multiple posts * Adding tests for TeamStore.GetByNames method * Fixing shadow variables * Addressing PR comments * Extracting i18n strings * Fixing tests * Fixing tests * Adding more test cases * Using a variable instead of a fake timestamp
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2bec92a404
Коммит
27d536b212
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/mattermost/gorp"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -287,6 +288,33 @@ func (s SqlTeamStore) GetByName(name string) (*model.Team, *model.AppError) {
|
||||
return &team, nil
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetByNames(names []string) ([]*model.Team, *model.AppError) {
|
||||
uniqueNames := utils.RemoveDuplicatesFromStringArray(names)
|
||||
|
||||
query := s.getQueryBuilder().
|
||||
Select("*").
|
||||
From("Teams").
|
||||
Where(sq.Eq{"Name": uniqueNames})
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByNames", "store.sql_team.get_by_names.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
teams := []*model.Team{}
|
||||
_, err = s.GetReplica().Select(&teams, queryString, args...)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByNames", "store.sql_team.get_by_names.missing.app_error", nil, err.Error(), http.StatusNotFound)
|
||||
}
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByNames", "store.sql_team.get_by_names.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if len(teams) != len(uniqueNames) {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByNames", "store.sql_team.get_by_names.missing.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
return teams, nil
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) SearchAll(term string) ([]*model.Team, *model.AppError) {
|
||||
var teams []*model.Team
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user