def compat_stats(request, version, minimum, ratio, binary): # Get the list of add-ons for usage stats. # Show add-ons marked as incompatible with this current version having # greater than 10 incompatible reports and whose average exceeds 80%. version_int = str(vint(version)) prefix = 'works.%s' % version_int qs = (AppCompat.search().filter( **{ '%s.failure__gt' % prefix: minimum, '%s.failure_ratio__gt' % prefix: ratio, 'support.max__gte': 0 }).order_by('-%s.failure_ratio' % prefix, '-%s.total' % prefix).values_dict()) if binary is not None: qs = qs.filter(binary=binary) addons = amo.utils.paginate(request, qs) for obj in addons.object_list: obj['usage'] = obj['usage'] obj['max_version'] = obj['max_version'] obj['works'] = obj['works'].get(version_int, {}) # Get all overrides for this add-on. obj['overrides'] = CompatOverride.objects.filter(addon__id=obj['id']) # Determine if there is an override for this current app version. obj['has_override'] = obj['overrides'].filter( _compat_ranges__min_app_version=version + 'a1').exists() return addons, CompatTotals.objects.get().total
def compat_stats(request, app, ver, minimum, ratio, binary): # Get the list of add-ons for usage stats. # Show add-ons marked as incompatible with this current version having # greater than 10 incompatible reports and whose average exceeds 80%. ver_int = str(vint(ver)) prefix = 'works.%s.%s' % (app, ver_int) qs = (AppCompat.search() .filter(**{'%s.failure__gt' % prefix: minimum, '%s.failure_ratio__gt' % prefix: ratio, 'support.%s.max__gte' % app: 0}) .order_by('-%s.failure_ratio' % prefix, '-%s.total' % prefix) .values_dict()) if binary is not None: qs = qs.filter(binary=binary) addons = amo.utils.paginate(request, qs) for obj in addons.object_list: obj['usage'] = obj['usage'][app] obj['max_version'] = obj['max_version'][app] obj['works'] = obj['works'][app].get(ver_int, {}) # Get all overrides for this add-on. obj['overrides'] = CompatOverride.objects.filter(addon__id=obj['id']) # Determine if there is an override for this current app version. obj['has_override'] = obj['overrides'].filter( _compat_ranges__min_app_version=ver + 'a1').exists() return addons, CompatTotals.objects.get(app=app).total