avoid SELECT * in audit store (#30829)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e9c54bf88e
Коммит
3c9b2511bc
@@ -13,10 +13,28 @@ import (
|
|||||||
|
|
||||||
type SqlAuditStore struct {
|
type SqlAuditStore struct {
|
||||||
*SqlStore
|
*SqlStore
|
||||||
|
|
||||||
|
auditQuery sq.SelectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSqlAuditStore(sqlStore *SqlStore) store.AuditStore {
|
func newSqlAuditStore(sqlStore *SqlStore) store.AuditStore {
|
||||||
return &SqlAuditStore{sqlStore}
|
s := &SqlAuditStore{
|
||||||
|
SqlStore: sqlStore,
|
||||||
|
}
|
||||||
|
|
||||||
|
s.auditQuery = s.getQueryBuilder().
|
||||||
|
Select(
|
||||||
|
"Id",
|
||||||
|
"CreateAt",
|
||||||
|
"UserId",
|
||||||
|
"Action",
|
||||||
|
"ExtraInfo",
|
||||||
|
"IpAddress",
|
||||||
|
"SessionId",
|
||||||
|
).
|
||||||
|
From("Audits")
|
||||||
|
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlAuditStore) Save(audit *model.Audit) error {
|
func (s SqlAuditStore) Save(audit *model.Audit) error {
|
||||||
@@ -37,9 +55,7 @@ func (s SqlAuditStore) Get(userId string, offset int, limit int) (model.Audits,
|
|||||||
return nil, store.NewErrOutOfBounds(limit)
|
return nil, store.NewErrOutOfBounds(limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
query := s.getQueryBuilder().
|
query := s.auditQuery.
|
||||||
Select("*").
|
|
||||||
From("Audits").
|
|
||||||
OrderBy("CreateAt DESC").
|
OrderBy("CreateAt DESC").
|
||||||
Limit(uint64(limit)).
|
Limit(uint64(limit)).
|
||||||
Offset(uint64(offset))
|
Offset(uint64(offset))
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user