Skip to content

Commit

Permalink
Merge pull request #3307 from freelawproject/3294-add-api-fields
Browse files Browse the repository at this point in the history
A few API tweaks
  • Loading branch information
mlissner authored Oct 26, 2023
2 parents ba49235 + 06e5098 commit 347b90b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cl/alerts/api_serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from drf_dynamic_fields import DynamicFieldsMixin
from rest_framework import serializers
from rest_framework.serializers import HyperlinkedRelatedField

from cl.alerts.models import Alert, DocketAlert
from cl.api.utils import HyperlinkedModelSerializerWithId
from cl.search.models import Docket


class SearchAlertSerializer(
Expand Down
5 changes: 4 additions & 1 deletion cl/api/templates/rest-change-log.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ <h4 class="v-offset-below-3">
<h1 id="about">REST API Change Log</h1>
<ul>
<li>
<p><strong>v3.14</strong> &mdash; This release blocks users from paginating past page 100 in the API. This release is not backwards incompatible, but is being released on an emergency basis to stop crawlers that have been impacting our database tier. In our performance documentation, we have long warned against using deep pagination. Now it is blocked. If you need this functionality for your application, please consider using filters to complete your crawling instead.
<p><strong>v3.15</strong> — Allow deep pagination on the Court endpoint, add <code>docket_id</code> to the Clusters endpoint, and add <code>cluster_id</code> and <code>author_id</code> to the Opinions endpoint.</p>
</li>
<li>
<p><strong>v3.14</strong> &mdash; This release blocks users from paginating past page 100 in the API. This release is not backwards incompatible, but is being released on an emergency basis to stop crawlers that have been impacting our database tier. In our performance documentation, we have long warned against using deep pagination. Now it is blocked. If you need this functionality for your application, please consider using filters to complete your crawling instead.</p>
</li>
<li>
<p><strong>v3.13</strong> &mdash; This version adds data from newly added judicial financial disclosure documents. This data is now included in a series of new endpoints to explore financial disclosures. For example, you can filter by gifts received by a specific federal judge or district.</p>
Expand Down
4 changes: 2 additions & 2 deletions cl/api/templates/rest-docs-vlatest.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% load static %}
{% load extras %}

{% block title %}REST API, v3.14 &ndash; CourtListener.com{% endblock %}
{% block title %}REST API, v3.15 &ndash; CourtListener.com{% endblock %}
{% block description %}REST API for federal and state opinions, PACER data, the searchable RECAP Archive, and oral argument recordings. Provided by Free Law Project, a 501(c)(3) non-profit. Please donate to support this service.{% endblock %}
{% block og_description %}REST API for federal and state opinions, PACER data, the searchable RECAP Archive, and oral argument recordings. Provided by Free Law Project, a 501(c)(3) non-profit. Please donate to support this service.{% endblock %}

Expand All @@ -17,7 +17,7 @@
{% include "includes/toc_sidebar.html" %}
</div>
<div class="col-xs-12 col-md-8 col-lg-6">
<h1 id="about">REST API &ndash; v3.14</h1>
<h1 id="about">REST API &ndash; v3.15</h1>

<h2 id="api-overview">Getting Started &amp; Overview</h2>

Expand Down
3 changes: 3 additions & 0 deletions cl/search/api_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ class OpinionSerializer(DynamicFieldsMixin, HyperlinkedModelSerializerWithId):
absolute_url = serializers.CharField(
source="get_absolute_url", read_only=True
)
cluster_id = serializers.ReadOnlyField()
cluster = serializers.HyperlinkedRelatedField(
many=False,
view_name="opinioncluster-detail",
queryset=OpinionCluster.objects.all(),
style={"base_template": "input.html"},
)
author_id = serializers.ReadOnlyField()
author = serializers.HyperlinkedRelatedField(
many=False,
view_name="person-detail",
Expand Down Expand Up @@ -217,6 +219,7 @@ class OpinionClusterSerializer(
queryset=Person.objects.all(),
style={"base_template": "input.html"},
)
docket_id = serializers.ReadOnlyField()
docket = serializers.HyperlinkedRelatedField(
many=False,
view_name="docket-detail",
Expand Down
5 changes: 5 additions & 0 deletions cl/search/api_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import waffle
from rest_framework import pagination, permissions, response, status, viewsets
from rest_framework.pagination import PageNumberPagination

from cl.api.utils import CacheListMixin, LoggingMixin, RECAPUsersReadOnly
from cl.search import api_utils
Expand Down Expand Up @@ -119,6 +120,10 @@ class CourtViewSet(LoggingMixin, viewsets.ModelViewSet):
queryset = Court.objects.exclude(
jurisdiction=Court.TESTING_COURT
).order_by("position")
# Our default pagination blocks deep pagination by overriding
# PageNumberPagination. Allow deep pagination, by overriding our default
# with this base class.
pagination_class = PageNumberPagination


class OpinionClusterViewSet(LoggingMixin, viewsets.ModelViewSet):
Expand Down

0 comments on commit 347b90b

Please sign in to comment.