-
Notifications
You must be signed in to change notification settings - Fork 31
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
Reducing query counts on processing and removing 1+N queries in Admin View #118
base: master
Are you sure you want to change the base?
Changes from all commits
cdfd0e3
a1a92aa
195a687
64f4f28
75fece1
a621164
1ea0840
1de80ce
71cb08e
42dfc7c
c3287fa
62099a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,9 +342,12 @@ def create_from_as2message( | |
if not filename: | ||
filename = f"{uuid4()}.msg" | ||
message.headers.save( | ||
name=f"{filename}.header", content=ContentFile(as2message.headers_str) | ||
name=f"{filename}.header", | ||
content=ContentFile(as2message.headers_str), | ||
save=False, | ||
) | ||
message.payload.save(name=filename, content=ContentFile(payload)) | ||
message.payload.save(name=filename, content=ContentFile(payload), save=False) | ||
message.save() | ||
|
||
# Save the payload to the inbox folder | ||
full_filename = None | ||
|
@@ -460,6 +463,13 @@ def status_icon(self): | |
|
||
def send_message(self, header, payload): | ||
"""Send the message to the partner""" | ||
|
||
if self.organization_id and self.partner_id: | ||
self.organization = self.organization or Organization.objects.get( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reason for this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have noted that under certain circumstances (i.e. update_or_create) will not keep the related object inside the model. So, in case that this is happening, then we pull it once more, but we are not pulling it, when it exists already, thus not executing another query. |
||
id=self.organization_id | ||
) | ||
self.partner = self.partner or Partner.objects.get(id=self.partner_id) | ||
|
||
logger.info( | ||
f'Sending message {self.message_id} from organization "{self.organization}" ' | ||
f'to partner "{self.partner}".' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment on why you are doing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add.