database/tableau_api_models.py
def construct_summary_statistics(self):
        """
        Construct summary statistics from forest output, returning whether or not any
        SummaryStatisticDaily has potentially been created or updated.
        """
        if not os.path.exists(self.forest_results_path):
            return False

        if self.forest_tree == ForestTree.jasmine:
            task_attribute = "jasmine_task"
        elif self.forest_tree == ForestTree.willow:
            task_attribute = "willow_task"
        else:
            raise Exception("Unknown tree")
        
        with open(self.forest_results_path, "r") as f:
            reader = csv.DictReader(f)
            has_data = False
    
            for line in reader:
                has_data = True
                summary_date = datetime.date(
                    int(float(line['year'])),
                    int(float(line['month'])),
                    int(float(line['day'])),
                )
                if not (self.data_date_start < summary_date < self.data_date_end):
                    continue
                updates = {}
                for column_name, value in line.items():
                    if (self.forest_tree, column_name) in TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS:
                        summary_stat_field, interpretation_function = TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS[(self.forest_tree, column_name)]
                        if interpretation_function is not None:
                            updates[summary_stat_field] = interpretation_function(value, line)
                        elif value == '':
                            updates[summary_stat_field] = None
                        else:
                            updates[summary_stat_field] = value
            
                updates[task_attribute] = self
                
                data = {
                    "date": summary_date,
                    "defaults": updates,
                    "participant": self.participant,
                }
                SummaryStatisticDaily.objects.update_or_create(**data)
        return has_data

        Construct summary statistics from forest output, returning whether or not any
        SummaryStatisticDaily has potentially been created or updated.
        
Construct summary statistics from forest output, returning whether or not any
SummaryStatisticDaily has potentially been created or updated.
Construct summary statistics from forest output returning whether or not any SummaryStatisticDaily has potentially been created or updated .
def construct_summary_statistics(self):
        if not os.path.exists(self.forest_results_path):
            return False
        if self.forest_tree == ForestTree.jasmine:
            task_attribute = "jasmine_task"
        elif self.forest_tree == ForestTree.willow:
            task_attribute = "willow_task"
        else:
            raise Exception("Unknown tree")
        with open(self.forest_results_path, "r") as f:
            reader = csv.DictReader(f)
            has_data = False
            for line in reader:
                has_data = True
                summary_date = datetime.date(
                    int(float(line['year'])),
                    int(float(line['month'])),
                    int(float(line['day'])),
                )
                if not (self.data_date_start < summary_date < self.data_date_end):
                    continue
                updates = {}
                for column_name, value in line.items():
                    if (self.forest_tree, column_name) in TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS:
                        summary_stat_field, interpretation_function = TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS[(self.forest_tree, column_name)]
                        if interpretation_function is not None:
                            updates[summary_stat_field] = interpretation_function(value, line)
                        elif value == '':
                            updates[summary_stat_field] = None
                        else:
                            updates[summary_stat_field] = value
                updates[task_attribute] = self
                data = {
                    "date": summary_date,
                    "defaults": updates,
                    "participant": self.participant,
                }
                SummaryStatisticDaily.objects.update_or_create(**data)
        return has_data
def construct_summary_statistics ( self ) : if not os . path . exists ( self . forest_results_path ) : return False if self . forest_tree == ForestTree . jasmine : task_attribute = "jasmine_task" elif self . forest_tree == ForestTree . willow : task_attribute = "willow_task" else : raise Exception ( "Unknown tree" ) with open ( self . forest_results_path , "r" ) as f : reader = csv . DictReader ( f ) has_data = False for line in reader : has_data = True summary_date = datetime . date ( int ( float ( line [ 'year' ] ) ) , int ( float ( line [ 'month' ] ) ) , int ( float ( line [ 'day' ] ) ) , ) if not ( self . data_date_start < summary_date < self . data_date_end ) : continue updates = { } for column_name , value in line . items ( ) : if ( self . forest_tree , column_name ) in TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS : summary_stat_field , interpretation_function = TREE_COLUMN_NAMES_TO_SUMMARY_STATISTICS [ ( self . forest_tree , column_name ) ] if interpretation_function is not None : updates [ summary_stat_field ] = interpretation_function ( value , line ) elif value == '' : updates [ summary_stat_field ] = None else : updates [ summary_stat_field ] = value updates [ task_attribute ] = self data = { "date" : summary_date , "defaults" : updates , "participant" : self . participant , } SummaryStatisticDaily . objects . update_or_create ( ** data ) return has_data
Construct summary statistics from forest output, returning whether or not any
SummaryStatisticDaily has potentially been created or updated.
Construct summary statistics from forest output returning whether or not any SummaryStatisticDaily has potentially been created or updated .
"""
        Construct summary statistics from forest output, returning whether or not any
        SummaryStatisticDaily has potentially been created or updated.
        """
self