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