def stats(request):
 context = {}
 context['title'] = _('Weblate statistics')
 totals = Profile.objects.aggregate(Sum('translated'), Sum('suggested'), Count('id'))
 total_strings = []
 total_words = []
 for project in SubProject.objects.iterator():
  try:
   translation_obj = project.translation_set.all()[0]
   total_strings.append(translation_obj.total)
   total_words.append(translation_obj.total_words)
  except IndexError:
   pass
 context['total_translations'] = totals['translated__sum']
 context['total_suggestions'] = totals['suggested__sum']
 context['total_users'] = totals['id__count']
 context['total_strings'] = sum(total_strings)
 context['total_units'] = Unit.objects.count()
 context['total_words'] = sum(total_words)
 context['total_languages'] = Language.objects.filter(translation__total__gt=0).distinct().count()
 context['total_checks'] = Check.objects.count()
 context['ignored_checks'] = Check.objects.filter(ignore=True).count()
 top_translations = Profile.objects.order_by('-translated')[:10]
 top_suggestions = Profile.objects.order_by('-suggested')[:10]
 context['top_translations'] = top_translations.select_related('user')
 context['top_suggestions'] = top_suggestions.select_related('user')
 return render(request, 'stats.html', context)

def stats ( request ) : context = { } context [ 'title' ] = _ ( 'Weblate statistics' ) totals = Profile . objects . aggregate ( Sum ( 'translated' ) , Sum ( 'suggested' ) , Count ( 'id' ) ) total_strings = [ ] total_words = [ ] for project in SubProject . objects . iterator ( ) : try : translation_obj = project . translation_set . all ( ) [ 0 ] total_strings . append ( translation_obj . total ) total_words . append ( translation_obj . total_words ) except IndexError : pass context [ 'total_translations' ] = totals [ 'translated__sum' ] context [ 'total_suggestions' ] = totals [ 'suggested__sum' ] context [ 'total_users' ] = totals [ 'id__count' ] context [ 'total_strings' ] = sum ( total_strings ) context [ 'total_units' ] = Unit . objects . count ( ) context [ 'total_words' ] = sum ( total_words ) context [ 'total_languages' ] = Language . objects . filter ( translation__total__gt = 0 ) . distinct ( ) . count ( ) context [ 'total_checks' ] = Check . objects . count ( ) context [ 'ignored_checks' ] = Check . objects . filter ( ignore = True ) . count ( ) top_translations = Profile . objects . order_by ( '-translated' ) [ : 10 ] top_suggestions = Profile . objects . order_by ( '-suggested' ) [ : 10 ] context [ 'top_translations' ] = top_translations . select_related ( 'user' ) context [ 'top_suggestions' ] = top_suggestions . select_related ( 'user' ) return render ( request , 'stats.html' , context )
returns a dictionary containing synchronization details of the ntp peers .