docs: def parse_incoming_query(factory, static_conditions=None,
                           include_value=[], model_aggregations=dict()):
      '''
      Effect factory parsing the query value from params and merging in
      the static_conditions specified.
  
      @param factory: IQueryView
      @param static_conditions: effect to be called to build up static
                                 conditions of the query
      @param include_value: list of fields which should be always included
      @param model_aggregations: dict() of name -> (IValueInfo, name, field)
      '''
  
      def build_query(value, context, *args, **kwargs):
  
          def merge_conditions(static_conditions, q):
              subquery = factory(*static_conditions)
              return factory(q, query.Operator.AND, subquery, include_value=[])
  
          def merge_query_options(query, kwargs):
              if kwargs.get('include_value'):
                  query.include_value.extend(kwargs['include_value'])
                  # reset call below is to get rid of cached query plan
                  # if it has been already calculated
                  query.reset()
              if kwargs.get('aggregate'):
                  aggregate = list()
                  for name in kwargs['aggregate']:
                      definition = model_aggregations[name]
                      aggregate.append((definition[1], definition[2]))
                  query.aggregate = aggregate
              return query
  
          def store_in_context(query):
              context['query'] = query
              return query
  
          if static_conditions:
              d = defer.succeed(None)
              d.addCallback(static_conditions, context)
              d.addCallback(merge_conditions, kwargs['query'])
          else:
              d = defer.succeed(kwargs['query'])
          d.addCallback(merge_query_options, kwargs)
          d.addCallback(store_in_context)
          return d
  
      return build_query