From 003aa065834ff583cb26e4bfd1afdbe09b34d3de Mon Sep 17 00:00:00 2001 From: Alex Szarka Date: Wed, 24 Aug 2016 14:57:42 +0200 Subject: [PATCH] Reduce code complexity - api.py Reduce the code complexity in nova/db/sqlalchemy/apy.py file. The 351176 patch depends by this. Change-Id: I39adb817b5e03b39a17df6f64152ce23ef3c9ed6 --- nova/db/sqlalchemy/api.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 05a2f29f87f1..c2dd09c2f218 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2153,10 +2153,8 @@ def instance_get_all_by_filters_sort(context, filters, limit=None, marker=None, query_prefix = query_prefix.filter(not_soft_deleted) if 'cleaned' in filters: - if filters.pop('cleaned'): - query_prefix = query_prefix.filter(models.Instance.cleaned == 1) - else: - query_prefix = query_prefix.filter(models.Instance.cleaned == 0) + cleaned = 1 if filters.pop('cleaned') else 0 + query_prefix = query_prefix.filter(models.Instance.cleaned == cleaned) if 'tags' in filters: tags = filters.pop('tags')