def _get_usage(self, model, counts=False, min_count=None, 
        extra_joins=None, extra_criteria=None, params=None):
        if min_count is not None: 
            counts = True
        
        model_table = qn(model._meta.db_table)
        model_pk = '%s.%s' % (model_table, qn(model._meta.pk.column))
        query = """
        SELECT DISTINCT %(tag)s.id, %(tag)s.name%(count_sql)s, %(tag)s.slug
        FROM
           %(tag)s
           INNER JOIN %(tagged_item)s
               ON %(tag)s.id = %(tagged_item)s.tag_id
           INNER JOIN %(model)s
               ON %(tagged_item)s.object_id = %(model_pk)s
           %%s
        WHERE %(tagged_item)s.content_type_id = %(content_type_id)s
           %%s 
        GROUP BY %(tag)s.id, %(tag)s.name, %(tag)s.slug
        %%s
        ORDER BY %(tag)s.name ASC""" % {
            'tag': qn(self.model._meta.db_table),
            'count_sql': counts and (', COUNT(%s)' % model_pk) or '',
            'tagged_item': qn(SuperTaggedItem._meta.db_table),
            'model': model_table,
            'model_pk': model_pk,
            'content_type_id': ContentType.objects.get_for_model(model).pk,
        }
        
        min_count_sql = ''
        if min_count is not None:
            min_count_sql = 'HAVING COUNT(%s) >= %%s' % model_pk
            params.append(min_count)
        
        cursor = connection.cursor()
        cursor.execute(query % (extra_joins, extra_criteria, min_count_sql), params)
        tags = []
        for row in cursor.fetchall():
            t = self.model(id=row[0], name=row[1], slug=row[3])
            if counts:
                t.count = row[2]
            tags.append(t)
        return tags
Perform the custom SQL query for ``usage_for_model`` and
dataset/ETHPy150Open callowayproject/django-supertagging/supertagging/models.py/SuperTagManager._get_usage