From f2d874386b59b87f55efbda7f4dbe088e31b9a94 Mon Sep 17 00:00:00 2001 From: Quentin Machu Date: Wed, 18 Nov 2015 21:20:48 -0500 Subject: [PATCH] Fix security worker (ok last time before I give up on engineering) --- data/model/image.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/data/model/image.py b/data/model/image.py index b9954b593..f3291a242 100644 --- a/data/model/image.py +++ b/data/model/image.py @@ -476,14 +476,14 @@ def get_secscan_candidates(engine_version, batch_size): ImageStorage.uploading == False) .limit(batch_size*10)) - images = (Image - .select(Image, ImageStorage) - .join(ImageStorage) - .where(Image.id << candidates) - .order_by(db_random_func()) - .limit(batch_size)) - - rimages.extend(images) + if len(candidates) > 0: + images = (Image + .select(Image, ImageStorage) + .join(ImageStorage) + .where(Image.id << candidates) + .order_by(db_random_func()) + .limit(batch_size)) + rimages.extend(images) # Collect the images with analyzed parents. candidates = list(Image @@ -497,17 +497,17 @@ def get_secscan_candidates(engine_version, batch_size): ImageStorage.uploading == False) .limit(batch_size*10)) - images = (Image - .select(Image, ImageStorage, Parent, ParentImageStorage) - .join(Parent, on=(Image.parent == Parent.id)) - .join(ParentImageStorage, on=(ParentImageStorage.id == Parent.storage)) - .switch(Image) - .join(ImageStorage) - .where(Image.id << candidates) - .order_by(db_random_func()) - .limit(batch_size)) - - rimages.extend(images) + if len(candidates) > 0: + images = (Image + .select(Image, ImageStorage, Parent, ParentImageStorage) + .join(Parent, on=(Image.parent == Parent.id)) + .join(ParentImageStorage, on=(ParentImageStorage.id == Parent.storage)) + .switch(Image) + .join(ImageStorage) + .where(Image.id << candidates) + .order_by(db_random_func()) + .limit(batch_size)) + rimages.extend(images) # Shuffle the images, otherwise the images without parents will always be on the top random.shuffle(rimages)