From 4fa29db91246e80b88bbd65860c8b0401a456959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= Date: Fri, 9 May 2025 01:55:08 +0000 Subject: [PATCH] fix: Optimize index generation --- friendica-delete-non-follower-featured-posts.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/friendica-delete-non-follower-featured-posts.sh b/friendica-delete-non-follower-featured-posts.sh index 7bf5d4a..89cbf00 100755 --- a/friendica-delete-non-follower-featured-posts.sh +++ b/friendica-delete-non-follower-featured-posts.sh @@ -22,8 +22,9 @@ printf "\rContactDiscovery\t%s\n\r" "${cbmax}" cc=${limit} ccmax=0 +sudo mariadb friendica -B -N -q -e "create table tmp_url (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`));" until [[ ${cc} -lt ${limit} ]]; do - cc=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_addcontact (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"AddContact\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_addcontact) and \`done\` = 0 limit ${cc}; select row_count();") + cc=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where \`command\`= \"AddContact\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_url) and \`done\` = 0 limit ${cc}; select row_count();") ccmax=$((ccmax + cc)) printf "\rAddContact \t%s\r" "${ccmax}" done @@ -32,8 +33,9 @@ printf "\rAddContact \t%s\n\r" "${ccmax}" cd=${limit} cdmax=0 +#sudo mariadb friendica -B -N -q -e "create table tmp_updategserver (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`));" until [[ ${cd} -lt ${limit} ]]; do - cd=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_updategserver (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\` = \"UpdateGServer\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_updategserver) and \`done\` = 0 limit ${cd}; select row_count();") + cd=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where \`command\` = \"UpdateGServer\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_url) and \`done\` = 0 limit ${cd}; select row_count();") cdmax=$((cdmax + cd)) printf "\rUpdateGServer\t\t%s\r" "${cdmax}" done @@ -43,10 +45,11 @@ printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}" ce=${limit} cemax=0 until [[ ${ce} -lt ${limit} ]]; do - ce=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_fetchfeaturedposts (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"FetchFeaturedPosts\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_fetchfeaturedposts) and \`done\` = 0 limit ${ce}; select row_count();") + ce=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where \`command\`= \"FetchFeaturedPosts\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_url) and \`done\` = 0 limit ${ce}; select row_count();") cemax=$((cemax + ce)) printf "\rFetchFeaturedPosts\t%s\r" "${cemax}" done +sudo mariadb friendica -B -N -q -e "drop table tmp_url" printf "\rFetchFeaturedPosts\t%s\n\r" "${cemax}" #echo "FetchFeaturedPosts $cemax"