~netlandish/links-dev

links: api: fix `createdOn` assignment when fetching tags for individual bookmarks, shorts, listings. v1 APPLIED

Peter Sanchez: 1
 api: fix `createdOn` assignment when fetching tags for individual bookmarks, shorts, listings.

 5 files changed, 8 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.code.netlandish.com/~netlandish/links-dev/patches/217/mbox | git am -3
Learn more about email & git

[PATCH links] api: fix `createdOn` assignment when fetching tags for individual bookmarks, shorts, listings. Export this patch

Changelog-fixed: Issue setting createdOn value for tags associated with
 bookmarks, shorts, listings.
Changelog-updated: API server version to 0.10.2
---
 api/graph/schema.resolvers.go | 2 +-
 models/base_url.go            | 2 +-
 models/link_short.go          | 4 ++--
 models/listing.go             | 4 ++--
 models/org_link.go            | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go
index 2c11efb..bf295fd 100644
--- a/api/graph/schema.resolvers.go
+++ b/api/graph/schema.resolvers.go
@@ -5126,7 +5126,7 @@ func (r *queryResolver) Version(ctx context.Context) (*model.Version, error) {
	return &model.Version{
		Major:           0,
		Minor:           10,
		Patch:           1,
		Patch:           2,
		DeprecationDate: nil,
	}, nil
}
diff --git a/models/base_url.go b/models/base_url.go
index 8a88578..5510991 100644
--- a/models/base_url.go
+++ b/models/base_url.go
@@ -65,7 +65,7 @@ func GetBaseURLs(ctx context.Context, opts *database.FilterOptions) ([]*BaseURL,
		rows, err := q.
			Columns("b.id", "b.url", "b.title", "b.counter", "b.data", "b.public_ready", "b.hash",
				"b.parse_attempts", "b.last_parse_attempt", "b.created_on", "b.visibility",
				fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END ORDER BY %s)::jsonb", tagOrder)).
				fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END ORDER BY %s)::jsonb", tagOrder)).
			From("base_urls b").
			LeftJoin("org_links ol ON ol.base_url_id = b.id").
			LeftJoin("organizations o ON o.id = ol.org_id").
diff --git a/models/link_short.go b/models/link_short.go
index a2b03bf..c8cae2e 100644
--- a/models/link_short.go
+++ b/models/link_short.go
@@ -22,7 +22,7 @@ func GetLinkShorts(ctx context.Context, opts *database.FilterOptions) ([]*LinkSh
		q := opts.GetBuilder(nil)
		rows, err := q.
			Columns("l.id", "l.title", "l.url", "l.short_code", "l.domain_id", "l.org_id", "l.user_id",
				"l.created_on", "l.updated_on", "d.lookup_name", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END)::jsonb").
				"l.created_on", "l.updated_on", "d.lookup_name", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END)::jsonb").
			From("link_shorts AS l").
			InnerJoin("domains d ON l.domain_id = d.id").
			LeftJoin("tag_link_shorts tl ON tl.link_short_id = l.id").
@@ -236,7 +236,7 @@ func ExportLinkShorts(ctx context.Context, opts *database.FilterOptions) ([]*Exp
	if err := database.WithTx(ctx, database.TxOptionsRO, func(tx *sql.Tx) error {
		q := opts.GetBuilder(nil)
		rows, err := q.
			Columns("l.id", "l.title", "l.url", "l.short_code", "l.created_on", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END)::jsonb").
			Columns("l.id", "l.title", "l.url", "l.short_code", "l.created_on", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END)::jsonb").
			From("link_shorts AS l").
			LeftJoin("tag_link_shorts tl ON tl.link_short_id = l.id").
			LeftJoin("tags t ON t.id = tl.tag_id").
diff --git a/models/listing.go b/models/listing.go
index b7c9636..410f2ef 100644
--- a/models/listing.go
+++ b/models/listing.go
@@ -22,7 +22,7 @@ func GetListings(ctx context.Context, opts *database.FilterOptions) ([]*Listing,
		rows, err := q.
			Columns("l.id", "l.title", "l.slug", "l.image", "l.metadata", "l.domain_id", "l.org_id",
				"l.user_id", "l.is_default", "l.is_active", "l.created_on", "l.updated_on", "d.lookup_name",
				"json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END)::jsonb").
				"json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END)::jsonb").
			From("listings l").
			InnerJoin("domains d ON l.domain_id = d.id").
			InnerJoin("organizations o ON l.org_id = o.id").
@@ -220,7 +220,7 @@ func ExportListings(ctx context.Context, opts *database.FilterOptions) ([]*Expor
	if err := database.WithTx(ctx, database.TxOptionsRO, func(tx *sql.Tx) error {
		q := opts.GetBuilder(nil)
		rows, err := q.
			Columns("l.id", "l.title", "l.slug", "l.created_on", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END)::jsonb", "json_agg(ll)::jsonb").
			Columns("l.id", "l.title", "l.slug", "l.created_on", "json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END)::jsonb", "json_agg(ll)::jsonb").
			From("listings l").
			LeftJoin("listing_links ll ON l.id = ll.listing_id").
			LeftJoin("tag_listings tl ON tl.listing_id = l.id").
diff --git a/models/org_link.go b/models/org_link.go
index 0148c5b..19a0a1e 100644
--- a/models/org_link.go
+++ b/models/org_link.go
@@ -37,7 +37,7 @@ func GetOrgLinks(ctx context.Context, opts *database.FilterOptions) ([]*OrgLink,
		rows, err := q.
			Columns("ol.id", "ol.title", "ol.url", "ol.description", "ol.base_url_id", "ol.org_id", "ol.user_id",
				"ol.visibility", "ol.unread", "ol.starred", "ol.archive_url", "ol.type", "ol.hash",
				"ol.created_on", "ol.updated_on", "o.slug", "u.full_name", fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END ORDER BY %s)::jsonb", tagOrder), "b.data", "b.counter", "b.hash").
				"ol.created_on", "ol.updated_on", "o.slug", "u.full_name", fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END ORDER BY %s)::jsonb", tagOrder), "b.data", "b.counter", "b.hash").
			From("org_links ol").
			Join("organizations o ON o.id = ol.org_id").
			Join("users u ON ol.user_id = u.id").
@@ -325,7 +325,7 @@ func ExportOrgLinks(ctx context.Context, opts *database.FilterOptions) ([]*Expor
		q := opts.GetBuilder(nil)
		rows, err := q.
			Columns("ol.id", "ol.title", "ol.url", "ol.description", "ol.visibility",
				"ol.unread", "ol.starred", "ol.hash", "ol.created_on", fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'created_on', t.created_on) END ORDER BY %s)::jsonb", tagOrder)).
				"ol.unread", "ol.starred", "ol.hash", "ol.created_on", fmt.Sprintf("json_agg(CASE WHEN t.id IS NOT NULL THEN json_build_object('id', t.id, 'name', tl.name, 'slug', t.slug, 'createdOn', t.created_on) END ORDER BY %s)::jsonb", tagOrder)).
			From("org_links ol").
			LeftJoin("tag_links tl ON tl.org_link_id = ol.id").
			LeftJoin("tags t ON t.id = tl.tag_id").
-- 
2.52.0
Applied.

To git@git.code.netlandish.com:~netlandish/links
   99798c8..78efdd9  master -> master