示例#1
0
def run_flush_comparison_cache(opts, **kwargs):
    """
    Flush the comparison cache.
    """
    from newslynx.models import ComparisonsCache

    ComparisonsCache.flush()
    log.info('Compaison cache flushed.')
示例#2
0
def run_flush_comparison_cache(opts, **kwargs):
    """
    Flush the comparison cache.
    """
    from newslynx.models import ComparisonsCache

    ComparisonsCache.flush()
    log.info('Compaison cache flushed.')
from newslynx.models import (
    ComparisonsCache, AllContentComparisonCache,
    SubjectTagsComparisonCache,
    ContentTypeComparisonCache,
    ImpactTagsComparisonCache)
from newslynx.views.util import (
    arg_bool, arg_str, validate_ts_unit, arg_list,
    arg_date, arg_int, delete_response
)

# blueprint
bp = Blueprint('content_metrics', __name__)

log = logging.getLogger(__name__)

comparisons_cache = ComparisonsCache()
comparison_types = {
    'all': AllContentComparisonCache(),
    'impact_tags': ImpactTagsComparisonCache(),
    'subject_tags': SubjectTagsComparisonCache(),
    'types': ContentTypeComparisonCache()
}


@bp.route('/api/v1/content/<content_item_id>/timeseries', methods=['GET'])
@load_user
@load_org
def get_content_timeseries(user, org, content_item_id):
    """
    Query an individual content timeseries.
    """
示例#4
0
文件: dev.py 项目: eads/newslynx-core
def run_flush_comparison_cache(opts, **kwargs):
    """
    Flush the comparison cache.
    """
    ComparisonsCache.flush()
    echo('Compaison cache flushed.', no_color=opts.no_color)
示例#5
0
from newslynx.models import (ComparisonsCache, AllContentComparisonCache,
                             SubjectTagsComparisonCache,
                             ContentTypeComparisonCache,
                             ImpactTagsComparisonCache, OrgMetricSummary,
                             ContentMetricSummary)

from newslynx.views.util import arg_bool

# blueprint
bp = Blueprint('comparisons', __name__)

log = logging.getLogger(__name__)

comparison_types = {
    'content': {
        'all': ComparisonsCache(),
        'impact_tags': ImpactTagsComparisonCache(),
        'subject_tags': SubjectTagsComparisonCache(),
        'types': ContentTypeComparisonCache()
    },
    'orgs': {}
}


def response_from_cache(cr):
    """
    Format a response from a cache object.
    """
    if arg_bool('cache_details', default=False):
        resp = jsonify({'cache': cr, 'comparisons': cr.value})
    else:
示例#6
0
def flush_comparison_cache():
    ComparisonsCache.flush()