From 21803e6410d12082fbcfa74d2f9fc50940eac620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= <csolisr@azkware.net> Date: Wed, 5 Mar 2025 15:05:22 -0600 Subject: [PATCH] feat: Add script to detect accounts with the largest amount of posts --- friendica-find-largest-accounts.sh | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 friendica-find-largest-accounts.sh diff --git a/friendica-find-largest-accounts.sh b/friendica-find-largest-accounts.sh new file mode 100755 index 0000000..80fdf60 --- /dev/null +++ b/friendica-find-largest-accounts.sh @@ -0,0 +1,52 @@ +#!/bin/bash +#Check for mariadb vs. mysql +dbengine="" +if [[ -n $(type mariadb) ]]; then + dbengine="mariadb" +elif [[ -n $(type mysql) ]]; then + dbengine="mysql" +else + exit +fi +db="friendica" +"${dbengine}" "${db}" -e "\ + create temporary table tmp_authors (\ + select \`author-id\`, \ + count(*) as amount \ + from \`post-user\` \ + group by \`author-id\` \ + order by count(*) desc \ + limit 1000 \ + ); \ + create temporary table tmp_owners (\ + select \`owner-id\`, \ + count(*) as amount \ + from \`post-user\` \ + group by \`owner-id\` \ + order by count(*) desc \ + limit 1000 \ + ); \ + create temporary table tmp_causers (\ + select \`causer-id\`, \ + count(*) as amount \ + from \`post-user\` \ + group by \`causer-id\` \ + order by count(*) desc \ + limit 1000 \ + ); \ + select c.url, \ + c.\`id\`, \ + g.platform, \ + a.amount \ + from contact as c \ + right join tmp_authors as a \ + on c.id = a.\`author-id\` \ + right join tmp_owners as o \ + on c.id = o.\`owner-id\` \ + right join tmp_causers as t \ + on c.id = t.\`causer-id\` \ + left join gserver as g \ + on g.id = c.gsid \ + where g.platform != \"lemmy\" \ + and g.platform != \"\" \ + limit 100;"