+1
-1
app/import_worker.rb
+1
-1
app/import_worker.rb
···
37
37
loop do
38
38
@user_threads.delete_if { |t| !t.alive? }
39
39
40
-
if user = User.with_unfinished_imports.where.not(id: @user_threads.map(&:user_id)).first
40
+
if user = User.with_unfinished_import.where.not(id: @user_threads.map(&:user_id)).first
41
41
collections = user.imports.unfinished.map(&:collection)
42
42
thread = UserThread.new(user, collections, @verbose)
43
43
@user_threads << thread
+6
-2
app/models/user.rb
+6
-2
app/models/user.rb
···
62
62
self.joins(:imports).distinct
63
63
end
64
64
65
-
def self.with_unfinished_imports
66
-
self.joins(:imports).merge(Import.unfinished).distinct
65
+
def self.with_unfinished_import
66
+
self.where(id: Import.unfinished.select('user_id').distinct)
67
+
.or(self.where(id: Like.in_queue(:import).select('actor_id').distinct))
68
+
.or(self.where(id: Repost.in_queue(:import).select('actor_id').distinct))
69
+
.or(self.where(id: Quote.in_queue(:import).select('actor_id').distinct))
70
+
.or(self.where(id: Pin.in_queue(:import).select('actor_id').distinct))
67
71
end
68
72
69
73
def active?