fix: Correct major typo that would delete all post-media

This commit is contained in:
Carlos Solís 2025-02-07 13:23:20 +00:00
parent f92982f10e
commit af11063bd8
2 changed files with 27 additions and 22 deletions

View file

@ -281,7 +281,6 @@ until [[ "${tmp_item_uri_not_valid_q}" -lt "${limit}" ]]; do
AND NOT EXISTS ( SELECT \`parent-uri-id\` FROM \`mail\` WHERE \`parent-uri-id\` = \`item-uri\`.\`id\` ) \
AND NOT EXISTS ( SELECT \`thr-parent-id\` FROM \`mail\` WHERE \`thr-parent-id\` = \`item-uri\`.\`id\` ) \
ORDER BY \`id\` LIMIT ${limit}")
final_i=$(($(date +%s) - initial_i))
echo "${tmp_item_uri_not_valid_q} item(s) deleted until ${tmp_item_uri_not_valid_current_id} in ${final_i}s"
done
@ -325,7 +324,7 @@ until [[ "${tmp_post_media_duplicate_q}" -lt "${limit}" ]]; do
tmp_post_media_duplicate_current_id="${id}"
fi
done < <("${dbengine}" "${db}" -N -B -q -e \
"SELECT u1.\`id\` FROM \`post-media\` u1 INNER JOIN \`post-media\` u2 WHERE u1.\`id\` < u2.\`id\` AND u1.\`uri-id\` = u2.\`uri-id\` AND u1.\`url\`= u2.\`url\` LIMIT ${limit}")
"SELECT u1.\`id\` FROM \`post-media\` u1 INNER JOIN \`post-media\` u2 WHERE u1.\`id\` > $(id) AND u1.\`id\` < u2.\`id\` AND u1.\`uri-id\` = u2.\`uri-id\` AND u1.\`url\`= u2.\`url\` LIMIT ${limit}")
final_i=$(($(date +%s) - initial_i))
echo "${tmp_post_media_duplicate_q} item(s) deleted until ${tmp_post_media_duplicate_current_id} in ${final_i}s"
done
@ -347,7 +346,7 @@ until [[ "${tmp_post_user_duplicate_q}" -lt "${limit}" ]]; do
tmp_post_user_duplicate_current_id="${id}"
fi
done < <("${dbengine}" "${db}" -N -B -q -e \
"SELECT v1.\`id\` FROM \`post-user\` v1 INNER JOIN \`post-media\` v2 WHERE v1.\`id\` = v2.\`id\` AND v1.\`uri-id\` = v2.\`uri-id\` LIMIT ${limit}")
"SELECT v1.\`id\` FROM \`post-user\` v1 INNER JOIN \`post-media\` v2 WHERE v1.\`id\` > $(id) AND v1.\`id\` < v2.\`id\` AND v1.\`uri-id\` = v2.\`uri-id\` LIMIT ${limit}")
fi
final_i=$(($(date +%s) - initial_i))
echo "${tmp_post_user_duplicate_q} item(s) deleted until ${tmp_post_user_duplicate_current_id} in ${final_i}s"

View file

@ -1,9 +1,10 @@
#!/bin/bash
ca=100
camax=0
while [[ ${ca} -gt 0 ]]; do
while [[ ${ca} -gt 0 ]]
do
ca=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"UpdateContact\" limit ${ca}; select row_count();")
camax=$((camax + ca))
camax=$(( camax + ca ))
printf "\rUpdateContact\t\t%s\r" "${camax}"
done
printf "\rUpdateContact\t\t%s\n\r" "${camax}"
@ -11,9 +12,10 @@ printf "\rUpdateContact\t\t%s\n\r" "${camax}"
cb=100
cbmax=0
while [[ ${cb} -gt 0 ]]; do
while [[ ${cb} -gt 0 ]]
do
cb=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"ContactDiscovery\" limit ${cb}; select row_count();")
cbmax=$((cbmax + cb))
cbmax=$(( cbmax + cb ))
printf "\rContactDiscovery\t%s\r" "${cbmax}"
done
printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
@ -21,31 +23,35 @@ printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
cc=100
ccmax=0
while [[ ${cc} -gt 0 ]]; do
cc=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') in (select \`url\` from \`contact\` where \`id\` not in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"UpdateGServer\" limit ${cd}; select row_count();")
ccmax=$((ccmax + cc))
printf "\rUpdateGServer\t\t%s\r" "${ccmax}"
while [[ ${cc} -gt 0 ]]
do
cc=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"FetchFeaturedPosts\" limit ${cc}; select row_count();")
ccmax=$(( ccmax + cc ))
printf "\rFetchFeaturedPosts\t%s\r" "${ccmax}"
done
printf "\rUpdateGServer\t\t%s\n\r" "${ccmax}"
#echo "UpdateGServer $ccmax"
printf "\rFetchFeaturedPosts\t%s\n\r" "${ccmax}"
#echo "FetchFeaturedPosts $ccmax"
cd=100
cdmax=0
while [[ ${cd} -gt 0 ]]; do
cd=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') in (select \`url\` from \`contact\` where \`id\` not in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"FetchFeaturedPosts\" limit ${cc}; select row_count();")
cdmax=$((ccmax + cc))
printf "\rFetchFeaturedPosts\t%s\r" "${cdmax}"
while [[ ${cd} -gt 0 ]]
do
cd=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"UpdateGServer\" limit ${cd}; select row_count();")
cdmax=$(( cdmax + cd ))
printf "\rUpdateGServer\t\t%s\r" "${cdmax}"
done
printf "\rFetchFeaturedPosts\t%s\n\r" "${cdmax}"
#echo "FetchFeaturedPosts $cdmax"
printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}"
#echo "UpdateGServer $cdmax"
ce=100
cemax=0
while [[ ${ce} -gt 0 ]]; do
while [[ ${ce} -gt 0 ]]
do
ce=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where command=\"ProcessQueue\" and pid=0 and done=0 limit ${ce}; select row_count();")
cemax=$((cemax + ce))
cemax=$(( cemax + ce ))
printf "\rProcessQueue\t\t%s\r" "${cemax}"
done
printf "\rProcessQueue\t\t%s\n\r" "${cemax}"
#echo "ProcessQueue $cemax"