8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +00:00

Remove useless query in detailed history

This commit is contained in:
Jean-Romain Garnier 2020-04-25 11:26:18 +00:00 committed by Gabriel Detraz
parent 4b33f57935
commit 7f3749dd29

View file

@ -648,11 +648,9 @@ class UserHistory(History):
# Add in "related" elements the list of objects
# that were once owned by this user
query = Q(serialized_data__contains='"user": {}'.format(user_id))
query &= ~Q(serialized_data__contains='"model": "users.user"')
self.related = (
Version.objects.all()
.filter(query)
.filter(serialized_data__contains='"user": {}'.format(user_id))
.order_by("content_type__model")
)
self.related = [RelatedHistory(v) for v in self.related]
@ -738,12 +736,9 @@ class MachineHistory(History):
self.event_type = MachineHistoryEvent
def get(self, machine_id, model):
query = Q(serialized_data__contains='"machine": {}'.format(machine_id))
query &= ~Q(serialized_data__contains='"model": "machines.machine"')
self.related = (
Version.objects.get_for_model(Interface)
.filter(query)
.filter(serialized_data__contains='"machine": {}'.format(machine_id))
.order_by("content_type__model")
)