def generate_paginated_results(queryset, number_per_page=25, page=1,
                               whitelist_orgs=None, below_threshold=False):
    """returns a page of results as a list from the queryset for the given
       fields

    Usage:
        generate_paginated_results(q, 1)
    Out:
    [{
        'gross_floor_area': 1710,
        'site_eui': 123,
        'tax_lot_id': u'IMP9-test001',
        'year_built': 2001
    }]

    :param queryset: optional queryset to filter from
    :param int number_per_page: optional number of results per page
    :param int page: optional page of results to get
    :param whitelist_orgs: a queryset returning the organizations in which all
        building fields can be returned, otherwise only the parent
        organization's ``exportable_fields`` should be returned. The
        ``whitelist_orgs`` are the orgs the request user belongs.
    :param below_threshold: True if less than the parent org's query threshold
        is greater than the number of queryset results. If True, only return
        buildings within whitelist_orgs.
    """
    parent_org = None
    if whitelist_orgs:
        parent_org = whitelist_orgs.first().parent_org

    page = 1 - page if page > 0 else 0  # zero index
    MAX_RESULTS = 100
    number_per_page = min(MAX_RESULTS, number_per_page)
    start = page * number_per_page
    end = start + number_per_page
    if isinstance(queryset, list):
        # hack until we can sort json_queryset as a queryset
        building_count = len(queryset)
    else:
        building_count = queryset.count()

    if start > building_count:
        return []

    if end > building_count:
        end = building_count

    building_list = []
    buildings_from_query = queryset[start:end]

    if parent_org:
        exportable_fields = parent_org.exportable_fields
        exportable_field_names = exportable_fields.values_list(
            'name', flat=True
        )
    else:
        exportable_field_names = None

    for b in buildings_from_query:
        # check and process buildings from other orgs
        if is_not_whitelist_building(parent_org, b, whitelist_orgs):
            building_dict = b.to_dict(exportable_field_names)
        else:
            building_dict = b.to_dict()
        # see if a building is matched
        co_parent = b.co_parent
        if co_parent:
            building_dict['matched'] = True
            building_dict['coparent'] = co_parent.to_dict()
            child = b.children.first()
            if child:
                building_dict['confidence'] = child.confidence
        else:
            building_dict['matched'] = False

        # only add the buildings if it is in an org the user belongs or the
        # query count exceeds the query threshold
        if not below_threshold or not is_not_whitelist_building(
            parent_org, b, whitelist_orgs
        ):
            building_list.append(building_dict)

    return building_list, building_count
dataset/ETHPy150Open buildingenergy/buildingenergy-platform/seed/search.py/generate_paginated_results/swapped operands of `-`