Skip to content

Commit

Permalink
Remove duplicate data from views screen (apache#5074)
Browse files Browse the repository at this point in the history
  • Loading branch information
rshermanTHG authored and merlimat committed Aug 30, 2019
1 parent bc76613 commit 73b8669
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions dashboard/django/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,20 @@ class HomeView(generic.ListView):
def home(request):
ts = get_timestamp()
properties = Property.objects.filter(
).annotate(
numNamespaces = Subquery(
Namespace.objects.filter(
deleted=False,
timestamp=ts,
property=OuterRef('pk')
).values('property')
.annotate(cnt=Count('pk'))
.values('cnt'),
output_field=IntegerField()
),
numTopics = Count('namespace__topic__name', distinct=True),
numProducers = Sum('namespace__topic__producerCount'),
numSubscriptions = Sum('namespace__topic__subscriptionCount'),
numConsumers = Sum('namespace__topic__consumerCount'),
backlog = Sum('namespace__topic__backlog'),
storage = Sum('namespace__topic__storageSize'),
rateIn = Sum('namespace__topic__msgRateIn'),
rateOut = Sum('namespace__topic__msgRateOut'),
throughputIn = Sum('namespace__topic__msgThroughputIn'),
throughputOut = Sum('namespace__topic__msgThroughputOut'),
)
namespace__topic__timestamp = ts,
).annotate(
numNamespaces = Count('namespace__name', distinct=True),
numTopics = Count('namespace__topic__name', distinct=True),
numProducers = Sum('namespace__topic__producerCount', filter=Q(topic__timestamp__eq=ts)),
numSubscriptions = Sum('namespace__topic__subscriptionCount'),
numConsumers = Sum('namespace__topic__consumerCount'),
backlog = Sum('namespace__topic__backlog'),
storage = Sum('namespace__topic__storageSize'),
rateIn = Sum('namespace__topic__msgRateIn'),
rateOut = Sum('namespace__topic__msgRateOut'),
throughputIn = Sum('namespace__topic__msgThroughputIn'),
throughputOut = Sum('namespace__topic__msgThroughputOut'),
)

logger.info(properties.query)

Expand Down

0 comments on commit 73b8669

Please sign in to comment.