import pymysql
import datetime


def get_esmm_users():
    db = pymysql.connect(host='172.16.40.158', port=4000, user='root',
                         passwd='3SYz54LS9#^9sBvC', db='jerry_prod')
    cursor = db.cursor()
    stat_date = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
    print(stat_date)
    sql = "select distinct device_id,city_id from data_feed_exposure_precise " \
          "where stat_date = '{}' limit 20".format(stat_date)
    cursor.execute(sql)
    result = list(cursor.fetchall())
    print(result[:2])
    return result


def get_user_profile(device_id):
    pass


def transform_to_tag(user_profile):
    pass


def get_queues(device_id,city_id):
    pass


def tag_boost(cid_list, tag_score):
    pass


def to_data_base(df,table_name = "tag_boost_device_diary_queue"):
    pass


def make_sample(uid,city_id,native_queue,nearby_queue,megacity_queue,nation_queue):
    pass


if __name__ == "__main__":
    # users_list = get_esmm_users()
    # total_samples = list()
    # for i in users_list:
    #     tag_score = get_user_profile(i[0])
    #     native,nearby,megacity,nation = get_queues(i[0],i[1])
    #
    #     native_sort_list = tag_boost(native, tag_score)
    #     nearby_sort_list = tag_boost(nearby, tag_score)
    #
    #     sample = make_sample(uid,city_id,native_queue,nearby_queue,megacity_queue,nation_queue)
    #     total_samples.append(sample)
    #
    # total_samples.todf
    # to_data_base(df)
    get_esmm_users()












