From 41e897f4945aaf8fbcdf0b12ac2f08c5e6ae0458 Mon Sep 17 00:00:00 2001 From: doc Date: Mon, 30 Jun 2025 20:11:52 +0000 Subject: commit of legacy code --- fix_queue3.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 fix_queue3.sh (limited to 'fix_queue3.sh') diff --git a/fix_queue3.sh b/fix_queue3.sh new file mode 100755 index 0000000..c28d42a --- /dev/null +++ b/fix_queue3.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# ===== CONFIG ===== +USERNAME="$1" +RAILS_ENV=production +cd /home/mastodon/live || exit 1 + +if [[ -z "$USERNAME" ]]; then + echo "❌ Usage: $0 " + exit 1 +fi + +# Set full path for bundle +BUNDLE_PATH="/home/mastodon/.rbenv/shims/bundle" + +echo "🔍 Looking up account ID for @$USERNAME..." +ACCOUNT_ID=$(sudo -u mastodon -E env RAILS_ENV=production $BUNDLE_PATH exec rails runner " +acct = Account.find_by(username: '$USERNAME') +puts acct&.id || 'not_found' +") + +if [[ "$ACCOUNT_ID" == "not_found" ]]; then + echo "❌ Account @$USERNAME not found." + exit 1 +fi + +echo "🗑️ Deleting Redis cache for home timeline..." +sudo -u mastodon -E env RAILS_ENV=production redis-cli DEL feed:home:$ACCOUNT_ID + +echo "🧱 Rebuilding timeline from followed accounts..." +sudo -u mastodon -E env RAILS_ENV=production $BUNDLE_PATH exec rails runner " +acct = Account.find_by(username: '$USERNAME') +if acct + FeedInsertWorker.push_bulk(acct.following.pluck(:id)) do |follower_id| + [follower_id, acct.id] + end + puts '✅ Timeline repopulation enqueued.' +end +" + +echo "✅ Done. Home timeline for @$USERNAME reset and rebuilt." -- cgit v1.2.3