@frappe.whitelist()
def get_stats(stats, doctype, filters=[]):
 import json
 tags = json.loads(stats)
 if filters:
  filters = json.loads(filters)
 stats = {}
 columns = frappe.db.get_table_columns(doctype)
 for tag in tags:
  if (not (tag in columns)):
   continue
  tagcount = frappe.get_list(doctype, fields=[tag, u'count(*)'], filters=(filters + [(u"ifnull(`%s`,'')!=''" % tag)]), group_by=tag, as_list=True)
  if (tag == u'_user_tags'):
   stats[tag] = scrub_user_tags(tagcount)
   stats[tag].append([u'No Tags', frappe.get_list(doctype, fields=[tag, u'count(*)'], filters=(filters + [u"({0} = ',' or {0} is null)".format(tag)]), as_list=True)[0][1]])
  else:
   stats[tag] = tagcount
 return stats

@ frappe . whitelist ( ) def get_stats ( stats , doctype , filters = [ ] ) : import json tags = json . loads ( stats ) if filters : filters = json . loads ( filters ) stats = { } columns = frappe . db . get_table_columns ( doctype ) for tag in tags : if ( not ( tag in columns ) ) : continue tagcount = frappe . get_list ( doctype , fields = [ tag , u'count(*)' ] , filters = ( filters + [ ( u"ifnull(`%s`,'')!=''" % tag ) ] ) , group_by = tag , as_list = True ) if ( tag == u'_user_tags' ) : stats [ tag ] = scrub_user_tags ( tagcount ) stats [ tag ] . append ( [ u'No Tags' , frappe . get_list ( doctype , fields = [ tag , u'count(*)' ] , filters = ( filters + [ u"({0} = ',' or {0} is null)" . format ( tag ) ] ) , as_list = True ) [ 0 ] [ 1 ] ] ) else : stats [ tag ] = tagcount return stats
print the stack stats estate : none the name of the target estate .