#NEWLINE# def compat_stats( request , app , ver , minimum , ratio , binary ) : #NEWLINE# #INDENT# ver_int = str ( vint ( ver ) ) #NEWLINE# prefix = ( 'works.%s.%s' % ( app , ver_int ) ) #NEWLINE# qs = AppCompat . search ( ) . filter ( ** { #NEWLINE# #INDENT# ( '%s.failure__gt' % prefix ) : minimum , #NEWLINE# ( '%s.failure_ratio__gt' % prefix ) : ratio , #NEWLINE# ( 'support.%s.max__gte' % app ) : 0 , #NEWLINE# #UNINDENT# } ) . order_by ( ( '-%s.failure_ratio' % prefix ) , ( '-%s.total' % prefix ) ) . values_dict ( ) #NEWLINE# if ( binary is not None ) : #NEWLINE# #INDENT# qs = qs . filter ( binary = binary ) #NEWLINE# #UNINDENT# addons = amo . utils . paginate ( request , qs ) #NEWLINE# for obj in addons . object_list : #NEWLINE# #INDENT# obj [ 'usage' ] = obj [ 'usage' ] [ ver ] #NEWLINE# obj [ 'max_version' ] = obj [ 'max_version' ] [ app ] #NEWLINE# obj [ 'works' ] = obj [ 'works' ] [ app ] . get ( ver_int , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# obj [ 'overrides' ] = CompatOverride . objects . filter ( addon__id = obj [ 'id' ] ) #NEWLINE# obj [ 'has_override' ] = obj [ 'overrides' ] . filter ( _compat_ranges__min_app_version = ( ver + 'a1' ) ) . exists ( ) #NEWLINE# #UNINDENT# return ( addons , CompatTotals . objects . get ( app = app ) . total )