Skip to content

Commit

Permalink
Merge pull request #548 from ODM2/develop
Browse files Browse the repository at this point in the history
Release 0.12.1 Hotfixes
  • Loading branch information
aufdenkampe authored Jan 6, 2022
2 parents a581a4d + b460063 commit 932d2ce
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 115 deletions.
4 changes: 4 additions & 0 deletions src/WebSDL/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'hydroshare_util.middleware.AuthMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
'django_cprofile_middleware.middleware.ProfilerMiddleware',
]

DJANGO_CPROFILE_MIDDLEWARE_REQUIRE_STAFF = False

REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
Expand Down Expand Up @@ -120,6 +123,7 @@
'HOST': database['host'] if 'host' in database else '',
'PORT': database['port'] if 'port' in database else '',
'OPTIONS': database['options'] if 'options' in database else {},
'CONN_MAX_AGE': 0,
'TEST': database['test'] if 'test' in database else {},
}

Expand Down
2 changes: 1 addition & 1 deletion src/dataloaderinterface/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

_dbsettings = settings.DATABASES['odm2']
_connection_str = f"postgresql://{_dbsettings['USER']}:{_dbsettings['PASSWORD']}@{_dbsettings['HOST']}:{_dbsettings['PORT']}/{_dbsettings['NAME']}"
_db_engine = sqlalchemy.create_engine(_connection_str)
_db_engine = sqlalchemy.create_engine(_connection_str, pool_size=30)

def get_result_timeseries_recent(request_data:Dict[str,Any]) -> str:
result_id = int(request_data['resultid'])
Expand Down
4 changes: 2 additions & 2 deletions src/dataloaderinterface/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Unit, Medium, Organization
from dataloaderinterface.querysets import SiteRegistrationQuerySet, SensorOutputQuerySet


class SiteRegistration(models.Model):
registration_id = models.AutoField(primary_key=True, db_column='RegistrationID')
registration_token = models.CharField(max_length=64, editable=False, db_column='RegistrationToken', unique=True, default=uuid4)
Expand Down Expand Up @@ -60,7 +59,8 @@ def latest_measurement(self):
return
try:
last_updated_sensor = [sensor for sensor in self.sensors.all() if sensor.last_measurement.pk == self.latest_measurement_id].pop()
except IndexError:
#except IndexError:
except:
return None

return last_updated_sensor.last_measurement
Expand Down
41 changes: 23 additions & 18 deletions src/dataloaderinterface/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from dataloader.models import SamplingFeature, Site, Annotation, SamplingFeatureAnnotation, SpatialReference, Action, \
Method, Result, ProcessingLevel, TimeSeriesResult, Unit
from dataloaderinterface.models import SiteRegistration, SiteSensor
from tsa.helpers import TimeSeriesAnalystHelper

#PRT - deprecated
#from tsa.helpers import TimeSeriesAnalystHelper


@receiver(pre_save, sender=SiteRegistration)
Expand Down Expand Up @@ -78,12 +80,13 @@ def handle_site_registration_post_save(sender, instance, created, update_fields=
sampling_feature.annotations.filter(annotation_code='closest_town').update(annotation_text=instance.closest_town or '')


@receiver(post_save, sender=SiteRegistration)
def handle_site_registration_tsa_post_save(sender, instance, created, update_fields=None, **kwargs):
if created:
return
helper = TimeSeriesAnalystHelper()
helper.update_series_from_site(instance)
#PRT - deprecated
#@receiver(post_save, sender=SiteRegistration)
#def handle_site_registration_tsa_post_save(sender, instance, created, update_fields=None, **kwargs):
# if created:
# return
# helper = TimeSeriesAnalystHelper()
# helper.update_series_from_site(instance)


@receiver(post_delete, sender=SiteRegistration)
Expand Down Expand Up @@ -144,13 +147,14 @@ def handle_sensor_post_save(sender, instance, created, update_fields=None, **kwa
TimeSeriesResult.objects.filter(result_id=instance.result_id).update(z_location=instance.height)


@receiver(post_save, sender=SiteSensor)
def handle_sensor_tsa_post_save(sender, instance, created, update_fields=None, **kwargs):
helper = TimeSeriesAnalystHelper()
if created:
helper.create_series_from_sensor(instance)
else:
helper.update_series_from_sensor(instance)
#PRT - deprecated
#@receiver(post_save, sender=SiteSensor)
#def handle_sensor_tsa_post_save(sender, instance, created, update_fields=None, **kwargs):
# helper = TimeSeriesAnalystHelper()
# if created:
# helper.create_series_from_sensor(instance)
# else:
# helper.update_series_from_sensor(instance)


@receiver(post_delete, sender=SiteSensor)
Expand All @@ -159,7 +163,8 @@ def handle_sensor_post_delete(sender, instance, **kwargs):
result and result.feature_action.action.delete()


@receiver(post_delete, sender=SiteSensor)
def handle_sensor_tsa_post_delete(sender, instance, **kwargs):
helper = TimeSeriesAnalystHelper()
helper.delete_series_for_sensor(instance)
#PRT - deprecated
#@receiver(post_delete, sender=SiteSensor)
#def handle_sensor_tsa_post_delete(sender, instance, **kwargs):
# helper = TimeSeriesAnalystHelper()
# helper.delete_series_for_sensor(instance)
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function updatePlotDateRange(min, max) {
}
if (max != null) {
$('#dpd2').val(dateToString(max));
max = max.getTime();
max = max.getTime() + 86399; //select end of day as end point
}
_chart.xAxis[0].update({'min':min, 'max':max});
_chart.xAxis[0].setExtremes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ <h6 class="page-title grid" style="grid-template-columns: auto auto;">
<div class="col-12">
<i class="link-card-icon material-icons icon-blue">show_chart</i>
<div>
<h5 class="link-card-title">Time Series Analyst</h5>
<h5 class="link-card-title">Time Series Visualization</h5>
<p class="text-muted">View data for this site.</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/dataloaderinterface/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def is_stale(value, default):
def divide(value, arg):
try:
return int(value) / int(arg) if int(arg) != 0 else 0
except (ValueError, ZeroDivisionError):
except (TypeError, ValueError, ZeroDivisionError):
return None


Expand Down
Loading

0 comments on commit 932d2ce

Please sign in to comment.