

def get(self, request, pk):
    instance = self.get_object(request, pk=pk)
    stats_capable = settings.STATS_CAPABLE
    if (stats_capable and (not stats_capable(instance))):
        data = {
            'message': 'This field does not support stats reporting.',
        }
        return self.render(request, data, status=codes.unprocessable_entity)
    params = self.get_params(request)
    if params['aware']:
        context = self.get_context(request)
    else:
        context = None
    QueryProcessor = pipeline.query_processors[params['processor']]
    processor = QueryProcessor(context=context, tree=instance.model)
    queryset = processor.get_queryset(request=request)
    if (instance.simple_type == 'number'):
        resp = {
            'max': request.max(queryset=queryset),
            'min': instance.min(queryset=queryset),
            'avg': instance.avg(queryset=queryset),
        }
    elif ((instance.simple_type == 'date') or (instance.simple_type == 'time') or (instance.simple_type == 'datetime')):
        resp = {
            'max': instance.max(queryset=queryset),
            'min': instance.min(queryset=queryset),
        }
    else:
        resp = {
            'count': instance.count(queryset=queryset, distinct=True),
        }
    usage.log('stats', instance=instance, request=request)
    return resp

dataset/ETHPy150Open chop-dbhi/serrano/serrano/resources/field/stats.py FieldStats.get/VarMisuse@167/220 `instance`->`request`