def refresh_content_summary(user, org):
    """
    Refresh content summary metrics
    """
    since = arg_int('since', 24)
    rollup_metric.content_timeseries_to_summary(org, since)
    rollup_metric.event_tags_to_summary(org)
    return jsonify({'success': True})
示例#2
0
def main(n_users=2,
         n_event_recipes=10,
         n_content_item_recipes=10,
         n_subject_tags=10,
         n_impact_tags=10,
         n_events=500,
         n_content_item_timeseries_metrics=10000,
         n_org_timeseries_metrics=10000,
         n_content_items=50,
         verbose=True):

    # top level content_items
    admin = db_session.query(User).filter_by(
        email=settings.SUPER_USER_EMAIL).first()
    users = [gen_user() for _ in xrange(n_users)] + [admin]
    org = gen_org(users)
    impact_tags = gen_impact_tags(org, n_subject_tags)
    subject_tags = gen_subject_tags(org, n_impact_tags)
    authors = gen_authors(org)
    recipes, metrics = gen_built_in_recipes(org)

    # generate content_items + metrics
    if verbose:
        print "generating {} content items".format(n_content_items)
    content_items = []
    for i in xrange(n_content_items):
        content_item = gen_content_item(org, recipes, subject_tags, authors)
        content_items.append(content_item)

    if verbose:
        print "generating {} events".format(n_events)

    if verbose:
        print "generating {} content item timeseries metrics"\
            .format(n_content_item_timeseries_metrics)

    gen_content_metric_timeseries(org, content_items, metrics,
                                  n_content_item_timeseries_metrics)

    if verbose:
        print "generating {} org timeseries metrics"\
            .format(n_org_timeseries_metrics)

    gen_org_metric_timeseries(org, metrics, n_org_timeseries_metrics)

    if verbose:
        print "generating {} events"\
            .format(n_events)

    # generate events
    gen_events(org, recipes, impact_tags, content_items, n_events)
    db_session.commit()

    # rollup metrics
    if verbose:
        print "rolling up metrics"
    rollup_metric.content_timeseries_to_summary(org)
    rollup_metric.event_tags_to_summary(org)