[Aider assisted]: Use SelectBuilder and GetBuilder in webhook_store.go (#29555)
I was planning to kick off a campaign for this. But aider can do this just fine. Starting off with a single file for now. But will slowly send more PRs with larger commit diffs. ```release-note NONE ``` Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f1cb9f1ec2
Коммит
7df4727353
2
.gitignore
поставляемый
2
.gitignore
поставляемый
@@ -157,3 +157,5 @@ docker-compose.override.yaml
|
|||||||
## Notice Folders
|
## Notice Folders
|
||||||
.notice/
|
.notice/
|
||||||
.notice-work/
|
.notice-work/
|
||||||
|
.aider*
|
||||||
|
.env
|
||||||
|
|||||||
@@ -121,12 +121,7 @@ func (s SqlWebhookStore) GetIncomingListByUser(userId string, offset, limit int)
|
|||||||
query = query.Where(sq.Eq{"UserId": userId})
|
query = query.Where(sq.Eq{"UserId": userId})
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "incoming_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to find IncomingWebhooks")
|
return nil, errors.Wrap(err, "failed to find IncomingWebhooks")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,12 +143,7 @@ func (s SqlWebhookStore) GetIncomingByTeamByUser(teamId string, userId string, o
|
|||||||
query = query.Where(sq.Eq{"UserId": userId})
|
query = query.Where(sq.Eq{"UserId": userId})
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "incoming_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to find IncomingWebhook with teamId=%s", teamId)
|
return nil, errors.Wrapf(err, "failed to find IncomingWebhook with teamId=%s", teamId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,12 +214,7 @@ func (s SqlWebhookStore) GetOutgoingListByUser(userId string, offset, limit int)
|
|||||||
query = query.Where(sq.Eq{"CreatorId": userId})
|
query = query.Where(sq.Eq{"CreatorId": userId})
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,12 +243,7 @@ func (s SqlWebhookStore) GetOutgoingByChannelByUser(channelId string, userId str
|
|||||||
query = query.Limit(uint64(limit)).Offset(uint64(offset))
|
query = query.Limit(uint64(limit)).Offset(uint64(offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,12 +272,7 @@ func (s SqlWebhookStore) GetOutgoingByTeamByUser(teamId string, userId string, o
|
|||||||
query = query.Limit(uint64(limit)).Offset(uint64(offset))
|
query = query.Limit(uint64(limit)).Offset(uint64(offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := query.ToSql()
|
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
return nil, errors.Wrap(err, "failed to find OutgoingWebhooks")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,13 +342,8 @@ func (s SqlWebhookStore) AnalyticsIncomingCount(teamID string, userID string) (i
|
|||||||
queryBuilder = queryBuilder.Where(sq.Eq{"UserId": userID})
|
queryBuilder = queryBuilder.Where(sq.Eq{"UserId": userID})
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := queryBuilder.ToSql()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.Wrap(err, "incoming_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
if err := s.GetReplica().Get(&count, queryString, args...); err != nil {
|
if err := s.GetReplica().GetBuilder(&count, queryBuilder); err != nil {
|
||||||
return 0, errors.Wrap(err, "failed to count IncomingWebhooks")
|
return 0, errors.Wrap(err, "failed to count IncomingWebhooks")
|
||||||
}
|
}
|
||||||
return count, nil
|
return count, nil
|
||||||
@@ -390,13 +360,8 @@ func (s SqlWebhookStore) AnalyticsOutgoingCount(teamId string) (int64, error) {
|
|||||||
queryBuilder = queryBuilder.Where("TeamId", teamId)
|
queryBuilder = queryBuilder.Where("TeamId", teamId)
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString, args, err := queryBuilder.ToSql()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.Wrap(err, "outgoing_webhook_tosql")
|
|
||||||
}
|
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
if err := s.GetReplica().Get(&count, queryString, args...); err != nil {
|
if err := s.GetReplica().GetBuilder(&count, queryBuilder); err != nil {
|
||||||
return 0, errors.Wrap(err, "failed to count OutgoingWebhooks")
|
return 0, errors.Wrap(err, "failed to count OutgoingWebhooks")
|
||||||
}
|
}
|
||||||
return count, nil
|
return count, nil
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user