Exemplo n.º 1
0
Arquivo: bar.py Projeto: 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)
Exemplo n.º 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()]
    }
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
Arquivo: map.py Projeto: 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])}
Exemplo n.º 6
0
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang):
    poll = get_poll(site)
    if stamp == None:
        visits = (Visit.query.filter(
            on(site)).filter(Visit.date > (datetime.utcfromtimestamp(
                stamp / 1000) if stamp else datetime.min)).order_by(
                    Visit.date.desc()).limit(10).all())

        visits.reverse()
        visits = [polish_visit(visit_to_dict(visit)) for visit in visits]
        stamp = len(poll.visits)
    else:
        visits, stamp = poll.get(stamp)

    return {'list': visits, 'stamp': stamp}
Exemplo n.º 7
0
Arquivo: top.py Projeto: 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()]}
Exemplo n.º 8
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')
Exemplo n.º 9
0
Arquivo: pie.py Projeto: 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')
Exemplo n.º 10
0
Arquivo: map.py Projeto: 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])
    }
Exemplo n.º 11
0
def process_data(site, graph, criteria, from_date, to_date, step, stamp, lang):
    poll = get_poll(site)
    if stamp == None:
        visits = (
            Visit.query.filter(on(site))
            .filter(Visit.date > (datetime.utcfromtimestamp(stamp / 1000) if stamp else datetime.min))
            .order_by(Visit.date.desc())
            .limit(10)
            .all()
        )

        visits.reverse()
        visits = [polish_visit(visit_to_dict(visit)) for visit in visits]
        stamp = len(poll.visits)
    else:
        visits, stamp = poll.get(stamp)

    return {"list": visits, "stamp": stamp}
Exemplo n.º 12
0
Arquivo: bar.py Projeto: 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)