'Returns community tags for an item.'

def get_community_tags(self, item=None, limit=None):

    item_class = item.__class__
    item_tag_assoc_class = self.get_tag_assoc_class(item_class)
    if (not item_tag_assoc_class):
        return []
    cols_to_select = [item_tag_assoc_class.table.c.tag_id, func.count('*')]
    from_obj = item_tag_assoc_class.table.join(item_class.table).join(galaxy.model.Tag.table)
    where_clause = (self.get_id_col_in_item_tag_assoc_table(item_class) == item.id)
    order_by = [func.count('*').desc()]
    group_by = item_tag_assoc_class.table.c.tag_id
    query = select(columns=cols_to_select, from_obj=from_obj, whereclause=where_clause, group_by=group_by, order_by=order_by, limit=limit)
    result_set = self.sa_session.execute(query)
    community_tags = []
    for row in result_set:
        tag_id = row[0]
        community_tags.append(self.get_tag_by_id(tag_id))
    return community_tags
