def _does_cohort_need_persons(self, prop: Property) -> bool: try: cohort = Cohort.objects.get(pk=prop.value, team_id=self._team_id) except Cohort.DoesNotExist: return False if is_precalculated_query(cohort): return True for group in cohort.groups: if group.get("properties"): return True return False
def _get_cohort_subquery(self, prop) -> Tuple[str, Dict[str, Any]]: cohort = Cohort.objects.get(pk=prop.value, team_id=self._team_id) is_precalculated = is_precalculated_query(cohort) person_id_query, cohort_filter_params = ( get_precalculated_query(cohort, custom_match_field=f"{self.DISTINCT_ID_TABLE_ALIAS}.person_id") if is_precalculated else format_person_query(cohort, custom_match_field=f"{self.DISTINCT_ID_TABLE_ALIAS}.person_id") ) return person_id_query, cohort_filter_params
def _get_cohort_subquery(self, prop) -> Tuple[str, Dict[str, Any]]: try: cohort: Cohort = Cohort.objects.get(pk=prop.value, team_id=self._team_id) except Cohort.DoesNotExist: return "0 = 1", {} # If cohort doesn't exist, nothing can match is_precalculated = is_precalculated_query(cohort) person_id_query, cohort_filter_params = ( get_precalculated_query(cohort, 0, custom_match_field=f"{self.DISTINCT_ID_TABLE_ALIAS}.person_id") if is_precalculated else format_person_query(cohort, 0, custom_match_field=f"{self.DISTINCT_ID_TABLE_ALIAS}.person_id") ) return person_id_query, cohort_filter_params