Exemplo n.º 1
0
    def actor_query(self, limit_actors: Optional[bool] = True):
        drop_off = self._filter.drop_off
        if drop_off is None:
            raise ValidationError(
                f"Filter parameter {DROP_OFF} must be provided and a bool for funnel trends persons!"
            )

        entrance_period_start = self._filter.entrance_period_start
        if not entrance_period_start:
            raise ValidationError(
                f"Filter parameter {ENTRANCE_PERIOD_START} must be provided and a datetime for funnel trends persons!"
            )

        step_counts_query = self.get_step_counts_without_aggregation_query(
            specific_entrance_period_start=entrance_period_start)
        # Expects multiple rows for same person, first event time, steps taken.
        self.params.update(self.funnel_order.params)

        _, reached_to_step_count_condition, did_not_reach_to_step_count_condition = self.get_steps_reached_conditions(
        )

        return (
            FUNNEL_PERSONS_BY_STEP_SQL.format(
                steps_per_person_query=step_counts_query,
                persons_steps=did_not_reach_to_step_count_condition
                if drop_off else reached_to_step_count_condition,
                matching_events_select_statement=self.
                _get_funnel_person_step_events(),
                extra_fields="",
                limit="LIMIT %(limit)s" if limit_actors else "",
                offset="OFFSET %(offset)s" if limit_actors else "",
            ),
            self.params,
        )
Exemplo n.º 2
0
    def get_query(self) -> str:
        drop_off = self._filter.drop_off
        if drop_off is None:
            raise ValidationError(
                f"Filter parameter {DROP_OFF} must be provided and a bool for funnel trends persons!"
            )

        entrance_period_start = self._filter.entrance_period_start
        if not entrance_period_start:
            raise ValidationError(
                f"Filter parameter {ENTRANCE_PERIOD_START} must be provided and a datetime for funnel trends persons!"
            )

        step_counts_query = self.get_step_counts_without_aggregation_query(
            specific_entrance_period_start=entrance_period_start)
        # Expects multiple rows for same person, first event time, steps taken.
        self.params.update(self.funnel_order.params)

        _, reached_to_step_count_condition, did_not_reach_to_step_count_condition = self.get_steps_reached_conditions(
        )

        return FUNNEL_PERSONS_BY_STEP_SQL.format(
            offset=self._filter.offset,
            steps_per_person_query=step_counts_query,
            persons_steps=did_not_reach_to_step_count_condition
            if drop_off else reached_to_step_count_condition,
        )
Exemplo n.º 3
0
 def get_query(self):
     return FUNNEL_PERSONS_BY_STEP_SQL.format(
         offset=self._filter.offset,
         steps_per_person_query=self.get_step_counts_query(),
         persons_steps=self._get_funnel_person_step_condition(),
         extra_fields=self._get_timestamp_outer_select(),
         limit="" if self._no_person_limit else "LIMIT %(limit)s",
     )
Exemplo n.º 4
0
 def get_query(self, extra_fields: Optional[List[str]] = None):
     extra_fields_string = ", ".join([self._get_timestamp_outer_select()] +
                                     (extra_fields or []))
     return FUNNEL_PERSONS_BY_STEP_SQL.format(
         offset=self._filter.offset,
         steps_per_person_query=self.get_step_counts_query(),
         persons_steps=self._get_funnel_person_step_condition(),
         extra_fields=extra_fields_string,
         limit="" if self._no_person_limit else "LIMIT %(limit)s",
     )
Exemplo n.º 5
0
 def actor_query(self, limit_actors: Optional[bool] = True, extra_fields: Optional[List[str]] = None):
     extra_fields_string = ", ".join([self._get_timestamp_outer_select()] + (extra_fields or []))
     return (
         FUNNEL_PERSONS_BY_STEP_SQL.format(
             steps_per_person_query=self.get_step_counts_query(),
             persons_steps=self._get_funnel_person_step_condition(),
             matching_events_select_statement=self._get_funnel_person_step_events(),
             extra_fields=extra_fields_string,
             limit="LIMIT %(limit)s" if limit_actors else "",
             offset="OFFSET %(offset)s" if limit_actors else "",
         ),
         self.params,
     )
Exemplo n.º 6
0
 def get_query(self):
     return FUNNEL_PERSONS_BY_STEP_SQL.format(
         offset=self._filter.offset,
         steps_per_person_query=self.get_step_counts_query(),
         persons_steps=self._get_funnel_person_step_condition(),
     )