From 9ab7548ea91e492d3e58a5443196031f2899ef08 Mon Sep 17 00:00:00 2001 From: judell Date: Sat, 25 Mar 2023 11:18:26 -0700 Subject: [PATCH] simplify with function vs hcl with --- tagexplore.sp | 143 +++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 88 deletions(-) diff --git a/tagexplore.sp b/tagexplore.sp index d958063..559ef0c 100644 --- a/tagexplore.sp +++ b/tagexplore.sp @@ -18,6 +18,53 @@ dashboard "TagExplore" { } } + with "mastodon_tag_data" { + sql = <>'account_url' as account_url, - account_url_tag_note->>'tag' as tag - from - data - ) select tag, count(*) from - unnested + mastodon_tag_data($1, $2) group by tag order by count desc - EOQ } - } container { @@ -109,20 +143,8 @@ dashboard "TagExplore" { node { category = category.tagger - args = [ with.data.rows[*].account_url_tag_note ] + args = [ self.input.tag.value, self.input.limit.value] sql = <>'account_url' as account_url, - account_url_tag_note->>'tag' as tag, - account_url_tag_note->>'note' as note - from - data - ) select account_url as id, regexp_match(account_url, '@.+') as title, @@ -131,25 +153,14 @@ dashboard "TagExplore" { 'note', note ) as properties from - unnested + mastodon_tag_data($1, $2) EOQ } node { category = category.tag - args = [ with.data.rows[*].account_url_tag_note ] + args = [ self.input.tag.value, self.input.limit.value] sql = <>'account_url' as account_url, - account_url_tag_note->>'tag' as tag - from - data - ) select tag as id, tag as title, @@ -158,29 +169,18 @@ dashboard "TagExplore" { 'url', '${local.host}/mastodon.dashboard.TagExplore?input.tag=' || tag ) as properties from - unnested + mastodon_tag_data($1, $2) EOQ } edge { - args = [ with.data.rows[*].account_url_tag_note ] + args = [ self.input.tag.value, self.input.limit.value] sql = <>'account_url' as account_url, - account_url_tag_note->>'tag' as tag - from - data - ) select account_url as from_id, tag as to_id from - unnested + mastodon_tag_data($1, $2) EOQ } @@ -188,39 +188,6 @@ dashboard "TagExplore" { } - with "data" { - args = [ self.input.tag.value, self.input.limit.value] - sql = <