Ejemplo n.º 1
0
    def get_addition_clients(self, targeting_code, num, day_im_id):
        """
        向 campaign_client 里补充 num 个 client
        """
        #clients = list()
        try_max = 100
        try_temp = 0
        while num > 0:
            client = self.get_client_by_region(targeting_code)
            if not client:
                num -= 1
                continue

            if try_temp > try_max:
                break
            try:
                DayImpressionModel.get().where(DayImpressionModel.day_impression_id == day_im_id,
                                               DayImpressionModel.client_id == client.id)
            except:
                # clients.append(client)
                CampaignClientModel(day_impression_id=day_im_id,
                                    client_id=client.id,
                                    actual_plan_impression=0).\
                    save()
            else:
                try_temp += 1
                continue

            try_temp = 0
            num -= 1
Ejemplo n.º 2
0
 def get_day_impression_by_id(self, id):
     try:
         day_im = DayImpressionModel.select()
         return day_im.where(DayImpressionModel.impression_master_id == id)
     except Exception as e:
         self.logger.warning(e)
         return None