Fix SQL query counting the number of individual consumers having allocations by only selecting the aggregated consumer_id column.

Story: 2006904
Task: 37546
Change-Id: Ie0bee79c1ee185c0f68fa170c668395d9058c56d
This commit is contained in:
Christian Rohmann 2021-07-20 09:11:37 +02:00
parent 8d4c1c20f3
commit 616208914a
1 changed files with 3 additions and 2 deletions

View File

@ -62,8 +62,9 @@ class Checks(upgradecheck.UpgradeCommands):
# Count the total number of consumers.
num_consumers = ctxt.session.query(models.Consumer).count()
# Count the total number of unique consumers in the allocations table.
num_alloc_consumers = ctxt.session.query(models.Allocation).group_by(
models.Allocation.consumer_id).count()
num_alloc_consumers = ctxt.session.query(
models.Allocation.consumer_id).group_by(
models.Allocation.consumer_id).count()
return num_alloc_consumers - num_consumers
def _check_incomplete_consumers(self):