mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
export-search: Joins to usermessages may require adding a distinct.
(cherry picked from commit e703f65198)
This commit is contained in:
committed by
Tim Abbott
parent
a9417eb4fe
commit
f5097ce7ed
@@ -143,6 +143,7 @@ This is most often used for legal compliance.
|
||||
|
||||
realm = self.get_realm(options)
|
||||
assert realm is not None
|
||||
need_distinct = False
|
||||
limits = Q()
|
||||
|
||||
limits = reduce(
|
||||
@@ -168,6 +169,7 @@ This is most often used for legal compliance.
|
||||
limits &= Q(
|
||||
usermessage__user_profile_id__in=[user_profile.id for user_profile in user_profiles]
|
||||
)
|
||||
need_distinct = len(user_profiles) > 1
|
||||
elif options["sender"]:
|
||||
limits &= reduce(
|
||||
or_,
|
||||
@@ -217,6 +219,8 @@ This is most often used for legal compliance.
|
||||
)
|
||||
.order_by("date_sent")
|
||||
)
|
||||
if need_distinct:
|
||||
messages_query = messages_query.distinct("id")
|
||||
print(f"Exporting {len(messages_query)} messages...")
|
||||
|
||||
@lru_cache(maxsize=1000)
|
||||
|
||||
Reference in New Issue
Block a user