# -*- coding: utf-8 -*-
import time
from my_config import set_config
from log import Log
from db_helper import RedisHelper
from datetime import datetime

config_, _ = set_config()
log_ = Log()
redis_helper = RedisHelper()



def main():
    date_write = ""
    while True:
        date_cur = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        if "2024-06-01" in date_cur:
            print("退出")
            break
        apptype_list = ["0", "4", "5", "21", "3", "6", "2", "13", "17", "18", "19", "22"]
        level_list = ["1", "2", "3", "4", "5"]
        for app in apptype_list:
            for level in level_list:
                key = "flow:pool:level:item:" + app + ":" + level
                result = redis_helper.get_data_from_set(key)
                if not result:
                    result = []
                size = len(result)
                log_str = "\t".join([date_cur, app, level, str(size)])
                log_.info(log_str)
        time.sleep(40)



        # for level in ["1", "2", "3", "4"]:
        #     key = "flow:pool:level:item:4:" + level
        #     result = redis_helper.get_data_from_set(key)
        #     if not result:
        #         result = []
        #     size = len(result)
        #     log_str = "\t".join([date_cur, "4", level, str(size)])
        #     # print(log_str)
        #     log_.info(log_str)
        # for level in ["1", "2", "3", "4"]:
        #     key = "flow:pool:level:item:0:" + level
        #     result = redis_helper.get_data_from_set(key)
        #     if not result:
        #         result = []
        #     size = len(result)
        #     log_str = "\t".join([date_cur, "0", level, str(size)])
        #     # print(log_str)
        #     log_.info(log_str)
        # for level in ["1", "2", "3", "4"]:
        #     key = "flow:pool:level:item:21:" + level
        #     result = redis_helper.get_data_from_set(key)
        #     if not result:
        #         result = []
        #     size = len(result)
        #     log_str = "\t".join([date_cur, "21", level, str(size)])
        #     # print(log_str)
        #     log_.info(log_str)

        # date_write = datetime.now().strftime("%Y-%m-%d %H:%M")


if __name__ == '__main__':
    main()




# cd /root/zhangbo/rov-offline
# nohup python alg_recsys_coldstart_offlinecheck.py > p2.log 2>&1 &