Skip to content

Commit

Permalink
if account alias is null returns account id (#3003)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fozzywozzybear authored Jul 8, 2021
1 parent 81062c4 commit ba317d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion koku/api/resource_types/aws_accounts/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
"""View for AWS accounts."""
from django.db.models import F
from django.db.models.functions import Coalesce
from django.utils.decorators import method_decorator
from django.views.decorators.vary import vary_on_headers
from rest_framework import filters
Expand All @@ -20,7 +21,12 @@ class AWSAccountView(generics.ListAPIView):

queryset = (
AWSCostSummaryByAccount.objects.annotate(
**{"value": F("usage_account_id"), "alias": F("account_alias__account_alias")}
**(
{
"value": F("usage_account_id"),
"alias": Coalesce(F("account_alias__account_alias"), "usage_account_id"),
}
)
)
.values("value", "alias")
.distinct()
Expand Down

0 comments on commit ba317d8

Please sign in to comment.