def METHOD_NAME(request, table_id):
    "Returns a list of available reports and labels."
    reports = Spappresource.objects.filter(
        mimetype__icontains="jrxml/",
        spappresourcedir__discipline=request.specify_collection.discipline) \
        .prefetch_related('spreports') \
        .filter(
        Q(spappresourcedir__collection=None) |
        Q(spappresourcedir__collection=request.specify_collection)) \
        .filter(
        Q(spappresourcedir__specifyuser=request.specify_user) |
        Q(spappresourcedir__ispersonal=False))
    if table_id is not None:
        reports = reports.filter(Q(spreports__query__contexttableid=table_id))
    def map(app_resource):
        report = app_resource.spreports.first()
        return dict(
            app_resource=app_resource,
            report=report,
            query=None if report is None else report.query
        )
    response = [
        map(app_resource) for app_resource in reports
    ]
    data = objs_to_data_(
        response,
        len(response),
        lambda o: {
            key: None if value is None else _obj_to_data(value, lambda x: None)
            for key, value in o.items()
        },
        request.GET.get('offset', 0),
        request.GET.get('limit', 0)
    )
    return HttpResponse(toJson(data), content_type="application/json")