mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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>
This commit is contained in:
parent
f1cb9f1ec2
commit
7df4727353
2
.gitignore
vendored
2
.gitignore
vendored
@ -157,3 +157,5 @@ docker-compose.override.yaml
|
||||
## Notice Folders
|
||||
.notice/
|
||||
.notice-work/
|
||||
.aider*
|
||||
.env
|
||||
|
@ -121,12 +121,7 @@ func (s SqlWebhookStore) GetIncomingListByUser(userId string, offset, limit int)
|
||||
query = query.Where(sq.Eq{"UserId": userId})
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "incoming_webhook_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
||||
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||
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})
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "incoming_webhook_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
||||
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||
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})
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
||||
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||
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))
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
||||
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||
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))
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "outgoing_webhook_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().Select(&webhooks, queryString, args...); err != nil {
|
||||
if err := s.GetReplica().SelectBuilder(&webhooks, query); err != nil {
|
||||
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})
|
||||
}
|
||||
|
||||
queryString, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "incoming_webhook_tosql")
|
||||
}
|
||||
|
||||
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 count, nil
|
||||
@ -390,13 +360,8 @@ func (s SqlWebhookStore) AnalyticsOutgoingCount(teamId string) (int64, error) {
|
||||
queryBuilder = queryBuilder.Where("TeamId", teamId)
|
||||
}
|
||||
|
||||
queryString, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "outgoing_webhook_tosql")
|
||||
}
|
||||
|
||||
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 count, nil
|
||||
|
Loading…
Reference in New Issue
Block a user