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

Don't break on missing categories #475

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions inbox/models/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ def most_recent_sent_date(self):
sorted_messages = sorted(
self.messages, key=lambda m: m.received_date, reverse=True
)
for m in sorted_messages:
if "sent" in [c.name for c in m.categories] or (m.is_draft and m.is_sent):
sent_recent_date = m.received_date
for message in sorted_messages:
if "sent" in [
category.name for category in message.categories if category
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if category is the part that I added to filter out None categories that come from missing categories because of missing FK.

] or (message.is_draft and message.is_sent):
sent_recent_date = message.received_date
return sent_recent_date

@property
Expand Down