diff --git a/.gitignore b/.gitignore index 8af02c68bf..af38a25eac 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,5 @@ docker-compose.override.yaml ## Notice Folders .notice/ .notice-work/ +.aider* +.env diff --git a/server/channels/store/sqlstore/webhook_store.go b/server/channels/store/sqlstore/webhook_store.go index 8fbc6cd4c2..7a174a0478 100644 --- a/server/channels/store/sqlstore/webhook_store.go +++ b/server/channels/store/sqlstore/webhook_store.go @@ -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