Skip to content
Snippets Groups Projects
Commit db50cf92 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

bugfix SDC-1235

parent 52d732f3
No related branches found
No related tags found
1 merge request!345bugfix SDC-1235
Pipeline #73408 passed
...@@ -2,6 +2,7 @@ from django.db import models ...@@ -2,6 +2,7 @@ from django.db import models
from django.urls import reverse from django.urls import reverse
from django.utils import timezone from django.utils import timezone
from django.utils.timezone import datetime, timedelta from django.utils.timezone import datetime, timedelta
from django.core.exceptions import MultipleObjectsReturned
from django.conf import settings from django.conf import settings
import json import json
import logging import logging
...@@ -609,11 +610,20 @@ class Monitor(models.Model): ...@@ -609,11 +610,20 @@ class Monitor(models.Model):
# in the LatestMonitor, and update if it is newer. # in the LatestMonitor, and update if it is newer.
try: try:
latestMonitor = LatestMonitor.objects.get(name=self.name,hostname=self.hostname) latestMonitor = LatestMonitor.objects.get(name=self.name,hostname=self.hostname)
except MultipleObjectsReturned as e:
# it has happened that latest_monitoring objects failed to delete,
# which leads to a growing database and failure of the 'Hold' button on the Monitoring screen.
LatestMonitor.objects.all().delete()
try:
# carry over the metadata, if possible # carry over the metadata, if possible
latest_metadata = latestMonitor.metadata latest_metadata = latestMonitor.metadata
latestMonitor.delete() latestMonitor.delete()
except:
pass except Exception as error:
print(error)
# this combination of name and hostname didn't yet exist, create it. # this combination of name and hostname didn't yet exist, create it.
metadata = self.metadata metadata = self.metadata
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 22 Feb 2024 <p class="footer"> Version 23 Feb 2024
</div> </div>
{% include 'taskdatabase/refresh.html' %} {% include 'taskdatabase/refresh.html' %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment