Esempio n. 1
0
def topic_focal_set_list(topics_id):
    snapshots_id = request.args.get('snapshotId')
    include_story_counts = request.args.get('includeStoryCounts')
    focal_sets = topic_focal_sets_list(user_mediacloud_key(), topics_id, snapshots_id)
    if include_story_counts and (include_story_counts == u'1'):
        _add_story_counts_to_foci(topics_id, focal_sets)
    return jsonify(focal_sets)
Esempio n. 2
0
def topic_focal_set_list(topics_id):
    snapshots_id, timespans_id, foci_id, q = filters_from_args(request.args)
    include_story_counts = request.args.get('includeStoryCounts')
    focal_sets = apicache.topic_focal_sets_list(user_mediacloud_key(),
                                                topics_id, snapshots_id)
    # now mark the ones that are the magically added URL sharing platform ones
    for fs in focal_sets:
        fs['is_url_sharing'] = is_url_sharing_focal_set(fs)
    if include_story_counts and (include_story_counts == u'1'):
        _add_story_counts_to_foci(topics_id, focal_sets)
    return jsonify(focal_sets)
Esempio n. 3
0
def _snapshot_foci_count_job(job):
    snapshot = job['snapshot']
    # add in the number of focal sets
    focal_sets = apicache.topic_focal_sets_list(job['user_mc_key'],
                                                job['topics_id'],
                                                snapshot['snapshots_id'])
    foci_count = sum([len(fs['foci']) for fs in focal_sets])
    snapshot['foci_count'] = foci_count
    snapshot['foci_names'] = [{
        'focal_set_name': fs['name'],
        'foci_names': [f['name'] for f in fs['foci']]
    } for fs in focal_sets]
    return snapshot
Esempio n. 4
0
def topic_timespan_list(topics_id, snapshots_id):
    ignored_snapshots_id, _timespans_id, foci_id, _q = filters_from_args(
        request.args)
    timespans = apicache.cached_topic_timespan_list(topics_id, snapshots_id,
                                                    foci_id)
    # add the focal_set type to the timespan so we can use that in the client (ie. decide what to show or not
    # based on what type of focal_set this timespan is part of)
    focal_sets = apicache.topic_focal_sets_list(user_mediacloud_key(),
                                                topics_id, snapshots_id)
    for t in timespans:
        for fs in focal_sets:
            for f in fs['foci']:
                if f['foci_id'] == t['foci_id']:
                    t['focal_set'] = fs
                    t['focus'] = f
                    break
    return jsonify({'list': timespans})