Add subscription created_at, updated_at when listing subscribers list (#1018)

This commit is contained in:
Romain 2022-11-09 17:10:11 +01:00 committed by GitHub
parent fd70776166
commit 6d3ae4cc73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -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.

View file

@ -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)