@classmethod<EOL><INDENT>@BatchController.memoise<EOL>def _filtered_clauses(cls, user):<DEDENT>
types = list(ConditionController._controllers())<EOL>discounttypes = [<EOL>i for i in types if issubclass(i, conditions.DiscountBase)<EOL>]<EOL>product_clauses = conditions.DiscountForProduct.objects.all()<EOL>product_clauses = product_clauses.select_related(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>)<EOL>category_clauses = conditions.DiscountForCategory.objects.all()<EOL>category_clauses = category_clauses.select_related(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>)<EOL>all_subsets = []<EOL>for discounttype in discounttypes:<EOL><INDENT>discounts = discounttype.objects.all()<EOL>ctrl = ConditionController.for_type(discounttype)<EOL>discounts = ctrl.pre_filter(discounts, user)<EOL>all_subsets.append(discounts)<EOL><DEDENT>filtered_discounts = list(itertools.chain(*all_subsets))<EOL>from_filter = dict((i.id, i) for i in filtered_discounts)<EOL>clause_sets = (<EOL>product_clauses.filter(discount__in=filtered_discounts),<EOL>category_clauses.filter(discount__in=filtered_discounts),<EOL>)<EOL>clause_sets = (<EOL>cls._annotate_with_past_uses(i, user) for i in clause_sets<EOL>)<EOL>discount_clauses = set(itertools.chain(*clause_sets))<EOL>for clause in discount_clauses:<EOL><INDENT>clause.discount = from_filter[clause.discount.id]<EOL><DEDENT>return discount_clauses<EOL>
Returns:
    Sequence[DiscountForProduct | DiscountForCategory]: All clauses
    that passed the filter function.