def METHOD_NAME(pid, record, page=1, **kwargs):
    """Record view - get files for current page."""
    rf = record.get('files', [])
    items_per_page = request.args.get('perPage', 5)
    try:
        items_per_page = int(items_per_page)
    except Exception:
        items_per_page = 5
    if request.args.get('group'):
        # grouped = groupby(rf, lambda x: x.get('type'))
        index_files = [d for d in rf if (
            d.get('type', "") in ['index', 'index.txt'])]
        _files = [d for d in rf if (
            d.get('type', "") not in ['index', 'index.txt', 'index.json'])]
        grouped_files = {
            "index_files": {
                "total": len(index_files),
                "files": index_files[:items_per_page]
            },
            "files": {
                "total": len(_files),
                "files": _files[:items_per_page]
            },
        }
        return jsonify(grouped_files)
    file_type_filter = request.args.get('type')
    if file_type_filter == 'index_files':
        filtered_files = [d
                          for d in rf
                          if (d.get('type', "")
                              in ['index', 'index.txt'])]
        rf_len = len(filtered_files)
        paged_files = get_paged_files(filtered_files, page, items_per_page)
        return jsonify({"total": rf_len, "files": paged_files})
    else:
        filtered_files = [d
                          for d in rf
                          if (d.get('type', "")
                              not in ['index', 'index.txt', 'index.json'])]
        rf_len = len(filtered_files)
        paged_files = get_paged_files(filtered_files, page, items_per_page)
        return jsonify({"total": rf_len, "files": paged_files})
    rf_len = len(rf)
    paged_files = get_paged_files(rf, page, items_per_page)
    return jsonify({"total": rf_len, "files": paged_files})