(self, username)
return data_source_config._id
Build a temp datasource and return the ID
Build a temp datasource and return the ID
Build a temp datasource and return the ID
def create_temp_data_source_if_necessary(self, username):
        """
        Build a temp datasource and return the ID
        """
        if not self.ds_builder.uses_managed_data_source:
            # if the data source interface doens't use a temp data source then the id is just the source_id
            return self.ds_builder.data_source_id

        filters = [f._asdict() for f in self.initial_user_filters + self.initial_default_filters]
        columns = [c._asdict() for c in self.initial_columns]

        data_source_config = self.ds_builder.construct_data_source(
            table_id=clean_table_name(self.domain, uuid.uuid4().hex),
            **self.ds_builder.get_temp_datasource_constructor_kwargs(columns, filters)
        )
        data_source_config.validate()
        data_source_config.save()

        # expire the data source
        always_eager = hasattr(settings, "CELERY_TASK_ALWAYS_EAGER") and settings.CELERY_TASK_ALWAYS_EAGER
        # CELERY_TASK_ALWAYS_EAGER will cause the data source to be deleted immediately. Switch it off temporarily
        settings.CELERY_TASK_ALWAYS_EAGER = False
        tasks.delete_data_source_task.apply_async(
            (self.domain, data_source_config._id),
            countdown=TEMP_DATA_SOURCE_LIFESPAN
        )
        settings.CELERY_TASK_ALWAYS_EAGER = always_eager

        tasks.rebuild_indicators(data_source_config._id,
                                 username,
                                 limit=SAMPLE_DATA_MAX_ROWS)  # Do synchronously
        self._filter_data_source_changes(data_source_config._id)
        return data_source_config._id
def create_temp_data_source_if_necessary ( self , username ) : if not self . ds_builder . uses_managed_data_source : # if the data source interface doens't use a temp data source then the id is just the source_id return self . ds_builder . data_source_id filters = [ f . _asdict ( ) for f in self . initial_user_filters + self . initial_default_filters ] columns = [ c . _asdict ( ) for c in self . initial_columns ] data_source_config = self . ds_builder . construct_data_source ( table_id = clean_table_name ( self . domain , uuid . uuid4 ( ) . hex ) , * * self . ds_builder . get_temp_datasource_constructor_kwargs ( columns , filters ) ) data_source_config . validate ( ) data_source_config . save ( ) # expire the data source always_eager = hasattr ( settings , "CELERY_TASK_ALWAYS_EAGER" ) and settings . CELERY_TASK_ALWAYS_EAGER # CELERY_TASK_ALWAYS_EAGER will cause the data source to be deleted immediately. Switch it off temporarily settings . CELERY_TASK_ALWAYS_EAGER = False tasks . delete_data_source_task . apply_async ( ( self . domain , data_source_config . _id ) , countdown = TEMP_DATA_SOURCE_LIFESPAN ) settings . CELERY_TASK_ALWAYS_EAGER = always_eager tasks . rebuild_indicators ( data_source_config . _id , username , limit = SAMPLE_DATA_MAX_ROWS ) # Do synchronously self . _filter_data_source_changes ( data_source_config . _id ) return data_source_config . _id