예제 #1
0
 def get_user_activity_collection():
     return eval("MongoDbUtils.db." + ConfigUtils.get("mongodb", "user_activity"))
예제 #2
0
 def get_comb_imp_collection():
     return eval("MongoDbUtils.db.") + ConfigUtils.get("mongodb", "comb_imp")
예제 #3
0
 def get_dict_collection():
     return eval("MongoDbUtils.db." + ConfigUtils.get("mongodb", "dict"))
예제 #4
0
 def get_od_imp_collection():
     return eval("MongoDbUtils.db." + ConfigUtils.get("mongodb", "od_imp"))
예제 #5
0
    def get_raw_info(time):
        pool = PooledDB(
            creator=MySQLdb,
            mincached=1,
            maxcached=20,
            host=ConfigUtils.get('mysql', 'host'),
            port=ConfigUtils.getint('mysql', 'port'),
            user=ConfigUtils.get('mysql', 'user'),
            passwd=ConfigUtils.get('mysql', 'passwd'),
            db=ConfigUtils.get('mysql', 'db'),
            cursorclass=Cursor,
            charset="utf8"
        )

        conn = pool.connection()
        cur = conn.cursor()
        sql = """
SELECT
    order_item_formal.id,
    order_item_formal.name AS name,
    IF(targeting_type=0, content_id, NULL) AS area,
    IF(targeting_type=1, content_id, NULL) AS platform,
    IF(targeting_type=24, content_id, NULL) AS channel,
    IF(targeting_type=27, content_id, NULL) AS album,
    step,
    step_num,
    frequency,
    words,
    deliver_type,
    roll_type,
    weight,
    order_item_formal.start_date,
    order_item_formal.end_date,
    IF(targeting_type=26, content_id, NULL) AS episode,
    cpm,
    ad_product_id,
    wave
FROM
    order_item_formal
LEFT OUTER JOIN
    targeting_unit_formal
ON
    order_item_formal.id = targeting_unit_formal.order_item_id
LEFT OUTER JOIN
    freq_formal
ON
    targeting_unit_formal.order_item_id = freq_formal.biz_id
LEFT OUTER JOIN
    keyword
ON
    keyword.type = 1 AND
    targeting_unit_formal.order_item_id = keyword.ref_id
LEFT OUTER JOIN
    creative_template
ON
    order_item_formal.creative_template_id = creative_template.id
LEFT OUTER JOIN
    priority
ON
    order_item_formal.priority_id = priority.id
LEFT OUTER JOIN
    schedule_day_formal
ON
    order_item_formal.id = schedule_day_formal.order_item_id AND
    schedule_day_formal.day = '%s'
WHERE
    order_item_formal.start_date <= '%s' AND
    order_item_formal.end_date >= '%s' AND
    order_item_formal.online_status = 1 AND
    order_item_formal.delete_flag = 0 AND
    (IF(targeting_type=0, content_id, NULL) IS NOT NULL OR
     IF(targeting_type=1, content_id, NULL) IS NOT NULL OR
     IF(targeting_type=24, content_id, NULL) IS NOT NULL OR
     IF(targeting_type=27, content_id, NULL) IS NOT NULL OR
     IF(targeting_type=26, content_id, NULL) IS NOT NULL)
GROUP BY
    order_item_formal.id,
    order_item_formal.name,
    IF(targeting_type=0, content_id, NULL),
    IF(targeting_type=1, content_id, NULL),
    IF(targeting_type=24, content_id, NULL),
    IF(targeting_type=27, content_id, NULL),
    step,
    step_num,
    frequency,
    IF(targeting_type=26, content_id, NULL)
""" % (time, time, time)

        cur.execute(sql)
        return cur.fetchall()