(sketch, form)
return aggregation
Creates an aggregation from form data.

        Args:
            sketch: Instance of timesketch.models.sketch.Sketch
            form: Instance of timesketch.lib.forms.SaveAggregationForm

        Returns:
            An aggregation (instance of timesketch.models.sketch.Aggregation)
Creates an aggregation from form data.
Creates an aggregation from form data .
def create_aggregation_from_form(sketch, form):
        """Creates an aggregation from form data.

        Args:
            sketch: Instance of timesketch.models.sketch.Sketch
            form: Instance of timesketch.lib.forms.SaveAggregationForm

        Returns:
            An aggregation (instance of timesketch.models.sketch.Aggregation)
        """
        # Default to user supplied data
        name = form.get('name', '')
        description = form.get('description', '')
        agg_type = form.get('agg_type', '')
        parameter_data = form.get('parameters', {})
        parameters = json.dumps(parameter_data, ensure_ascii=False)
        chart_type = form.get('chart_type', '')
        view_id = form.get('view_id')

        # Create the aggregation in the database
        aggregation = Aggregation(
            name=name,
            description=description,
            agg_type=agg_type,
            parameters=parameters,
            chart_type=chart_type,
            user=current_user,
            sketch=sketch,
            view=view_id
        )

        labels = form.get('labels', '')
        if labels:
            for label in json.loads(labels):
                if aggregation.has_label(label):
                    continue
                aggregation.add_label(label)

        db_session.add(aggregation)
        db_session.commit()

        return aggregation
def create_aggregation_from_form ( sketch , form ) : # Default to user supplied data name = form . get ( 'name' , '' ) description = form . get ( 'description' , '' ) agg_type = form . get ( 'agg_type' , '' ) parameter_data = form . get ( 'parameters' , { } ) parameters = json . dumps ( parameter_data , ensure_ascii = False ) chart_type = form . get ( 'chart_type' , '' ) view_id = form . get ( 'view_id' ) # Create the aggregation in the database aggregation = Aggregation ( name = name , description = description , agg_type = agg_type , parameters = parameters , chart_type = chart_type , user = current_user , sketch = sketch , view = view_id ) labels = form . get ( 'labels' , '' ) if labels : for label in json . loads ( labels ) : if aggregation . has_label ( label ) : continue aggregation . add_label ( label ) db_session . add ( aggregation ) db_session . commit ( ) return aggregation