Skip to content

Commit

Permalink
feat: update new notes with known tweet info
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed May 14, 2024
1 parent b480187 commit deb469d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x_notes/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def urlize(inp: str) -> str:


def get_notes(notes: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
notes_by_tweet_id = {
note["tweet_id"]: note
for note in notes.items()
if "dl" in note
}
notes = {
k: v
for k, v in notes.items()
Expand All @@ -42,6 +47,8 @@ def get_notes(notes: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
continue
if row["classification"] == "NOT_MISLEADING":
# exclude "not misleading" notes
if note_id in notes:
del notes[note_id]
continue
reasons = ", ".join([v for k, v in reasons_lookup.items() if bool(int(row[k]))])
note = notes.get(note_id, {})
Expand All @@ -55,5 +62,10 @@ def get_notes(notes: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
"created_at": created_at,
}
)
if "dl" not in note and note["tweet_id"] in notes_by_tweet_id:
tweet_note = notes_by_tweet_id[note["tweet_id"]]
for k in ["dl", "deleted", "lang", "user", "tweet"]:
if k in tweet_note:
note[k] = tweet_note[k]
notes[note_id] = note
return notes

0 comments on commit deb469d

Please sign in to comment.