Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More enhancements to "I'm now following" posts #332

Closed
mlissner opened this issue Jul 25, 2023 · 14 comments · Fixed by #530
Closed

More enhancements to "I'm now following" posts #332

mlissner opened this issue Jul 25, 2023 · 14 comments · Fixed by #530

Comments

@mlissner
Copy link
Member

I just added a new case for the bot to follow and it dutifully sent out an "I'm now following..." tweet. That's good, but there's a bit of missing context: The bot wasn't following the case until just recently, even though the case was opened over a year ago.

We should add a date stamp to the "I'm now following..." tweets for any case that's older than a month. This should be easy. Just get the date_filed field from the docket object via the API, do a comparison, and then add that bit of context, if needed.

The NYT times does this on its older articles. When you read them, there's a warning at the top that they're old. I think the Guardian does something like this too.

@mlissner mlissner changed the title Include the date on old cases when newly followed More enhancements to "I'm now following" posts Aug 3, 2023
@mlissner
Copy link
Member Author

mlissner commented Aug 3, 2023

Another change we should do is to include the initial complaint, not just photos of it. So, it should say:

Docket: xyz

Complaint: xyz

Context: xyz

In bankruptcy cases (I'm sorry, not sorry), these are called the "petition", so we'll have:

Docket: xyz

Petition: zyx

Context: sdj

I think we still have space for that!

This came up recently when somebody replied to our "I'm now following..." post with a link to the complaint. I was like, what?

@TheCleric
Copy link
Contributor

@mlissner looking at this, but I have a question. For something like enqueue_posts_for_new_case it's going off the Subscription for the case. Do we want to:

  1. start saving the date_filed there (and possibly backfill it as we go)
  2. or just make a call out to CL every time to get the date_filed

Option 1 seems like the better one to me, but I'm not sure how you folks feel about messing with database schema (and potentially ugly backfill code).

@mlissner
Copy link
Member Author

Yeah, good questions, we could:

  • Pass the date_filed into the method, if we have it.
  • Cal out to CL within the method
  • Add it to the Subscription object

I think tweaking the DB and taking the third option is fine. We don't need to backfill, and it keeps the python code tidy. Works for me.

@ERosendo, what do you think?

@TheCleric
Copy link
Contributor

@mlissner for your other request, how do I trace a new case back to its initial complaint?

Would it just be the earliest item CL with the same docket#? (Sorry, not a lawyer 😆)

As well I'm assuming that you wouldn't want to show the complaint link if this item IS the initial complaint, right?

@mlissner
Copy link
Member Author

It's already finding the initial complaint and adding it as screenshots on the "I'm now following" posts. I think just use the same document as the one we're using for thumbnails? (Sorry, I forget how that area of the code works, but I think you should have the info you need already in there.)

@mlissner
Copy link
Member Author

As well I'm assuming that you wouldn't want to show the complaint link if this item IS the initial complaint, right?

Most of our "I'm now following" posts are around the time the case comes out. After that, it's in auto-drive mode, and it posts about whatever docs are filed in a given moment. So..I'm not sure I understand your question, sorry!

@TheCleric
Copy link
Contributor

Sorry for not being clear: I was referring to this:

Another change we should do is to include the initial complaint, not just photos of it. So, it should say:

So maybe I'm just confused what "initial complaint" means here?

@ERosendo
Copy link
Contributor

I'm very sorry for joining the conversation this late.

@ERosendo, what do you think?

I don't think we need to store the date_filed in the subscription model since it'll be only used for the initial announcement, we can retrieve it with an API request during the check_initial_complaint_before_posting task.

@ERosendo
Copy link
Contributor

how do I trace a new case back to its initial complaint?

@TheCleric we have a helper function named lookup_initial_complaint that can quickly retrieve the initial complaint.

def lookup_initial_complaint(docket_id: int | None) -> DocumentDict | None:
"""
Performs a GET query on /api/rest/v3/recap/
using the docket_id to get the first entry of the case.
Args:
docket_id (int): CourtListener docket identifier
Returns:
DocumentDict | None: Dictionary containing the path to get
the document or None when the entry is not available.
"""
if not docket_id:
return None
params: dict[str, str | int] = {
"docket_entry__docket__id": docket_id,
"docket_entry__entry_number": 1,
"order_by": "id",
"fields": "id,filepath_local,page_count,pacer_doc_id",
}
response = requests.get(
f"{CL_API['recap-documents']}",
params=params,
headers=auth_header(),
timeout=5,
)
response.raise_for_status()
data = response.json()
if not data["count"]:
return None
document = data["results"][0]
return {
"id": document["id"],
"filepath_local": document["filepath_local"],
"page_count": document["page_count"],
"pacer_doc_id": document["pacer_doc_id"],
}

@ERosendo
Copy link
Contributor

As well I'm assuming that you wouldn't want to show the complaint link if this item IS the initial complaint, right?

The bot uses various pre-defined messages to create posts within channels. These messages can be categorized into two main groups:

  • Initial Announcement Templates: used when the bot starts following a new case, these templates likely introduce the case to followers. Here's an example:

image

  • New Document/Entry Templates: used when new information is added to a case.

The initial complaint is typically part of the case from the beginning so the bot won't create a New Document/Entry post for it.

This issue focuses on tweaking the first group, the Initial Announcement Templates. It's easy to identify these templates because all of them include the keyword "FOLLOW_A_NEW_CASE" in their names.

@ERosendo
Copy link
Contributor

So maybe I'm just confused what "initial complaint" means here?

@TheCleric I'm pretty sure it means we should add the link to the "initial complaint" within the message template, right @mlissner?

@TheCleric
Copy link
Contributor

This issue focuses on tweaking the first group, the Initial Announcement Templates. It's easy to identify these templates because all of them include the keyword "FOLLOW_A_NEW_CASE" in their names.

This is what I was thinking. Thanks for confirming.

@TheCleric
Copy link
Contributor

Also it looks like to test any of this I would need access to the CL API. I signed up for an account and got an API key, but I don't think I have access to the right endpoints (such as the recap-documents one). I completely get not wanting to hand that out. Please advise on how you would like to handle.

@mlissner
Copy link
Member Author

Totally. I just granted access to your account. Thank you!

TheCleric added a commit to TheCleric/bigcases2 that referenced this issue May 1, 2024
TheCleric added a commit to TheCleric/bigcases2 that referenced this issue May 1, 2024
mlissner added a commit that referenced this issue May 8, 2024
feat(templates): Enhance I'm Now Following [#332]
@mlissner mlissner moved this from Bots Backlog to Done in @erosendo's backlog May 8, 2024
@mlissner mlissner linked a pull request May 8, 2024 that will close this issue
@mlissner mlissner closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants