Avoid empty notifications when no effective modifications (#1074)
Fix TG-5341remotes/origin/3.4.0rc 3.1.2
parent
d3a754997b
commit
b05da06ab2
|
@ -245,14 +245,20 @@ def send_sync_notifications(notification_id):
|
|||
"""
|
||||
|
||||
notification = HistoryChangeNotification.objects.select_for_update().get(pk=notification_id)
|
||||
# If the last modification is too recent we ignore it
|
||||
# If the last modification is too recent we ignore it for the time being
|
||||
now = timezone.now()
|
||||
time_diff = now - notification.updated_datetime
|
||||
if time_diff.seconds < settings.CHANGE_NOTIFICATIONS_MIN_INTERVAL:
|
||||
return
|
||||
|
||||
history_entries = tuple(notification.history_entries.all().order_by("created_at"))
|
||||
history_entries = squash_history_entries(history_entries)
|
||||
history_entries = list(squash_history_entries(history_entries))
|
||||
|
||||
# If there are no effective modifications we can delete this notification
|
||||
# without further processing
|
||||
if notification.history_type == HistoryType.change and not history_entries:
|
||||
notification.delete()
|
||||
return
|
||||
|
||||
obj, _ = get_last_snapshot_for_key(notification.key)
|
||||
obj_class = get_model_from_key(obj.key)
|
||||
|
|
|
@ -359,7 +359,7 @@ def test_send_notifications_using_services_method_for_user_stories(settings, mai
|
|||
history_change = f.HistoryEntryFactory.create(
|
||||
project=project,
|
||||
user={"pk": member1.user.id},
|
||||
comment="",
|
||||
comment="test:change",
|
||||
type=HistoryType.change,
|
||||
key="userstories.userstory:{}".format(us.id),
|
||||
is_hidden=False,
|
||||
|
@ -454,7 +454,7 @@ def test_send_notifications_using_services_method_for_tasks(settings, mail):
|
|||
history_change = f.HistoryEntryFactory.create(
|
||||
project=project,
|
||||
user={"pk": member1.user.id},
|
||||
comment="",
|
||||
comment="test:change",
|
||||
type=HistoryType.change,
|
||||
key="tasks.task:{}".format(task.id),
|
||||
is_hidden=False,
|
||||
|
@ -549,7 +549,7 @@ def test_send_notifications_using_services_method_for_issues(settings, mail):
|
|||
history_change = f.HistoryEntryFactory.create(
|
||||
project=project,
|
||||
user={"pk": member1.user.id},
|
||||
comment="",
|
||||
comment="test:change",
|
||||
type=HistoryType.change,
|
||||
key="issues.issue:{}".format(issue.id),
|
||||
is_hidden=False,
|
||||
|
@ -644,7 +644,7 @@ def test_send_notifications_using_services_method_for_wiki_pages(settings, mail)
|
|||
history_change = f.HistoryEntryFactory.create(
|
||||
project=project,
|
||||
user={"pk": member1.user.id},
|
||||
comment="",
|
||||
comment="test:change",
|
||||
type=HistoryType.change,
|
||||
key="wiki.wikipage:{}".format(wiki.id),
|
||||
is_hidden=False,
|
||||
|
|
Loading…
Reference in New Issue