def metrics(request, locale_code=None):
 template = 'questions/metrics.html'
 product = request.GET.get('product')
 if product:
  product = get_object_or_404(Product, slug=product)
 form = StatsForm(request.GET)
 if form.is_valid():
  bucket_days = form.cleaned_data['bucket']
  start = form.cleaned_data['start']
  end = form.cleaned_data['end']
 else:
  bucket_days = 1
  start = (date.today() - timedelta(days=30))
  end = date.today()
 graph_data = stats_topic_data(bucket_days, start, end, locale_code, product)
 for group in graph_data:
  for (name, count) in group.items():
   if (count == 0):
    del group[name]
 data = {'graph': graph_data, 'form': form, 'current_locale': locale_code, 'product': product, 'products': Product.objects.filter(visible=True)}
 return render(request, template, data)

def metrics ( request , locale_code = None ) : template = 'questions/metrics.html' product = request . GET . get ( 'product' ) if product : product = get_object_or_404 ( Product , slug = product ) form = StatsForm ( request . GET ) if form . is_valid ( ) : bucket_days = form . cleaned_data [ 'bucket' ] start = form . cleaned_data [ 'start' ] end = form . cleaned_data [ 'end' ] else : bucket_days = 1 start = ( date . today ( ) - timedelta ( days = 30 ) ) end = date . today ( ) graph_data = stats_topic_data ( bucket_days , start , end , locale_code , product ) for group in graph_data : for ( name , count ) in group . items ( ) : if ( count == 0 ) : del group [ name ] data = { 'graph' : graph_data , 'form' : form , 'current_locale' : locale_code , 'product' : product , 'products' : Product . objects . filter ( visible = True ) } return render ( request , template , data )
the support forum metrics dashboard .