Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jan 5, 2024

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from devded January 5, 2024 17:32

def save(self, *args, **kwargs):
if self.full_name == "" or self.full_name == None:
if self.full_name == "" or self.full_name is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function Profile.save refactored with the following changes:

def sender_profile(self):
sender_profile = Profile.objects.get(user=self.sender)
return sender_profile
return Profile.objects.get(user=self.sender)
Copy link
Author

Choose a reason for hiding this comment

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

Function ChatMessage.sender_profile refactored with the following changes:

Comment on lines 77 to 78
reciever_profile = Profile.objects.get(user=self.reciever)
return reciever_profile
return Profile.objects.get(user=self.reciever)
Copy link
Author

Choose a reason for hiding this comment

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

Function ChatMessage.reciever_profile refactored with the following changes:

self.Meta.depth = 0
else:
self.Meta.depth = 3
self.Meta.depth = 0 if request and request.method=='POST' else 3
Copy link
Author

Choose a reason for hiding this comment

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

Function ProfileSerializer.__init__ refactored with the following changes:

Comment on lines -93 to +90
if request and request.method=='POST':
self.Meta.depth = 0
else:
self.Meta.depth = 2
self.Meta.depth = 0 if request and request.method=='POST' else 2
Copy link
Author

Choose a reason for hiding this comment

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

Function MessageSerializer.__init__ refactored with the following changes:


todo = Todo.objects.filter(user=user)
return todo
return Todo.objects.filter(user=user)
Copy link
Author

Choose a reason for hiding this comment

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

Function TodoListView.get_queryset refactored with the following changes:

Comment on lines -73 to +72
todo = Todo.objects.get(id=todo_id, user=user)

return todo
return Todo.objects.get(id=todo_id, user=user)
Copy link
Author

Choose a reason for hiding this comment

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

Function TodoDetailView.get_object refactored with the following changes:

Comment on lines -101 to -117
messages = ChatMessage.objects.filter(
id__in = Subquery(
return ChatMessage.objects.filter(
id__in=Subquery(
User.objects.filter(
Q(sender__reciever=user_id) |
Q(reciever__sender=user_id)
).distinct().annotate(
Q(sender__reciever=user_id) | Q(reciever__sender=user_id)
)
.distinct()
.annotate(
last_msg=Subquery(
ChatMessage.objects.filter(
Q(sender=OuterRef('id'),reciever=user_id) |
Q(reciever=OuterRef('id'),sender=user_id)
).order_by('-id')[:1].values_list('id',flat=True)
Q(sender=OuterRef('id'), reciever=user_id)
| Q(reciever=OuterRef('id'), sender=user_id)
)
.order_by('-id')[:1]
.values_list('id', flat=True)
)
).values_list('last_msg', flat=True).order_by("-id")
)
.values_list('last_msg', flat=True)
.order_by("-id")
)
).order_by("-id")

return messages
Copy link
Author

Choose a reason for hiding this comment

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

Function MyInbox.get_queryset refactored with the following changes:

Comment on lines -125 to +128
messages = ChatMessage.objects.filter(sender__in=[sender_id, reciever_id], reciever__in=[sender_id, reciever_id])
return messages
return ChatMessage.objects.filter(
sender__in=[sender_id, reciever_id],
reciever__in=[sender_id, reciever_id],
)
Copy link
Author

Choose a reason for hiding this comment

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

Function GetMessages.get_queryset refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant