Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value limits to GPS coordinates for Configurations #410

Merged
merged 5 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions publicdb/default/management/commands/createfakedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ def handle(*args, **options):
]

for summary in summaries:
histograms_factories.EventtimeHistogramFactory(summary=summary)
histograms_factories.AzimuthHistogramFactory(summary=summary)
histograms_factories.ZenithHistogramFactory(summary=summary)
histograms_factories.BarometerDatasetFactory(summary=summary)
histograms_factories.ConfigurationFactory(summary=summary)
histograms_factories.DetectorTimingOffsetFactory(summary=summary)
histograms_factories.EventtimeHistogramFactory(summary=summary)
histograms_factories.PulseheightHistogramFactory(summary=summary)
histograms_factories.PulseintegralHistogramFactory(summary=summary)
histograms_factories.SingleslowHistogramFactory(summary=summary)
histograms_factories.SingleshighHistogramFactory(summary=summary)
histograms_factories.TemperatureDatasetFactory(summary=summary)
histograms_factories.BarometerDatasetFactory(summary=summary)
histograms_factories.SinglesratelowDatasetFactory(summary=summary)
histograms_factories.SingleslowHistogramFactory(summary=summary)
histograms_factories.SinglesratehighDatasetFactory(summary=summary)
histograms_factories.ConfigurationFactory(summary=summary)
histograms_factories.DetectorTimingOffsetFactory(summary=summary)
histograms_factories.SinglesratelowDatasetFactory(summary=summary)
histograms_factories.TemperatureDatasetFactory(summary=summary)
histograms_factories.ZenithHistogramFactory(summary=summary)
29 changes: 20 additions & 9 deletions publicdb/histograms/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,27 @@ def update_config(summary):

for config in configs[summary.num_config :]:
new_config = Configuration(summary=summary)
for var in vars(new_config):
if var in ['summary', 'id', 'summary_id'] or var[0] == '_':
pass
elif var in ['mas_version', 'slv_version']:
vars(new_config)[var] = blobs[config[var]]
elif var == 'timestamp':
ts = datetime.datetime.utcfromtimestamp(config[var])
vars(new_config)[var] = ts
for field in new_config._meta.get_fields():
field_name = field.name
if field_name in ['summary', 'id']:
continue
elif field_name in ['mas_version', 'slv_version']:
value = blobs[config[field_name]]
elif field_name == 'timestamp':
value = datetime.datetime.utcfromtimestamp(config[field_name])
elif field_name == 'gps_latitude':
if -90 <= config[field_name] <= 90:
value = config[field_name]
else:
value = 0
elif field_name == 'gps_longitude':
if -360 <= config[field_name] <= 360:
value = config[field_name]
else:
value = 0
else:
vars(new_config)[var] = config[var]
value = config[field_name]
setattr(new_config, field_name, value)
django.db.close_old_connections()
new_config.save()

Expand Down
4 changes: 1 addition & 3 deletions publicdb/inforecords/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import socket

from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
Expand All @@ -11,7 +9,7 @@ def create_datastore_config(request):
"""Create the datastore configuration"""

# Limit access to only allow access from the Datastore server
if socket.gethostbyaddr(request.META['REMOTE_ADDR'])[0] != settings.DATASTORE_HOST:
if request.META['REMOTE_HOST'] != settings.DATASTORE_HOST:
raise PermissionDenied

return render(
Expand Down
2 changes: 1 addition & 1 deletion publicdb/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
DATASTORE_PROXY = 'http://datastore:8002'

# Datastore host name
DATASTORE_HOST = 'publicdb_datastore_1.publicdb_default'
DATASTORE_HOST = 'datastore'
4 changes: 4 additions & 0 deletions tests/factories/histograms_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class NetworkHistogramFactory(factory.django.DjangoModelFactory):

class Meta:
model = models.NetworkHistogram
django_get_or_create = ('network_summary', 'type')


class CoincidencetimeHistogramFactory(NetworkHistogramFactory):
Expand All @@ -190,6 +191,7 @@ class DailyHistogramFactory(factory.django.DjangoModelFactory):

class Meta:
model = models.DailyHistogram
django_get_or_create = ('summary', 'type')


class EventtimeHistogramFactory(DailyHistogramFactory):
Expand Down Expand Up @@ -249,6 +251,7 @@ class DailyDatasetFactory(factory.django.DjangoModelFactory):

class Meta:
model = models.DailyDataset
django_get_or_create = ('summary', 'type')


class TemperatureDatasetFactory(DailyDatasetFactory):
Expand Down Expand Up @@ -301,3 +304,4 @@ class StationTimingOffsetFactory(factory.django.DjangoModelFactory):

class Meta:
model = models.StationTimingOffset
django_get_or_create = ('ref_summary', 'summary')
Loading