Skip to content

Commit

Permalink
separate the boost graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
judell committed Mar 15, 2023
1 parent bafe59c commit a3d0a2f
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 246 deletions.
83 changes: 83 additions & 0 deletions boosts_federated.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
dashboard "BoostsFederated" {

tags = {
service = "Mastodon"
}

container {
text {
value = replace(
replace(
"${local.menu}",
"__HOST__",
"${local.host}"
),
"[BoostsFederated](${local.host}/mastodon.dashboard.BoostsFederated)",
"BoostsFederated"
)
}
}

container {

graph {

title = "boosts from server to server"

node {
category = category.server
sql = <<EOQ
select
server as id,
server as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server
) as properties
from
mastodon_toot_home
where
reblog_server is not null
limit ${local.limit}
EOQ
}

node {
category = category.server
sql = <<EOQ
select
reblog_server as id,
reblog_server as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server
) as properties
from
mastodon_toot_home
where
reblog_server is not null
limit ${local.limit}
EOQ
}

edge {
category = category.boost
sql = <<EOQ
select
server as from_id,
reblog_server as to_id,
'boosts' as title
from
mastodon_toot_home
where
reblog_server is not null
limit ${local.limit}
EOQ
}

}

}

}

178 changes: 178 additions & 0 deletions boosts_from_server.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
dashboard "BoostsFromServer" {

tags = {
service = "Mastodon"
}

container {
text {
value = replace(
replace(
"${local.menu}",
"__HOST__",
"${local.host}"
),
"[BoostsFromServer](${local.host}/mastodon.dashboard.BoostsFromServer)",
"BoostsFromServer"
)
}
}

container {
input "server" {
base = input.server
}

graph {

title = "boosts from selected server"

node {
category = category.boosted_server
args = [ self.input.server.value ]
sql = <<EOQ
select
reblog_server as id,
reblog_server as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server
) as properties
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

// Note: the sequence of nodes matters. If mastodon.social is both a server and
// reblog_server, we want this node here to have the selected_server category
node {
category = category.selected_server
args = [ self.input.server.value ]
sql = <<EOQ
select
server as id,
server as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server
) as properties
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

node {
category = category.person
args = [ self.input.server.value ]
sql = <<EOQ
select
username as id,
display_name as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server,
'instance_qualified_account_url', instance_qualified_account_url
) as properties
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

node {
category = category.boosted_person
args = [ self.input.server.value ]
sql = <<EOQ
select
reblog_username as id,
reblog_username as title,
jsonb_build_object(
'server', server,
'reblog_server', reblog_server,
'instance_qualified_reblog_url', instance_qualified_reblog_url,
'content', reblog_content
) as properties
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

edge {
sql = <<EOQ
select
username as from_id,
server as to_id,
'belongs to' as title,
jsonb_build_object(
'username', username,
'server', server,
'reblog_username', reblog_username,
'reblog_server', reblog_server
) as properties
from
mastodon_toot_home
where
reblog_server is not null
limit ${local.limit}
EOQ
}

edge {
args = [ self.input.server.value ]
sql = <<EOQ
select
reblog_username as from_id,
reblog_server as to_id,
'belongs to' as title
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

edge {
category = category.boost
args = [ self.input.server.value ]
sql = <<EOQ
select
username as from_id,
reblog_username as to_id,
'boosts' as title,
jsonb_build_object(
'reblog_username', reblog_username,
'reblog_server', reblog_server,
'content', reblog_content
) as properties
from
mastodon_toot_home
where
reblog_server is not null
and server = $1
limit ${local.limit}
EOQ
}

}

}

}

4 changes: 4 additions & 0 deletions mod.sp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ locals {
menu = <<EOT
[Blocked](__HOST__/mastodon.dashboard.Blocked)
[BoostsFromServer](__HOST__/mastodon.dashboard.BoostsFromServer)
[BoostsFederated](__HOST__/mastodon.dashboard.BoostsFederated)
[Direct](__HOST__/mastodon.dashboard.Direct)
[Favorites](__HOST__/mastodon.dashboard.Favorites)
Expand Down
Loading

0 comments on commit a3d0a2f

Please sign in to comment.