freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.
https://www.courtlistener.com
Other
552 stars 151 forks source link

Clean up Main documents with attachment number 0 #4599

Open albertisfu opened 1 month ago

albertisfu commented 1 month ago

Once we stop merging documents with attachment 0, we should clean up Main documents with attachment_number 0 and set it to None.

For this, we can use the following query as a base:

RECAPDocument.objects.filter(
    document_type=RECAPDocument.PACER_DOCUMENT,
    document_number__isnull=False,
    attachment_number=0
)

We also have Main documents with attachment_number 1 (and probably other numbers), which we can review to determine if they need to be cleaned up as well.

RECAPDocument.objects.filter(
    document_type=RECAPDocument.PACER_DOCUMENT,
    document_number__isnull=False,
    attachment_number=1
)