예제 #1
0
파일: bar.py 프로젝트: arthru/pystil
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)
예제 #2
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()]
    }
예제 #3
0
파일: line.py 프로젝트: arthru/pystil
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang):
    rq = (db.session.query(
        Visit.day.label("key"),
        count(distinct(Visit.uuid)).label("count") if criteria == 'unique' else
        count(1).label("count")).filter(on(site)).filter(
            between(from_date, to_date)))

    if criteria == 'new':
        rq = rq.filter(Visit.last_visit == None)

    results = rq.group_by(Visit.day).order_by(Visit.day).all()
    return make_time_serie(results, criteria, from_date, to_date, lang)
예제 #4
0
파일: line.py 프로젝트: arthru/pystil
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang):
    rq = (db.session
          .query(Visit.day.label("key"),
                 count(distinct(Visit.uuid)).label("count")
                 if criteria == 'unique' else count(1).label("count"))
          .filter(on(site))
          .filter(between(from_date, to_date)))

    if criteria == 'new':
        rq = rq.filter(Visit.last_visit == None)

    results = rq.group_by(Visit.day).order_by(Visit.day).all()
    return make_time_serie(results, criteria, from_date, to_date, lang)
예제 #5
0
파일: map.py 프로젝트: arthru/pystil
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])}
예제 #6
0
파일: top.py 프로젝트: arthru/pystil
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()]}
예제 #7
0
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')
예제 #8
0
파일: pie.py 프로젝트: arthru/pystil
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')
예제 #9
0
파일: map.py 프로젝트: arthru/pystil
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])
    }
예제 #10
0
파일: bar.py 프로젝트: arthru/pystil
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)