def topics_for(product, parent=False):
 statsd.incr('wiki.facets.topics_for.db')
 docs = Document.objects.filter(locale=settings.WIKI_DEFAULT_LANGUAGE, is_archived=False, current_revision__isnull=False, products=product, category__in=settings.IA_DEFAULT_CATEGORIES)
 qs = Topic.objects.filter(product=product)
 qs = qs.filter(visible=True, document__in=docs).annotate(num_docs=Count('document')).distinct()
 if (parent or (parent is None)):
  qs = qs.filter(parent=parent)
 return qs

def topics_for ( product , parent = False ) : statsd . incr ( 'wiki.facets.topics_for.db' ) docs = Document . objects . filter ( locale = settings . WIKI_DEFAULT_LANGUAGE , is_archived = False , current_revision__isnull = False , products = product , category__in = settings . IA_DEFAULT_CATEGORIES ) qs = Topic . objects . filter ( product = product ) qs = qs . filter ( visible = True , document__in = docs ) . annotate ( num_docs = Count ( 'document' ) ) . distinct ( ) if ( parent or ( parent is None ) ) : qs = qs . filter ( parent = parent ) return qs
returns a list of topics that apply to passed in product .