Ejemplo n.º 1
0
def get_global_feed():
    person_id = request.args.get(VKID_NAME)
    # TODO: add search by lat & lon
    sql = """
SELECT p.`post_id`, p.`author_id`, p.`text`, p.`pic_url`, p.`date`, p.`latitude`, p.`longitude`, p.`likes`, p.`comments` FROM `post` p
JOIN `personsubscriptions` ps ON p.`author_id` = ps.`owner_id`
WHERE ps.`follower_id` = %s AND p.`is_deleted` IS NOT TRUE
"""
    query = database.execute_sql(sql, person_id)
    res = prepare_feed_from_query_result(query)
    return json.dumps(res)
Ejemplo n.º 2
0
def get_global_feed():
    person_id = request.args.get(VKID_NAME)
    # TODO: add search by lat & lon
    sql = """
SELECT p.`post_id`, p.`author_id`, p.`text`, p.`pic_url`, p.`date`, p.`latitude`, p.`longitude`, p.`likes`, p.`comments` FROM `post` p
JOIN `personsubscriptions` ps ON p.`author_id` = ps.`owner_id`
WHERE ps.`follower_id` = %s AND p.`is_deleted` IS NOT TRUE
"""
    query = database.execute_sql(sql, person_id)
    res = prepare_feed_from_query_result(query)
    return json.dumps(res)
Ejemplo n.º 3
0
def get_map():
    longitude = request.args.get("longitude", None)
    latitude = request.args.get("latitude", None)
    distance = request.args.get("distance", None)
    if longitude and latitude and distance:
        # sql = "CALL geodist({0}, {1}, {2});".format(longitude, latitude, distance)  # F**k this
        sql = """
SELECT p.`post_id`, p.`author_id`, p.`text`, p.`pic_url`, p.`date`, p.`latitude`, p.`longitude`, p.`likes`, p.`comments` FROM `post` p
WHERE p.`date` BETWEEN DATE_SUB(NOW(), INTERVAL 1 DAY) AND NOW() ORDER BY p.`date` DESC LIMIT 7
"""
        query = database.execute_sql(sql)
        res = prepare_feed_from_query_result(query)
        return json.dumps(res)
    else:
        return json.dumps({"message": "Parameters 'latitude', 'longitude' and 'distance' are required"})
Ejemplo n.º 4
0
def get_map():
    longitude = request.args.get("longitude", None)
    latitude = request.args.get("latitude", None)
    distance = request.args.get("distance", None)
    if longitude and latitude and distance:
        # sql = "CALL geodist({0}, {1}, {2});".format(longitude, latitude, distance)  # F**k this
        sql = """
SELECT p.`post_id`, p.`author_id`, p.`text`, p.`pic_url`, p.`date`, p.`latitude`, p.`longitude`, p.`likes`, p.`comments` FROM `post` p
WHERE p.`date` BETWEEN DATE_SUB(NOW(), INTERVAL 1 DAY) AND NOW() ORDER BY p.`date` DESC LIMIT 7
"""
        query = database.execute_sql(sql)
        res = prepare_feed_from_query_result(query)
        return json.dumps(res)
    else:
        return json.dumps({
            "message":
            "Parameters 'latitude', 'longitude' and 'distance' are required"
        })