예제 #1
0
    def get_task_report(cls, shop_id, campaign_id, last_sync_time, tapi):
        mnger = cls.get_manager(campaign_id, last_sync_time, tapi)
        if not mnger.has_task():
            mnger.time_slot = cls.get_time_slot(last_sync_time)
            mnger.register_task(tapi)

        if time_is_ndays_interval(mnger.task_start_time, 2): # 超过两天,就放弃之前的任务,重新生成任务
            mnger.time_slot = cls.get_time_slot(last_sync_time)  # 重新生成timeslot
            mnger.register_task(tapi)
            return False, []
        else:
            status = mnger.get_status(tapi)
            if status == TaskStatusEnum.done:
                rpt_list = mnger.get_task_result(shop_id)
                return True, rpt_list
            elif status == TaskStatusEnum.failed:
                # 如果是今天的任务,还可以抢救一下,否则只能重新生成任务了,因为报表的特殊性,只要过一天,结果就不一样了。
                if time_is_ndays_interval(mnger.task_start_time, 0): 
                    mnger.regenerate_task(tapi)
                else:
                    mnger.time_slot = cls.get_time_slot(last_sync_time)
                    mnger.register_task(tapi)
                return False, []
            else:
                return False, []
예제 #2
0
 def ensure_task(cls, shop_id, campaign_id, last_sync_time, tapi): # 保证任务生成,不管结果
     mnger = cls.get_manager(campaign_id, last_sync_time, tapi)
     if time_is_ndays_interval(mnger.task_start_time, 2): # 超过两天,就放弃之前的任务,重新生成任务
         mnger.time_slot = cls.get_time_slot(last_sync_time)  # 重新生成time_slot
         mnger.register_task(tapi)
         return True
     else:
         if mnger.get_status(tapi) == TaskStatusEnum.failed:
             if time_is_ndays_interval(mnger.task_start_time, 0): 
                 mnger.regenerate_task(tapi)
             else:
                 mnger.time_slot = cls.get_time_slot(last_sync_time)
                 mnger.register_task(tapi)
             return True
         else:
             return True
예제 #3
0
def auto_optimize_dryrun2(adg_wrapper, strategy_name = '', summary_rpt = -1):
    adg_wrapper.init_report(force_sync_qscore = time_is_ndays_interval(adg_wrapper.adgroup.qscore_sync_time, 1))
    #
    adg_wrapper.prepare_data_4optimize_mobile()
    analyze_result = AdgRptAnalyze().analyze(adg_wrapper = adg_wrapper)
    adg_wrapper.analyze_result.update(analyze_result)
    adg_wrapper.calc_kw_limitprice_mobile(kw_g_cpc = analyze_result.get('kw_g_ppc7', 500))
    strategy_mobile_name = strategy_name
    if not strategy_name:
        if adg_wrapper.kw_list_valid:
            alg = Algorithm1()
            strategy_mobile_name, _ = alg.diagnose(adg_wrapper = adg_wrapper)
        else:
            strategy_mobile_name = DEFAULT_NO_CLICK_STRATEGY
    strategy_mobile = StrategyFactory().get(name = strategy_mobile_name)
    strategy_mobile.dry_run(data = adg_wrapper)

    adg_wrapper.prepare_data_4optimize_pc()
    analyze_result = AdgRptAnalyze().analyze(adg_wrapper = adg_wrapper)
    adg_wrapper.analyze_result.update(analyze_result)
    adg_wrapper.calc_kw_limitprice_pc(kw_g_cpc = analyze_result.get('kw_g_ppc7', 500))
    strategy_pc_name = strategy_name
    if not strategy_name:
        if adg_wrapper.kw_list_valid:
            alg = Algorithm1()
            strategy_pc_name, _ = alg.diagnose(adg_wrapper = adg_wrapper)
        else:
            strategy_pc_name = DEFAULT_NO_CLICK_STRATEGY
    strategy_pc = StrategyFactory().get(name = strategy_pc_name)
    strategy_pc.dry_run(data = adg_wrapper)

    adg_wrapper.summarize_report(rpt = summary_rpt)
    return
예제 #4
0
def auto_optimize_dryrun(adg_wrapper, strategy_name = ''):
    adg_wrapper.init_report(force_sync_qscore = time_is_ndays_interval(adg_wrapper.adgroup.qscore_sync_time, 1))
    analyze_result = AdgRptAnalyze().analyze(adg_wrapper = adg_wrapper)
    adg_wrapper.analyze_result.update(analyze_result)
    adg_wrapper.calc_kw_limitprice(kw_g_cpc = analyze_result.get('kw_g_ppc7', 500))
    alg = Algorithm1()
    if not strategy_name:
        strategy_name, _ = alg.diagnose(adg_wrapper = adg_wrapper)
    strategy = StrategyFactory().get(name = strategy_name)
    strategy.dry_run(data = adg_wrapper)
    return
예제 #5
0
파일: api.py 프로젝트: Florence3546/CRM
 def is_outservice(shop_id):
     expire_days = Config.get_value('web.clean_up.OUTSERVICE_EXPIRE_DAYS',
                                    default=15)
     deadline_query_sql = "select deadline from router_articleusersubscribe where nick=(select nick from router_user where shop_id=%s) order by deadline desc limit 1"
     # 检查是否可删除
     deadline_list = execute_query_sql(deadline_query_sql % shop_id)
     for tmp_deadline in deadline_list:
         deadline = tmp_deadline["deadline"]
         if time_is_ndays_interval(deadline, expire_days):
             return True
     return False
예제 #6
0
def temp_strategy_optimize_dryrun(adg_wrapper, strategy_name, kw_cmd_list, adg_cmd_list):
    adg_wrapper.init_report(force_sync_qscore = time_is_ndays_interval(adg_wrapper.adgroup.qscore_sync_time, 1))
    analyze_result = AdgRptAnalyze().analyze(adg_wrapper = adg_wrapper)
    adg_wrapper.analyze_result.update(analyze_result)
    adg_wrapper.calc_kw_limitprice(kw_g_cpc = analyze_result.get('kw_g_ppc7', 500))
    if strategy_name:
        strategy = StrategyFactory().get(name = strategy_name)
    else:
        adg_wrapper.can_add_kw = False
        strategy = CommandStrategy(cmd_cfg_name = 'temp')
        strategy.bind_temp_strategy(kw_cmd_list = kw_cmd_list, adg_cmd_list = adg_cmd_list)
    strategy.dry_run(data = adg_wrapper)
예제 #7
0
파일: rates.py 프로젝트: Florence3546/CRM
def is_recent(value, args):
    """
            判断该对象是不是最近创建,或者最近删除等
    {{k|is_recent:'create_time,5'}}    返回True或者False,天数要注意,如果是一周内,天数是6,可以是负数
    {{k|is_recent:'create_time'}}    不带天数表示是否是当天
    """
    try:
        if value and args:
            args_list = args.split(',')
            if hasattr(value, args_list[0]):
                from apps.common.utils.utils_datetime import time_is_ndays_interval, time_is_someday
                if len(args_list) == 2:
                    return time_is_ndays_interval(getattr(value, args_list[0]),
                                                  int(args_list[1]))
                elif len(args_list) == 1:
                    return time_is_someday(getattr(value, args_list[0]))
                else:
                    raise Exception()
            else:
                raise Exception()
    except Exception, e:
        return False