コード例 #1
0
    def get(self, count=10):
        try:
            rows = get_top_page_time(limit=count)
        except Exception as e:
            log.error(str(e))

            return {'status': 'ERROR'}, 500

        remote_address = request.environ.get('HTTP_X_REAL_IP',
                                             request.remote_addr)
        log.info("Request from {}".format(remote_address))
        output = ujson.loads(ujson.dumps(rows))

        return output, 200
コード例 #2
0
ファイル: market.py プロジェクト: leocelis/ada
    def get(self, report, count=10):
        rows = dict()

        # TODO: do this with more style
        try:
            if report == "emailopens":
                rows = get_top_opens(limit=count)

            if report == "openrate":
                rows = get_top_open_rate(limit=count)
        except Exception as e:
            log.error(str(e))

            return {'status': 'ERROR'}, 500

        remote_address = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
        log.info("Request from {}".format(remote_address))
        output = ujson.loads(ujson.dumps(rows))

        return output, 200
コード例 #3
0
ファイル: market.py プロジェクト: leocelis/ada
    def get(self, report):
        rows = dict()

        try:
            if report == "members_by_country":
                rows = get_members_by_country()

            if report == "open_rate_by_country":
                rows = get_open_rate_by_country()

        except Exception as e:
            log.error(str(e))

            return {'status': 'ERROR'}, 500

        remote_address = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
        log.info("Request from {}".format(remote_address))
        output = ujson.loads(ujson.dumps(rows))

        return output, 200
コード例 #4
0
ファイル: utils.py プロジェクト: leocelis/ada
def get_links_shares(threshold=1, limit=0):
    """
    Get all link shares
    """
    conn = get_mysql_conn()
    cursor = conn.cursor()

    sql = """
    SELECT idlinks_shares, link_url, link_title, shares_total, sentiment, sharing_score FROM links_shares 
    WHERE shares_total > {} ORDER BY shares_total DESC
    """.format(threshold)

    if limit > 0:
        sql += " LIMIT 0,{}".format(limit)

    log.info(sql)

    cursor.execute(sql)

    conn.commit()
    rows = dictfecth(cursor)
    cursor.close()

    return rows