def get_content_timeseries(user, org, content_item_id): """ Query an individual content timeseries. """ c = ContentItem.query\ .filter_by(id=content_item_id)\ .filter_by(org_id=org.id)\ .first() if not c: raise NotFoundError( 'A ContentItem with ID {} does not exist' .format(content_item_id)) # select / exclude select, exclude = arg_list('select', typ=str, exclusions=True, default=['*']) if '*' in select: exclude = [] select = "*" kw = dict( unit=arg_str('unit', default='hour'), sparse=arg_bool('sparse', default=True), sig_digits=arg_int('sig_digits', default=2), select=select, exclude=exclude, rm_nulls=arg_bool('rm_nulls', default=False), time_since_start=arg_bool('time_since_start', default=False), transform=arg_str('transform', default=None), before=arg_date('before', default=None), after=arg_date('after', default=None) ) q = QueryContentMetricTimeseries(org, [content_item_id], **kw) return jsonify(list(q.execute()))
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})
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 get_org_timeseries(user, org_id_slug): # fetch org org = fetch_by_id_or_field(Org, 'slug', org_id_slug) # if it still doesn't exist, raise an error. if not org: raise NotFoundError( 'This Org does not exist.') # ensure the active user can edit this Org if user.id not in org.user_ids: raise ForbiddenError( 'You are not allowed to access this Org') # todo: validate which metrics you can select. # select / exclude select, exclude = arg_list( 'select', typ=str, exclusions=True, default=['all']) if 'all' in select: exclude = [] select = "all" kw = dict( unit=arg_str('unit', default='hour'), sparse=arg_bool('sparse', default=True), sig_digits=arg_int('sig_digits', default=2), select=select, exclude=exclude, group_by_id=arg_bool('group_by_id', default=True), rm_nulls=arg_bool('rm_nulls', default=False), time_since_start=arg_bool('time_since_start', default=False), transform=arg_str('transform', default=None), before=arg_date('before', default=None), after=arg_date('after', default=None) ) q = QueryOrgMetricTimeseries(org, [org.id], **kw) return jsonify(list(q.execute()))
def refresh_org_timeseries(user, org_id_slug): """ Refresh content summary metrics """ # fetch org org = fetch_by_id_or_field(Org, "slug", org_id_slug) # if it still doesn't exist, raise an error. if not org: raise NotFoundError("This Org does not exist.") # ensure the active user can edit this Org if user.id not in org.user_ids: raise ForbiddenError("You are not allowed to access this Org") # how many hours since last update should we refresh? since = arg_int("since", 24) # rollup timeseries => summary rollup_metric.org_timeseries(org, [], since) # simple response return jsonify({"success": True})
def refresh_org_timeseries(user, org_id_slug): """ Refresh content summary metrics """ # fetch org org = fetch_by_id_or_field(Org, 'slug', org_id_slug) # if it still doesn't exist, raise an error. if not org: raise NotFoundError('This Org does not exist.') # ensure the active user can edit this Org if user.id not in org.user_ids: raise ForbiddenError('You are not allowed to access this Org') # how many hours since last update should we refresh? since = arg_int('since', 24) # rollup timeseries => summary rollup_metric.org_timeseries(org, [], since) # simple response return jsonify({'success': True})