PERF: Split queries when cleaning uploads.

This reduces the number of scans that the db has to do in the query
to fetch orphan uploads. Futheremore, we were not batching our
records which bloats memory.
This commit is contained in:
Guo Xiang Tan
2016-07-01 15:22:30 +08:00
parent 4657d22eb0
commit bd07658a37
7 changed files with 111 additions and 31 deletions

View File

@@ -1,11 +1,11 @@
Fabricator(:upload) do
user
sha1 "e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98"
sha1 { sequence(:sha1) { |n| Digest::SHA1.hexdigest(n.to_s) } }
original_filename "logo.png"
filesize 1234
width 100
height 200
url "/uploads/default/1/1234567890123456.png"
url { sequence(:url) { |n| "/uploads/default/#{n}/1234567890123456.png" } }
end
Fabricator(:attachment, from: :upload) do

View File

@@ -0,0 +1,3 @@
Fabricator(:user_avatar) do
user
end