Example #1
0
def count_stats():
    # count the uses of sources or collection whenever the user clicks the search button
    sources = request.args['sources'].split(",") if 'sources' in request.args else None
    collections = request.args['collections'].split(",") if 'collections' in request.args else None
    for media_id in sources:
        analytics_db.increment_count(analytics_db.TYPE_MEDIA, media_id,
                                     analytics_db.ACTION_EXPLORER_QUERY, sources.count(media_id))
    for collection_id in collections:
        analytics_db.increment_count(analytics_db.TYPE_COLLECTION, collection_id,
                                     analytics_db.ACTION_EXPLORER_QUERY, collections.count(collection_id))
    return jsonify({'status': 'ok'})
Example #2
0
def api_media_source_details(media_id):
    health = _cached_media_source_health(user_mediacloud_key(), media_id)
    info = _media_source_details(media_id)
    info['health'] = health
    user_mc = user_admin_mediacloud_client()
    if user_has_auth_role(ROLE_MEDIA_EDIT):
        info['scrape_status'] = user_mc.feedsScrapeStatus(media_id)  # need to know if scrape is running
    else:
        info['scrape_status'] = None
    add_user_favorite_flag_to_sources([info])
    add_user_favorite_flag_to_collections(info['media_source_tags'])
    analytics_db.increment_count(analytics_db.TYPE_MEDIA, media_id, analytics_db.ACTION_SOURCE_MGR_VIEW)
    return jsonify(info)
Example #3
0
def api_collection_details(collection_id):
    add_in_sources = False
    if ('getSources' in request.args) and (request.args['getSources'] == 'true'):
        add_in_sources = True

    user_mc = user_mediacloud_client()
    info = user_mc.tag(collection_id)
    add_user_favorite_flag_to_collections([info])
    info['id'] = collection_id
    info['tag_set'] = _tag_set_info(user_mediacloud_key(), info['tag_sets_id'])
    if add_in_sources:
        media_in_collection = media_with_tag(user_mediacloud_key(), collection_id)
        info['sources'] = media_in_collection
    analytics_db.increment_count(analytics_db.TYPE_COLLECTION, collection_id, analytics_db.ACTION_SOURCE_MGR_VIEW)
    return jsonify({'results': info})
def api_collection_details(collection_id):
    add_in_sources = False
    if ('getSources' in request.args) and (request.args['getSources'] == 'true'):
        add_in_sources = True

    user_mc = user_mediacloud_client()
    info = user_mc.tag(collection_id)
    add_user_favorite_flag_to_collections([info])
    info['id'] = collection_id
    info['tag_set'] = _tag_set_info(user_mediacloud_key(), info['tag_sets_id'])
    if add_in_sources:
        media_in_collection = media_with_tag(user_mediacloud_key(), collection_id)
        info['sources'] = media_in_collection
    analytics_db.increment_count(analytics_db.TYPE_COLLECTION, collection_id, analytics_db.ACTION_SOURCE_MGR_VIEW)
    return jsonify({'results': info})
Example #5
0
def api_media_source_details(media_id):
    health = _cached_media_source_health(user_mediacloud_key(), media_id)
    info = _media_source_details(media_id)
    info['health'] = health
    user_mc = user_admin_mediacloud_client()
    if user_has_auth_role(ROLE_MEDIA_EDIT):
        info['scrape_status'] = user_mc.feedsScrapeStatus(
            media_id)  # need to know if scrape is running
    else:
        info['scrape_status'] = None
    add_user_favorite_flag_to_sources([info])
    add_user_favorite_flag_to_collections(info['media_source_tags'])
    analytics_db.increment_count(analytics_db.TYPE_MEDIA, media_id,
                                 analytics_db.ACTION_SOURCE_MGR_VIEW)
    return jsonify(info)
def count_stats():
    # count the uses of sources or collection whenever the user clicks the search button
    sources = request.args['sources'].split(
        ",") if 'sources' in request.args else None
    collections = request.args['collections'].split(
        ",") if 'collections' in request.args else None
    for media_id in sources:
        analytics_db.increment_count(analytics_db.TYPE_MEDIA, media_id,
                                     analytics_db.ACTION_EXPLORER_QUERY,
                                     sources.count(media_id))
    for collection_id in collections:
        analytics_db.increment_count(analytics_db.TYPE_COLLECTION,
                                     collection_id,
                                     analytics_db.ACTION_EXPLORER_QUERY,
                                     collections.count(collection_id))
    return jsonify({'status': 'ok'})