def _clean_event(self, event): if not event: return {} event = event[:StatsyEvent.NAME_LENGTH_LIMIT] if self.use_cache: cache_key = StatsyEvent.cache_key_string.format(event) event = cache.setdefault( cache_key, lambda: self.events.get_or_create(name=event)[0]) else: event, _ = self.events.get_or_create(name=event) if event.is_active: return {'event_id': event.id} raise StatsyDisabled
def _clean_group(self, group): if not group: return {} group = group[:StatsyGroup.NAME_LENGTH_LIMIT] if self.use_cache: cache_key = StatsyGroup.cache_key_string.format(group) group = cache.setdefault( cache_key, lambda: self.groups.get_or_create(name=group)[0]) else: group, _ = self.groups.get_or_create(name=group) if group.is_active: return {'group_id': group.id} raise StatsyDisabled
def _clean_event(self, event): if not event: return {} event = event[:StatsyEvent.NAME_LENGTH_LIMIT] if self.use_cache: cache_key = StatsyEvent.cache_key_string.format(event) event = cache.setdefault( cache_key, lambda: self.events.get_or_create(name=event)[0] ) else: event, _ = self.events.get_or_create(name=event) if event.is_active: return { 'event_id': event.id } raise StatsyDisabled
def _clean_group(self, group): if not group: return {} group = group[:StatsyGroup.NAME_LENGTH_LIMIT] if self.use_cache: cache_key = StatsyGroup.cache_key_string.format(group) group = cache.setdefault( cache_key, lambda: self.groups.get_or_create(name=group)[0] ) else: group, _ = self.groups.get_or_create(name=group) if group.is_active: return { 'group_id': group.id } raise StatsyDisabled