def incr(self, type): """Add to the number of times this action has been performed, stored in the DB""" assert type in IMPRESSION_TYPES day = get_ad_day() impression, _ = self.impressions.get_or_create(date=day) setattr(impression, type, models.F(type) + 1) impression.save()
def incr(self, type, project=None): """Add to the number of times this action has been performed, stored in the DB""" assert type in IMPRESSION_TYPES day = get_ad_day() if project: impression, _ = self.project_impressions.get_or_create(date=day, project=project) else: impression, _ = self.impressions.get_or_create(date=day) setattr(impression, type, models.F(type) + 1) impression.save()
def views_shown_today(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get_or_create(date=day)[0] return float(impression.views)
def click_ratio(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get_or_create(date=day)[0] return impression.click_ratio
def click_ratio(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get(date=day) return impression.click_ratio
def views_shown_today(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get_or_create(date=day)[0] return float(impression.views)
def view_ratio(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get_or_create(date=day)[0] return impression.view_ratio
def view_ratio(self, day=None): if not day: day = get_ad_day() impression = self.impressions.get(date=day) return impression.view_ratio