Add subscription created_at, updated_at when listing subscribers list (#1018)
This commit is contained in:
parent
fd70776166
commit
6d3ae4cc73
2 changed files with 10 additions and 2 deletions
|
@ -221,6 +221,8 @@ type List struct {
|
|||
|
||||
// This is only relevant when querying the lists of a subscriber.
|
||||
SubscriptionStatus string `db:"subscription_status" json:"subscription_status,omitempty"`
|
||||
SubscriptionCreatedAt null.Time `db:"subscription_created_at" json:"subscription_created_at,omitempty"`
|
||||
SubscriptionUpdatedAt null.Time `db:"subscription_updated_at" json:"subscription_updated_at,omitempty"`
|
||||
|
||||
// Pseudofield for getting the total number of subscribers
|
||||
// in searches and queries.
|
||||
|
|
|
@ -38,7 +38,13 @@ SELECT * FROM lists
|
|||
WITH subs AS (
|
||||
SELECT subscriber_id, JSON_AGG(
|
||||
ROW_TO_JSON(
|
||||
(SELECT l FROM (SELECT subscriber_lists.status AS subscription_status, lists.*) l)
|
||||
(SELECT l FROM (
|
||||
SELECT
|
||||
subscriber_lists.status AS subscription_status,
|
||||
subscriber_lists.created_at AS subscription_created_at,
|
||||
subscriber_lists.updated_at AS subscription_updated_at,
|
||||
lists.*
|
||||
) l)
|
||||
)
|
||||
) AS lists FROM lists
|
||||
LEFT JOIN subscriber_lists ON (subscriber_lists.list_id = lists.id)
|
||||
|
|
Loading…
Reference in a new issue