from my_utils import RedisHelper
from my_config import set_config
from log import Log
import sys
sys.path.append("zhangbo/")
sys.path.append("/")
config_, _ = set_config()
log_ = Log()
redis_helper = RedisHelper()


if __name__ == '__main__':

    key = "RISK_SHIELD_FILTER_RULE_V1_JSON"
    value = "{\"0\": [\"110000\"]}"
    redis_helper.set_data_to_redis(key, value, 7200)
    value_get = redis_helper.get_data_from_redis(key_name=key)
    print('key:', key, type(key))
    print('value_get:', value_get, type(value_get))

    # key = "RISK_SHIELD_FILTER_VIDEO_V1_STR"
    # value = "7536230,1,2,3,4,5,6,7,8,9,10"
    # redis_helper.set_data_to_redis(key, value, 7200)
    # value_get = redis_helper.get_data_from_redis(key_name=key)
    # print('key:', key, type(key))
    # print('value_get:', value_get, type(value_get))


    key = "RISK_SHIELD_FILTER_EXPANSION_FACTOR_INT"
    value = "15"
    redis_helper.set_data_to_redis(key, value, 7200)
    value_get = redis_helper.get_data_from_redis(key_name=key)
    print('key:', key, type(key))
    print('value_get:', value_get, type(value_get))


    key = "RISK_SHIELD_FILTER_FLAG_BOOL"
    value = "True"
    redis_helper.set_data_to_redis(key, value, 7200)
    value_get = redis_helper.get_data_from_redis(key_name=key)
    print('key:', key, type(key))
    print('value_get:', value_get, type(value_get))

    # redis_helper.del_keys(key_name=key)

    # python zhangbo/redis_test.py


    # dt = '20231203'
    # data_key = 'test_lr_v1'
    # key_name = f"{config_.KEY_NAME_PREFIX_AD_GROUP}{data_key}:{dt}"
    # redis_data = {
    #     'yxh': 0.3,
    #     'zb': 0.13213231231,
    # }
    # redis_data = {
    #     'mz': 0.2,
    #     'zb': 0.6666,
    # }
    # print(key_name)
    # #redis_helper.add_data_with_zset(key_name=key_name, data=redis_data, expire_time=2 * 24 * 3600)
    #
    # print(redis_helper.get_score_with_value(key_name=key_name, value='zb'))
    # print(redis_helper.get_score_with_value(key_name=key_name, value='mz'))
    # print(redis_helper.get_score_with_value(key_name='ad:users:group:predict:share:rate:test_lr_v1:20231129', value='16537775'))
    #
    # model_key = 'ad_out_v1'
    # KEY_NAME_PREFIX_AD_OUT_MODEL_CONFIG = 'ad:out:model:config:'
    # abtest_id = '173'
    # abtest_config_tag = 'u'
    # config_key_prefix = f"{KEY_NAME_PREFIX_AD_OUT_MODEL_CONFIG}{model_key}:{abtest_id}:{abtest_config_tag}"
    # threshold_key = f"{config_key_prefix}:threshold"
    # use_mean_key = f"{config_key_prefix}:use_mean"
    # threshold = redis_helper.get_data_from_redis(key_name=threshold_key)
    # use_mean = redis_helper.get_data_from_redis(key_name=use_mean_key)
    # print('threshold:', threshold, type(threshold))
    # print('use_mean:', use_mean, type(use_mean))
    # expire_time = 30 * 24 * 3600
    # redis_helper.set_data_to_redis(threshold_key, 0.4, expire_time)
    # redis_helper.set_data_to_redis(use_mean_key, 1, expire_time)
    # print(threshold_key)
    # print(use_mean_key)