fix: Show cleanup phase more clearly, tweak default intervals and limits
This commit is contained in:
parent
7c78b5e6e4
commit
5f30741e58
1 changed files with 19 additions and 17 deletions
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
interval=14
|
||||
limit=100
|
||||
interval=7
|
||||
limit=100000
|
||||
|
||||
echo "tmp_post_origin_deleted"
|
||||
tmp_post_origin_deleted_q="${limit}"
|
||||
until [[ "${tmp_post_origin_deleted_q}" -lt "${limit}" ]]
|
||||
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[@]}"
|
||||
|
@ -25,10 +25,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_user_deleted"
|
||||
tmp_post_user_deleted_q="${limit}"
|
||||
until [[ "${tmp_post_user_deleted_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_user_deleted}" | wc -l)
|
||||
|
@ -47,10 +47,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_uri_id_not_in_post_user"
|
||||
tmp_post_uri_id_not_in_post_user_q="${limit}"
|
||||
until [[ "${tmp_post_uri_id_not_in_post_user_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_uri_id_not_in_post_user}" | wc -l)
|
||||
|
@ -69,10 +69,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_content_uri_id_not_in_post_user"
|
||||
tmp_post_content_uri_id_not_in_post_user_q="${limit}"
|
||||
until [[ "${tmp_post_content_uri_id_not_in_post_user_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_content_uri_id_not_in_post_user}" | wc -l)
|
||||
|
@ -91,10 +91,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_thread_uri_id_not_in_post_user"
|
||||
tmp_post_thread_uri_id_not_in_post_user_q="${limit}"
|
||||
until [[ "${tmp_post_thread_uri_id_not_in_post_user_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_thread_uri_id_not_in_post_user}" | wc -l)
|
||||
|
@ -113,10 +113,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_user_uri_id_not_in_post"
|
||||
tmp_post_user_uri_id_not_in_post_q="${limit}"
|
||||
until [[ "${tmp_post_user_uri_id_not_in_post_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_user_uri_id_not_in_post}" | wc -l)
|
||||
|
@ -135,10 +135,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_item_uri_not_in_valid_post_thread"
|
||||
tmp_item_uri_not_in_valid_post_thread_q="${limit}"
|
||||
until [[ "${tmp_item_uri_not_in_valid_post_thread_q}" -lt "${limit}" ]]
|
||||
do
|
||||
echo "tmp_item_uri_not_in_valid_post_thread"
|
||||
tmp_item_uri_not_in_valid_post_thread=$(sudo mariadb friendica -N -B -q -e \
|
||||
"SELECT \`id\` FROM \`item-uri\` WHERE \`id\` IN (SELECT \`uri-id\` FROM \`post-thread\` WHERE \`received\` < (CURDATE() - INTERVAL ${interval} DAY) \
|
||||
AND NOT \`uri-id\` IN (SELECT \`uri-id\` FROM \`post-thread-user\` WHERE (\`mention\` OR \`starred\` OR \`wall\`) \
|
||||
|
@ -168,10 +168,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_item_uri_not_in_valid_post_user"
|
||||
tmp_item_uri_not_in_valid_post_user_q="${limit}"
|
||||
until [[ "${tmp_item_uri_not_in_valid_post_user_q}" -lt "${limit}" ]]
|
||||
do
|
||||
echo "tmp_item_uri_not_in_valid_post_user"
|
||||
tmp_item_uri_not_in_valid_post_user=$(sudo mariadb friendica -N -B -q -e \
|
||||
"SELECT \`id\` FROM \`item-uri\` WHERE \`id\` IN (SELECT \`uri-id\` FROM \`post-user\` WHERE \`gravity\` = 0 AND \`uid\` = 0 \
|
||||
AND \`received\` < (CURDATE() - INTERVAL ${interval} DAY) AND NOT \`uri-id\` IN ( SELECT \`parent-uri-id\` FROM \`post-user\` AS \`i\` WHERE \`i\`.\`uid\` != 0 \
|
||||
|
@ -193,10 +193,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_attach_not_in_post_media"
|
||||
tmp_attach_not_in_post_media_q="${limit}"
|
||||
until [[ "${tmp_attach_not_in_post_media_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_attach_not_in_post_media}" | wc -l)
|
||||
|
@ -215,12 +215,14 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_item_uri_not_valid"
|
||||
tmp_item_uri_not_valid_q="${limit}"
|
||||
until [[ "${tmp_item_uri_not_valid_q}" -lt "${limit}" ]]
|
||||
do
|
||||
echo "tmp_item_uri_not_valid"
|
||||
tmp_item_uri_not_valid_last_id=$(sudo mariadb friendica -N -B -q -e \
|
||||
"SELECT \`uri-id\` FROM \`post\` WHERE \`received\` < CURDATE() - INTERVAL 1 DAY ORDER BY \`received\` DESC LIMIT 1")
|
||||
tmp_item_uri_not_valid=$(sudo mariadb friendica -N -B -q -e \
|
||||
"SELECT \`id\` FROM \`item-uri\` WHERE ( \`id\` < ( SELECT \`uri-id\` FROM \`post\` WHERE \`received\` < CURDATE() - INTERVAL 1 DAY ORDER BY \`received\` DESC LIMIT 1 ) \
|
||||
"SELECT \`id\` FROM \`item-uri\` WHERE ( \`id\` < ${tmp_item_uri_not_valid_last_id} ) \
|
||||
AND NOT EXISTS ( SELECT \`uri-id\` FROM \`post-user\` WHERE \`uri-id\` = \`item-uri\`.\`id\` ) \
|
||||
AND NOT EXISTS ( SELECT \`parent-uri-id\` FROM \`post-user\` WHERE \`parent-uri-id\` = \`item-uri\`.\`id\` ) \
|
||||
AND NOT EXISTS ( SELECT \`thr-parent-id\` FROM \`post-user\` WHERE \`thr-parent-id\` = \`item-uri\`.\`id\` ) \
|
||||
|
@ -249,17 +251,17 @@ do
|
|||
if [[ -n "${id}" ]]
|
||||
then
|
||||
sudo mariadb friendica -N -B -q -e \
|
||||
"DELETE FROM \`item_uri\` WHERE \`id\` = ${id}"
|
||||
"DELETE FROM \`item-uri\` WHERE \`id\` = ${id}"
|
||||
echo "${id}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo "tmp_item_uri_duplicate"
|
||||
tmp_item_uri_duplicate_q="${limit}"
|
||||
until [[ "${tmp_item_uri_duplicate_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_item_uri_duplicate}" | wc -l)
|
||||
|
@ -278,10 +280,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_media_duplicate"
|
||||
tmp_post_media_duplicate_q="${limit}"
|
||||
until [[ "${tmp_post_media_duplicate_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_media_duplicate}" | wc -l)
|
||||
|
@ -300,10 +302,10 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "tmp_post_user_duplicate"
|
||||
tmp_post_user_duplicate_q="${limit}"
|
||||
until [[ "${tmp_post_user_duplicate_q}" -lt "${limit}" ]]
|
||||
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=$(echo "${tmp_post_user_duplicate}" | wc -l)
|
||||
|
|
Loading…
Add table
Reference in a new issue