Fix security worker (ok last time before I give up on engineering)

This commit is contained in:
Quentin Machu 2015-11-18 21:20:48 -05:00
parent e3c64afaf3
commit f2d874386b

View file

@ -476,14 +476,14 @@ def get_secscan_candidates(engine_version, batch_size):
ImageStorage.uploading == False) ImageStorage.uploading == False)
.limit(batch_size*10)) .limit(batch_size*10))
images = (Image if len(candidates) > 0:
.select(Image, ImageStorage) images = (Image
.join(ImageStorage) .select(Image, ImageStorage)
.where(Image.id << candidates) .join(ImageStorage)
.order_by(db_random_func()) .where(Image.id << candidates)
.limit(batch_size)) .order_by(db_random_func())
.limit(batch_size))
rimages.extend(images) rimages.extend(images)
# Collect the images with analyzed parents. # Collect the images with analyzed parents.
candidates = list(Image candidates = list(Image
@ -497,17 +497,17 @@ def get_secscan_candidates(engine_version, batch_size):
ImageStorage.uploading == False) ImageStorage.uploading == False)
.limit(batch_size*10)) .limit(batch_size*10))
images = (Image if len(candidates) > 0:
.select(Image, ImageStorage, Parent, ParentImageStorage) images = (Image
.join(Parent, on=(Image.parent == Parent.id)) .select(Image, ImageStorage, Parent, ParentImageStorage)
.join(ParentImageStorage, on=(ParentImageStorage.id == Parent.storage)) .join(Parent, on=(Image.parent == Parent.id))
.switch(Image) .join(ParentImageStorage, on=(ParentImageStorage.id == Parent.storage))
.join(ImageStorage) .switch(Image)
.where(Image.id << candidates) .join(ImageStorage)
.order_by(db_random_func()) .where(Image.id << candidates)
.limit(batch_size)) .order_by(db_random_func())
.limit(batch_size))
rimages.extend(images) rimages.extend(images)
# Shuffle the images, otherwise the images without parents will always be on the top # Shuffle the images, otherwise the images without parents will always be on the top
random.shuffle(rimages) random.shuffle(rimages)