fix: Correct counting of processed items

This commit is contained in:
Carlos Solís 2025-02-03 06:16:48 +00:00
parent 9f71fbd458
commit 7c78b5e6e4

View file

@ -8,7 +8,8 @@ do
echo "tmp_post_origin_deleted"
tmp_post_origin_deleted=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\`, \`uid\` FROM \`post-user\` WHERE \`gravity\` = 0 AND \`deleted\` AND \`edited\` < (CURDATE() - INTERVAL ${interval} DAY) LIMIT ${limit}");
tmp_post_origin_deleted_q="${#tmp_post_origin_deleted[@]}"
#tmp_post_origin_deleted_q="${#tmp_post_origin_deleted[@]}"
tmp_post_origin_deleted_q=$(echo "${tmp_post_origin_deleted}" | wc -l)
echo "${tmp_post_origin_deleted_q}"
if [[ "${tmp_post_origin_deleted_q}" -gt 0 ]]
then
@ -30,7 +31,7 @@ do
echo "tmp_post_user_deleted"
tmp_post_user_deleted=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\` FROM \`post-user\` WHERE \`gravity\` = 0 AND \`deleted\` AND \`edited\` < (CURDATE() - INTERVAL ${interval} DAY) LIMIT ${limit}");
tmp_post_user_deleted_q="${#tmp_post_user_deleted[@]}"
tmp_post_user_deleted_q=$(echo "${tmp_post_user_deleted}" | wc -l)
echo "${tmp_post_user_deleted_q}"
if [[ "${tmp_post_user_deleted_q}" -gt 0 ]]
then
@ -52,7 +53,7 @@ do
echo "tmp_post_uri_id_not_in_post_user"
tmp_post_uri_id_not_in_post_user=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\` FROM \`post\` WHERE \`uri-id\` NOT IN (SELECT \`uri-id\` FROM \`post-user\`) LIMIT ${limit}");
tmp_post_uri_id_not_in_post_user_q="${#tmp_post_uri_id_not_in_post_user[@]}"
tmp_post_uri_id_not_in_post_user_q=$(echo "${tmp_post_uri_id_not_in_post_user}" | wc -l)
echo "${tmp_post_uri_id_not_in_post_user_q}"
if [[ "${tmp_post_uri_id_not_in_post_user_q}" -gt 0 ]]
then
@ -74,7 +75,7 @@ do
echo "tmp_post_content_uri_id_not_in_post_user"
tmp_post_content_uri_id_not_in_post_user=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\` FROM \`post-content\` WHERE \`uri-id\` NOT IN (SELECT \`uri-id\` FROM \`post-user\`) LIMIT ${limit}");
tmp_post_content_uri_id_not_in_post_user_q="${#tmp_post_content_uri_id_not_in_post_user[@]}"
tmp_post_content_uri_id_not_in_post_user_q=$(echo "${tmp_post_content_uri_id_not_in_post_user}" | wc -l)
echo "${tmp_post_content_uri_id_not_in_post_user_q}"
if [[ "${tmp_post_content_uri_id_not_in_post_user_q}" -gt 0 ]]
then
@ -96,7 +97,7 @@ do
echo "tmp_post_thread_uri_id_not_in_post_user"
tmp_post_thread_uri_id_not_in_post_user=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\` FROM \`post-thread\` WHERE \`uri-id\` NOT IN (SELECT \`uri-id\` FROM \`post-user\`) LIMIT ${limit}");
tmp_post_thread_uri_id_not_in_post_user_q="${#tmp_post_thread_uri_id_not_in_post_user[@]}"
tmp_post_thread_uri_id_not_in_post_user_q=$(echo "${tmp_post_thread_uri_id_not_in_post_user}" | wc -l)
echo "${tmp_post_thread_uri_id_not_in_post_user_q}"
if [[ "${tmp_post_thread_uri_id_not_in_post_user_q}" -gt 0 ]]
then
@ -118,7 +119,7 @@ do
echo "tmp_post_user_uri_id_not_in_post"
tmp_post_user_uri_id_not_in_post=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`uri-id\` FROM \`post-user\` WHERE \`uri-id\` NOT IN (SELECT \`uri-id\` FROM \`post\`) LIMIT ${limit}");
tmp_post_user_uri_id_not_in_post_q="${#tmp_post_user_uri_id_not_in_post[@]}"
tmp_post_user_uri_id_not_in_post_q=$(echo "${tmp_post_user_uri_id_not_in_post}" | wc -l)
echo "${tmp_post_user_uri_id_not_in_post_q}"
if [[ "${tmp_post_user_uri_id_not_in_post_q}" -gt 0 ]]
then
@ -151,7 +152,7 @@ do
AND \`parent-uri-id\` = \`post-thread\`.\`uri-id\`) \
AND NOT \`uri-id\` IN (SELECT \`uri-id\` FROM \`post-content\` WHERE \`resource-id\` != 0 AND \`uri-id\` = \`post-thread\`.\`uri-id\`)) \
LIMIT ${limit}");
tmp_item_uri_not_in_valid_post_thread_q="${#tmp_item_uri_not_in_valid_post_thread[@]}"
tmp_item_uri_not_in_valid_post_thread_q=$(echo "${tmp_item_uri_not_in_valid_post_thread}" | wc -l)
echo "${tmp_item_uri_not_in_valid_post_thread_q}"
if [[ "${tmp_item_uri_not_in_valid_post_thread_q}" -gt 0 ]]
then
@ -176,7 +177,7 @@ do
AND \`received\` < (CURDATE() - INTERVAL ${interval} DAY) AND NOT \`uri-id\` IN ( SELECT \`parent-uri-id\` FROM \`post-user\` AS \`i\` WHERE \`i\`.\`uid\` != 0 \
AND \`i\`.\`parent-uri-id\` = \`post-user\`.\`uri-id\` ) AND NOT \`uri-id\` IN ( SELECT \`parent-uri-id\` FROM \`post-user\` AS \`i\` WHERE \`i\`.\`uid\` = 0 \
AND \`i\`.\`parent-uri-id\` = \`post-user\`.\`uri-id\` AND \`i\`.\`received\` > (CURDATE() - INTERVAL ${interval} DAY) ) ) LIMIT ${limit}");
tmp_item_uri_not_in_valid_post_user_q="${#tmp_item_uri_not_in_valid_post_user[@]}"
tmp_item_uri_not_in_valid_post_user_q=$(echo "${tmp_item_uri_not_in_valid_post_user}" | wc -l)
echo "${tmp_item_uri_not_in_valid_post_user_q}"
if [[ "${tmp_item_uri_not_in_valid_post_user_q}" -gt 0 ]]
then
@ -198,7 +199,7 @@ do
echo "tmp_attach_not_in_post_media"
tmp_attach_not_in_post_media=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`id\` FROM \`attach\` WHERE \`id\` NOT IN (SELECT \`attach-id\` FROM \`post-media\`) LIMIT ${limit}");
tmp_attach_not_in_post_media_q="${#tmp_attach_not_in_post_media[@]}"
tmp_attach_not_in_post_media_q=$(echo "${tmp_attach_not_in_post_media}" | wc -l)
echo "${tmp_attach_not_in_post_media_q}"
if [[ "${tmp_attach_not_in_post_media_q}" -gt 0 ]]
then
@ -239,7 +240,7 @@ 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\` )) \
LIMIT ${limit}");
tmp_item_uri_not_valid_q="${#tmp_item_uri_not_valid[@]}"
tmp_item_uri_not_valid_q=$(echo "${tmp_item_uri_not_valid}" | wc -l)
echo "${tmp_item_uri_not_valid_q}"
if [[ "${tmp_item_uri_not_valid_q}" -gt 0 ]]
then
@ -261,7 +262,7 @@ do
echo "tmp_item_uri_duplicate"
tmp_item_uri_duplicate=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`id\` FROM \`item-uri\` t1 INNER JOIN \`item-uri\` t2 WHERE t1.\`id\` < t2.\`id\` AND t1.\`uri\` = t2.\`uri\` LIMIT ${limit}")
tmp_item_uri_duplicate_q="${#tmp_item_uri_duplicate[@]}"
tmp_item_uri_duplicate_q=$(echo "${tmp_item_uri_duplicate}" | wc -l)
echo "${tmp_item_uri_duplicate_q}"
if [[ "${tmp_item_uri_duplicate_q}" -gt 0 ]]
then
@ -283,7 +284,7 @@ do
echo "tmp_post_media_duplicate"
tmp_post_media_duplicate=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`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}")
tmp_post_media_duplicate_q="${#tmp_post_media_duplicate[@]}"
tmp_post_media_duplicate_q=$(echo "${tmp_post_media_duplicate}" | wc -l)
echo "${tmp_post_media_duplicate_q}"
if [[ "${tmp_post_media_duplicate_q}" -gt 0 ]]
then
@ -305,7 +306,7 @@ do
echo "tmp_post_user_duplicate"
tmp_post_user_duplicate=$(sudo mariadb friendica -N -B -q -e \
"SELECT \`id\` FROM \`post-user\` v1 INNER JOIN \`post-media\` v2 WHERE v1.\`id\` = v2.\`id\` AND v1.\`uri-id\` = v2.\`uri-id\` LIMIT ${limit}")
tmp_post_user_duplicate_q="${#tmp_post_user_duplicate[@]}"
tmp_post_user_duplicate_q=$(echo "${tmp_post_user_duplicate}" | wc -l)
echo "${tmp_post_user_duplicate_q}"
if [[ "${tmp_post_user_duplicate_q}" -gt 0 ]]
then