mirror of
https://github.com/knadh/listmonk.git
synced 2024-11-10 09:02:36 +08:00
Add no_lists
param to subscriber query.
This commit is contained in:
parent
681f3073c6
commit
dccbdf90f3
3 changed files with 10 additions and 7 deletions
|
@ -92,6 +92,7 @@ func handleQuerySubscribers(c echo.Context) error {
|
||||||
subStatus = c.FormValue("subscription_status")
|
subStatus = c.FormValue("subscription_status")
|
||||||
orderBy = c.FormValue("order_by")
|
orderBy = c.FormValue("order_by")
|
||||||
order = c.FormValue("order")
|
order = c.FormValue("order")
|
||||||
|
noLists = c.FormValue("no_lists") == "true"
|
||||||
out models.PageResults
|
out models.PageResults
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ func handleQuerySubscribers(c echo.Context) error {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("globals.messages.invalidID"))
|
return echo.NewHTTPError(http.StatusBadRequest, app.i18n.T("globals.messages.invalidID"))
|
||||||
}
|
}
|
||||||
|
|
||||||
res, total, err := app.core.QuerySubscribers(query, listIDs, subStatus, order, orderBy, pg.Offset, pg.Limit)
|
res, total, err := app.core.QuerySubscribers(query, listIDs, subStatus, order, orderBy, pg.Offset, pg.Limit, noLists)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ Retrieve all subscribers.
|
||||||
| order | string | | Sorting order: ASC for ascending, DESC for descending. |
|
| order | string | | Sorting order: ASC for ascending, DESC for descending. |
|
||||||
| page | number | | Page number for paginated results. |
|
| page | number | | Page number for paginated results. |
|
||||||
| per_page | number | | Results per page. Set as 'all' for all results. |
|
| per_page | number | | Results per page. Set as 'all' for all results. |
|
||||||
|
| no_lists | bool | | The lists to which the subscriber is registered are not displayed. |
|
||||||
|
|
||||||
##### Example Request
|
##### Example Request
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (c *Core) GetSubscribersByEmail(emails []string) (models.Subscribers, error
|
||||||
}
|
}
|
||||||
|
|
||||||
// QuerySubscribers queries and returns paginated subscrribers based on the given params including the total count.
|
// QuerySubscribers queries and returns paginated subscrribers based on the given params including the total count.
|
||||||
func (c *Core) QuerySubscribers(query string, listIDs []int, subStatus string, order, orderBy string, offset, limit int) (models.Subscribers, int, error) {
|
func (c *Core) QuerySubscribers(query string, listIDs []int, subStatus string, order, orderBy string, offset, limit int, noLists bool) (models.Subscribers, int, error) {
|
||||||
// There's an arbitrary query condition.
|
// There's an arbitrary query condition.
|
||||||
cond := ""
|
cond := ""
|
||||||
if query != "" {
|
if query != "" {
|
||||||
|
@ -117,12 +117,13 @@ func (c *Core) QuerySubscribers(query string, listIDs []int, subStatus string, o
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lazy load lists for each subscriber.
|
// Lazy load lists for each subscriber.
|
||||||
if err := out.LoadLists(c.q.GetSubscriberListsLazy); err != nil {
|
if !noLists {
|
||||||
c.log.Printf("error fetching subscriber lists: %v", err)
|
if err := out.LoadLists(c.q.GetSubscriberListsLazy); err != nil {
|
||||||
return nil, 0, echo.NewHTTPError(http.StatusInternalServerError,
|
c.log.Printf("error fetching subscriber lists: %v", err)
|
||||||
c.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.subscribers}", "error", pqErrMsg(err)))
|
return nil, 0, echo.NewHTTPError(http.StatusInternalServerError,
|
||||||
|
c.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.subscribers}", "error", pqErrMsg(err)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, total, nil
|
return out, total, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue