예제 #1
0
def retrieve_transactions():
    sql = """
        SELECT *
         FROM  Collector_log
         WHERE event = 'buy'
         ORDER BY session_id, content_id
    """
    cursor = data_helper.get_query_cursor(sql)
    data = data_helper.dictfetchall(cursor)

    return data
예제 #2
0
def chart(request, take=10):
    sql = """SELECT content_id,
                mov.title,
                count(*) as sold
            FROM    collector_log log
            JOIN    moviegeeks_movie mov
            ON      log.content_id = mov.movie_id
            WHERE 	event like 'buy'
            GROUP BY content_id, mov.title
            ORDER BY sold desc
            LIMIT {}
            """.format(take)

    c = data_helper.get_query_cursor(sql)
    data = data_helper.dictfetchall(c)

    return JsonResponse(data, safe=False)