avoid SELECT * in notify admin store (#30834)

Этот коммит содержится в:
Jesse Hallam
2025-04-22 17:27:33 -03:00
коммит произвёл GitHub
родитель a36d29b459
Коммит b095ba22b8

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

@@ -17,10 +17,27 @@ import (
type SqlNotifyAdminStore struct {
*SqlStore
notifyAdminQuery sq.SelectBuilder
}
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) {
@@ -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) {
data := []*model.NotifyAdminData{}
query, args, err := s.getQueryBuilder().
Select("*").
From("NotifyAdmin").
query, args, err := s.notifyAdminQuery.
Where(sq.Eq{"UserId": userId, "RequiredFeature": feature}).
ToSql()
if err != nil {
@@ -65,9 +80,7 @@ func (s SqlNotifyAdminStore) GetDataByUserIdAndFeature(userId string, feature mo
func (s SqlNotifyAdminStore) Get(trial bool) ([]*model.NotifyAdminData, error) {
data := []*model.NotifyAdminData{}
query, args, err := s.getQueryBuilder().
Select("*").
From("NotifyAdmin").
query, args, err := s.notifyAdminQuery.
Where(sq.Eq{"Trial": trial}).
Where("(SentAt IS NULL)").
ToSql()