def _handle_compared(self, date_filter: Dict[str, datetime]) -> QuerySet: date_from, date_to = get_compare_period_dates( date_filter["timestamp__gte"], date_filter["timestamp__lte"]) date_filter["timestamp__gte"] = date_from date_filter["timestamp__lte"] = date_to compared_events = self.get_queryset().filter(**date_filter) return compared_events
def determine_compared_filter(filter): date_from, date_to = get_compare_period_dates(filter.date_from, filter.date_to) compared_filter = copy.deepcopy(filter) compared_filter._date_from = date_from.date().isoformat() compared_filter._date_to = date_to.date().isoformat() return compared_filter
def _determine_compared_filter(self, filter, request): date_from, date_to = get_compare_period_dates(filter.date_from, filter.date_to) compared_filter = Filter(request=request) compared_filter._date_from = date_from.date().isoformat() compared_filter._date_to = date_to.date().isoformat() return compared_filter
def determine_compared_filter(filter): if not filter.date_to or not filter.date_from: raise ValueError("You need date_from and date_to to compare") date_from, date_to = get_compare_period_dates(filter.date_from, filter.date_to) compared_filter = Filter( data={**filter._data, "date_from": date_from.date().isoformat(), "date_to": date_to.date().isoformat()} ) return compared_filter
def _determine_compared_filter(filter: Filter) -> Filter: if not filter.date_to or not filter.date_from: raise ValueError("You need date_from and date_to to compare") date_from, date_to = get_compare_period_dates(filter.date_from, filter.date_to) compared_filter = copy.deepcopy(filter) compared_filter._date_from = date_from.date().isoformat() compared_filter._date_to = date_to.date().isoformat() return compared_filter
def determine_compared_filter(filter) -> Filter: if not filter.date_to or not filter.date_from: raise ValidationError("You need date_from and date_to to compare") date_from, date_to = get_compare_period_dates(filter.date_from, filter.date_to) return filter.with_data({ "date_from": date_from.date().isoformat(), "date_to": date_to.date().isoformat() })
def _handle_compared(self, date_filter: Dict[str, datetime], session_type: str) -> List[Dict[str, Any]]: date_from, date_to = get_compare_period_dates( date_filter['timestamp__gte'], date_filter['timestamp__lte']) date_filter['timestamp__gte'] = date_from date_filter['timestamp__lte'] = date_to compared_events = self.get_queryset().filter(**date_filter) compared_calculated = self.calculate_sessions(compared_events, session_type, date_filter) return compared_calculated