avoid SELECT * in notify admin store (#30834)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a36d29b459
Коммит
b095ba22b8
@@ -17,10 +17,27 @@ import (
|
|||||||
|
|
||||||
type SqlNotifyAdminStore struct {
|
type SqlNotifyAdminStore struct {
|
||||||
*SqlStore
|
*SqlStore
|
||||||
|
|
||||||
|
notifyAdminQuery sq.SelectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlNotifyAdminStore(sqlStore *SqlStore) store.NotifyAdminStore {
|
func newSqlNotifyAdminStore(sqlStore *SqlStore) store.NotifyAdminStore {
|
||||||
return &SqlNotifyAdminStore{sqlStore}
|
s := &SqlNotifyAdminStore{
|
||||||
|
SqlStore: sqlStore,
|
||||||
|
}
|
||||||
|
|
||||||
|
s.notifyAdminQuery = s.getQueryBuilder().
|
||||||
|
Select(
|
||||||
|
"UserId",
|
||||||
|
"CreateAt",
|
||||||
|
"RequiredPlan",
|
||||||
|
"RequiredFeature",
|
||||||
|
"Trial",
|
||||||
|
"SentAt",
|
||||||
|
).
|
||||||
|
From("NotifyAdmin")
|
||||||
|
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlNotifyAdminStore) insert(data *model.NotifyAdminData) (sql.Result, error) {
|
func (s SqlNotifyAdminStore) insert(data *model.NotifyAdminData) (sql.Result, error) {
|
||||||
@@ -45,9 +62,7 @@ func (s SqlNotifyAdminStore) Save(data *model.NotifyAdminData) (*model.NotifyAdm
|
|||||||
|
|
||||||
func (s SqlNotifyAdminStore) GetDataByUserIdAndFeature(userId string, feature model.MattermostFeature) ([]*model.NotifyAdminData, error) {
|
func (s SqlNotifyAdminStore) GetDataByUserIdAndFeature(userId string, feature model.MattermostFeature) ([]*model.NotifyAdminData, error) {
|
||||||
data := []*model.NotifyAdminData{}
|
data := []*model.NotifyAdminData{}
|
||||||
query, args, err := s.getQueryBuilder().
|
query, args, err := s.notifyAdminQuery.
|
||||||
Select("*").
|
|
||||||
From("NotifyAdmin").
|
|
||||||
Where(sq.Eq{"UserId": userId, "RequiredFeature": feature}).
|
Where(sq.Eq{"UserId": userId, "RequiredFeature": feature}).
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -65,9 +80,7 @@ func (s SqlNotifyAdminStore) GetDataByUserIdAndFeature(userId string, feature mo
|
|||||||
|
|
||||||
func (s SqlNotifyAdminStore) Get(trial bool) ([]*model.NotifyAdminData, error) {
|
func (s SqlNotifyAdminStore) Get(trial bool) ([]*model.NotifyAdminData, error) {
|
||||||
data := []*model.NotifyAdminData{}
|
data := []*model.NotifyAdminData{}
|
||||||
query, args, err := s.getQueryBuilder().
|
query, args, err := s.notifyAdminQuery.
|
||||||
Select("*").
|
|
||||||
From("NotifyAdmin").
|
|
||||||
Where(sq.Eq{"Trial": trial}).
|
Where(sq.Eq{"Trial": trial}).
|
||||||
Where("(SentAt IS NULL)").
|
Where("(SentAt IS NULL)").
|
||||||
ToSql()
|
ToSql()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user