Ejemplo n.º 1
0
def tagcloud(tags=None):
    filters = []
    filters_tags = []
    if tags is not None:
        query_list = [get_tag(x) for x in tags.split(SEPARATOR)]
        filters_tags = map(lambda x: ItemTag(pid=x.id, pname=x.name,
            pfilter=True), query_list)
        filters = map(lambda x: x.id, query_list)

    cloud = get_tagcloud(filters)
    tags_list = [ItemTag(t.id, t.name, count).json() for t, count in cloud]
    process_tag_count(tags_list, max_percent=30, min_percent=11)
    tags_list = {"tags": [x.json() for x in filters_tags] + tags_list}

    return jsonify(tags_list)
Ejemplo n.º 2
0
def tagcloud(tags=None):
    filters = []
    filters_tags = []
    if tags is not None:
        query_list = [get_tag(x) for x in tags.split(app.config['SEPARATOR'])]
        filters_tags = map(lambda x: ItemTag(pid=x.id, pname=x.name,
            pfilter=True), query_list)
        filters = map(lambda x: x.id, query_list)

    cloud = get_tagcloud(filters)
    tags_list = [ItemTag(t.id, t.name, count).json() for t, count in cloud]
    process_tag_count(tags_list, max_percent=30, min_percent=11)
    tags_list = {"tags": [x.json() for x in filters_tags] + tags_list}

    return jsonify(tags_list)
Ejemplo n.º 3
0
 def test_withTwoTags(self):
     """
     Same as withOneTag test but with two tags.
     """
     self.assertEqual(tagscloud.process_tag_count([{'count': 1}, {'count': 10}]), [{'count': 1, 'size': 75}, {'count': 10, 'size': 120}])
Ejemplo n.º 4
0
 def test_withOneTag(self):
     """
     Test if all tag are returned when it asked to be filtered by one tag.
     """
     self.assertEqual(tagscloud.process_tag_count([{'count': 1}]), [{'count': 1, 'size': 75}])