Merge pull request #3368 from quay/security-scan-set-opt

Change the security scan update query to only change the indexed row
This commit is contained in:
Joseph Schorr 2019-02-18 11:59:45 -05:00 committed by GitHub
commit 2cebf828a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -460,19 +460,9 @@ def get_image_with_storage_and_parent_base():
def set_secscan_status(image, indexed, version): def set_secscan_status(image, indexed, version):
query = (Image
.select()
.join(ImageStorage)
.where(Image.docker_image_id == image.docker_image_id,
ImageStorage.uuid == image.storage.uuid))
ids_to_update = [row.id for row in query]
if not ids_to_update:
return False
return (Image return (Image
.update(security_indexed=indexed, security_indexed_engine=version) .update(security_indexed=indexed, security_indexed_engine=version)
.where(Image.id << ids_to_update) .where(Image.id == image.id)
.where((Image.security_indexed_engine != version) | (Image.security_indexed != indexed)) .where((Image.security_indexed_engine != version) | (Image.security_indexed != indexed))
.execute()) != 0 .execute()) != 0