def sites(): """List of sites""" table, attr, countcol = get_attribute_and_count('domain') sites = (db.session.query( attr, countcol.label('count')).group_by(attr).order_by( desc(countcol)))[:20] all_ = db.session.query(countcol).scalar() return render_template('sites.jinja2', sites=sites, all_=all_)
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, key, count_col = get_attribute_and_count(criteria) rq = (db.session .query(key.label("key"), count_col.label("count")) .filter(on(site, table)) .filter(between(from_date, to_date, table)) .group_by(key)) return make_serie(rq.all(), criteria, lang)
def sites(): """List of sites""" table, attr, countcol = get_attribute_and_count('domain') sites = ( db.session .query(attr, countcol.label('count')) .group_by(attr) .order_by(desc(countcol)))[:20] all_ = db.session.query(countcol).scalar() return render_template('sites.jinja2', sites=sites, all_=all_)
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criterion, count_col = get_attribute_and_count(criteria) return { 'list': [{ 'key': key, 'count': count } for key, count in db.session.query(criterion.label( "key"), count_col.label("count")).filter(on(site, table)).filter( between(from_date, to_date, table=table)).group_by( criterion).order_by(desc(count_col)).limit(10).all()] }
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criteria, count_col = get_attribute_and_count('country_code') rq = (db.session .query(table.c.country, table.c.country_code, count(1).label("count")) .filter(on(site, table)) .filter(between(from_date, to_date, table)) .group_by(table.c.country_code, table.c.country)) visits = [{'country': visit.country, 'code': visit.country_code, 'count': visit.count} for visit in rq.all()] return {'list': visits, 'max': max( [visit['count'] for visit in visits] + [0])}
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criterion, count_col = get_attribute_and_count(criteria) return {'list': [{'key': key, 'count': count} for key, count in db.session .query(criterion.label("key"), count_col.label("count")) .filter(on(site, table)) .filter(between(from_date, to_date, table=table)) .group_by(criterion) .order_by(desc(count_col)) .limit(10) .all()]}
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criterion, count_col = get_attribute_and_count(criteria) restrict = (criterion != None) if criteria == 'browser_name_version': restrict = ((table.c.browser_name != None) & (table.c.browser_version != None)) rq = (db.session.query( criterion.label("key"), count_col.label("count")).filter( on(site, table)).filter(between( from_date, to_date, table=table)).filter(restrict).group_by(criterion).order_by( desc(count_col))) return transform_for_pie( rq.limit(10).all(), site, from_date, to_date, lang, criteria == 'pretty_referrer')
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criterion, count_col = get_attribute_and_count(criteria) restrict = (criterion != None) if criteria == 'browser_name_version': restrict = ((table.c.browser_name != None) & (table.c.browser_version != None)) rq = (db.session .query(criterion.label("key"), count_col.label("count")) .filter(on(site, table)) .filter(between(from_date, to_date, table=table)) .filter(restrict) .group_by(criterion) .order_by(desc(count_col))) return transform_for_pie(rq.limit(10).all(), site, from_date, to_date, lang, criteria == 'pretty_referrer')
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, criteria, count_col = get_attribute_and_count('country_code') rq = (db.session.query( table.c.country, table.c.country_code, count(1).label("count")).filter(on(site, table)).filter( between(from_date, to_date, table)).group_by(table.c.country_code, table.c.country)) visits = [{ 'country': visit.country, 'code': visit.country_code, 'count': visit.count } for visit in rq.all()] return { 'list': visits, 'max': max([visit['count'] for visit in visits] + [0]) }
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang): table, key, count_col = get_attribute_and_count(criteria) rq = (db.session.query(key.label("key"), count_col.label("count")).filter( on(site, table)).filter(between(from_date, to_date, table)).group_by(key)) return make_serie(rq.all(), criteria, lang)