From 76df9c8d7648f5cae4c07c2d640a36a2b434f768 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 26 Aug 2022 16:49:51 +0530 Subject: [PATCH] Refactor and simply function name. --- internal/core/subscribers.go | 4 ++-- internal/core/subscriptions.go | 6 +++--- models/queries.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/core/subscribers.go b/internal/core/subscribers.go index 597ad44..bb4eea8 100644 --- a/internal/core/subscribers.go +++ b/internal/core/subscribers.go @@ -356,7 +356,7 @@ func (c *Core) BlocklistSubscribers(subIDs []int) error { // BlocklistSubscribersByQuery blocklists the given list of subscribers. func (c *Core) BlocklistSubscribersByQuery(query string, listIDs []int) error { - if err := c.q.ExecSubscriberQueryTpl(sanitizeSQLExp(query), c.q.BlocklistSubscribersByQuery, listIDs, c.db); err != nil { + if err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.BlocklistSubscribersByQuery, listIDs, c.db); err != nil { c.log.Printf("error blocklisting subscribers: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, c.i18n.Ts("subscribers.errorBlocklisting", "error", pqErrMsg(err))) @@ -385,7 +385,7 @@ func (c *Core) DeleteSubscribers(subIDs []int, subUUIDs []string) error { // DeleteSubscribersByQuery deletes subscribers by a given arbitrary query expression. func (c *Core) DeleteSubscribersByQuery(query string, listIDs []int) error { - err := c.q.ExecSubscriberQueryTpl(sanitizeSQLExp(query), c.q.DeleteSubscribersByQuery, listIDs, c.db) + err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.DeleteSubscribersByQuery, listIDs, c.db) if err != nil { c.log.Printf("error deleting subscribers: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, diff --git a/internal/core/subscriptions.go b/internal/core/subscriptions.go index b438db0..db2e4ce 100644 --- a/internal/core/subscriptions.go +++ b/internal/core/subscriptions.go @@ -25,7 +25,7 @@ func (c *Core) AddSubscriptionsByQuery(query string, sourceListIDs, targetListID sourceListIDs = []int{} } - err := c.q.ExecSubscriberQueryTpl(sanitizeSQLExp(query), c.q.AddSubscribersToListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) + err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.AddSubscribersToListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) if err != nil { c.log.Printf("error adding subscriptions by query: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, @@ -54,7 +54,7 @@ func (c *Core) DeleteSubscriptionsByQuery(query string, sourceListIDs, targetLis sourceListIDs = []int{} } - err := c.q.ExecSubscriberQueryTpl(sanitizeSQLExp(query), c.q.DeleteSubscriptionsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) + err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.DeleteSubscriptionsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) if err != nil { c.log.Printf("error deleting subscriptions by query: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, @@ -82,7 +82,7 @@ func (c *Core) UnsubscribeListsByQuery(query string, sourceListIDs, targetListID sourceListIDs = []int{} } - err := c.q.ExecSubscriberQueryTpl(sanitizeSQLExp(query), c.q.UnsubscribeSubscribersFromListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) + err := c.q.ExecSubQueryTpl(sanitizeSQLExp(query), c.q.UnsubscribeSubscribersFromListsByQuery, sourceListIDs, c.db, pq.Array(targetListIDs)) if err != nil { c.log.Printf("error unsubscriging from lists by query: %v", err) return echo.NewHTTPError(http.StatusInternalServerError, diff --git a/models/queries.go b/models/queries.go index 0904aad..aeece0d 100644 --- a/models/queries.go +++ b/models/queries.go @@ -126,7 +126,7 @@ func (q *Queries) CompileSubscriberQueryTpl(exp string, db *sqlx.DB) (string, er // compileSubscriberQueryTpl takes an arbitrary WHERE expressions and a subscriber // query template that depends on the filter (eg: delete by query, blocklist by query etc.) // combines and executes them. -func (q *Queries) ExecSubscriberQueryTpl(exp, tpl string, listIDs []int, db *sqlx.DB, args ...interface{}) error { +func (q *Queries) ExecSubQueryTpl(exp, tpl string, listIDs []int, db *sqlx.DB, args ...interface{}) error { // Perform a dry run. filterExp, err := q.CompileSubscriberQueryTpl(exp, db) if err != nil {