def refresh_one_content_summary(user, org, content_item_id): """ Refresh content summary metrics """ since = arg_int('since', 24) # rollup timeseries => summary rollup_metric.content_summary(org, [content_item_id], since) # compute metrics compute_metric.content_summary(org, ids=[content_item_id]) return jsonify({'success': True})
def refresh_content_summary(user, org): """ Refresh content summary metrics """ # how many hours since last update should we refresh? since = arg_int('since', 24) # rollup timeseries => summary rollup_metric.content_summary(org, [], since) # compute metrics compute_metric.content_summary(org, []) # simple response return jsonify({'success': True})
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: log.info("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: log.info("generating {} events".format(n_events)) if verbose: log.info("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: log.info("generating {} org timeseries metrics" .format(n_org_timeseries_metrics)) gen_org_metric_timeseries( org, metrics, n_org_timeseries_metrics) if verbose: log.info("generating {} events" .format(n_events)) # generate events gen_events(org, recipes, impact_tags, content_items, n_events) db.session.commit() # generate content summaries gen_content_metric_summaries(org, content_items, metrics) # rollup metrics if verbose: log.info("rolling up metrics") rollup_metric.content_summary(org)