aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-24 10:28:38 +0100
committerlain <lain@soykaf.club>2018-02-24 10:28:38 +0100
commitefd4d049331462c234de7364ee194f5a0559e70f (patch)
treeec19e550bfe40a8030450f982ffa923a5f463918 /lib
parent1331a39d3997cd93ae08b778a793ea0f2a3b8523 (diff)
downloadpleroma-efd4d049331462c234de7364ee194f5a0559e70f.tar.gz
Fix user upgrading code.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index a3bbae2a5..fcf3804d5 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -209,15 +209,18 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
# This could potentially take a long time, do it in the background
Task.start(fn ->
- q = from a in Activity,
- where: ^old_follower_address in a.recipients,
- update: [set: [recipients: fragment("array_replace(?,?,?)", a.recipients, ^old_follower_address, ^user.follower_address)]]
- Repo.update_all(q, [])
-
q = from u in User,
where: ^old_follower_address in u.following,
update: [set: [following: fragment("array_replace(?,?,?)", u.following, ^old_follower_address, ^user.follower_address)]]
Repo.update_all(q, [])
+
+ # Only do this for recent activties, don't go through the whole db.
+ since = (Repo.aggregate(Activity, :max, :id) || 0) - 100_000
+ q = from a in Activity,
+ where: ^old_follower_address in a.recipients,
+ where: a.id > ^since,
+ update: [set: [recipients: fragment("array_replace(?,?,?)", a.recipients, ^old_follower_address, ^user.follower_address)]]
+ Repo.update_all(q, [])
end)
{:ok, user}