Skip to content

Commit

Permalink
Updates 4.4.6 (#117)
Browse files Browse the repository at this point in the history
* Update hubeau harvester API

* Update 'download request' to just 'download'

* Fix error aware

* Update ehyd harvester
  • Loading branch information
meomancer authored Feb 29, 2024
1 parent e802410 commit 40746ec
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 204 deletions.
9 changes: 4 additions & 5 deletions harvesters/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,9 @@

class HarvesterAttributeInline(admin.TabularInline):
model = HarvesterAttribute
readonly_fields = ('harvester', 'name')
readonly_fields = ('harvester',)
extra = 0

def has_add_permission(self, request, obj=None):
return False


class HarvesterLogInline(admin.TabularInline):
model = HarvesterLog
Expand Down Expand Up @@ -130,7 +127,9 @@ class HarvesterAdmin(admin.ModelAdmin):
form = HarvesterForm
inlines = [HarvesterAttributeInline, HarvesterLogInline]
list_display = (
'id', 'name', 'organisation', 'is_run', 'active', 'harvester_class', 'last_run')
'id', 'name', 'organisation', 'is_run', 'active', 'harvester_class',
'last_run'
)
list_editable = ('active',)
actions = (harvest_data,)

Expand Down
26 changes: 20 additions & 6 deletions harvesters/harvester/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from django.utils import timezone

from gwml2.harvesters.models.harvester import (
Harvester, HarvesterLog, RUNNING,
ERROR, DONE, HarvesterWellData
HarvesterLog, RUNNING, ERROR,
DONE, HarvesterWellData, Harvester, HarvesterAttribute
)
from gwml2.models.general import Quantity, Unit
from gwml2.models.term import TermFeatureType
Expand All @@ -25,7 +25,7 @@
from gwml2.signals.well import post_save_measurement_for_cache
from gwml2.tasks.data_file_cache import generate_data_well_cache
from gwml2.tasks.well import generate_measurement_cache
from gwml2.utilities import temp_disconnect_signal
from gwml2.utilities import temp_disconnect_signal, make_aware_local

User = get_user_model()

Expand Down Expand Up @@ -239,7 +239,7 @@ def _save_measurement(
try:
obj, created = model.objects.get_or_create(
well=harvester_well_data.well,
time=time,
time=make_aware_local(time),
parameter=defaults.get('parameter', None),
defaults=defaults
)
Expand Down Expand Up @@ -267,8 +267,22 @@ def _save_measurement(
obj.save()
return obj

def post_processing_well(self, well: Well):
def post_processing_well(
self, well: Well, generate_country_cache: bool = True
):
"""Specifically for processing cache after procesing well."""
print(f'Generate cache for {well.original_id}')
well.update_metadata()
generate_measurement_cache(well.id)
generate_data_well_cache(well.id)
generate_data_well_cache(
well.id, generate_country_cache=generate_country_cache
)

def update_attribute(self, key: str, value):
"""Update attribute."""
attr, _ = HarvesterAttribute.objects.get_or_create(
harvester=self.harvester,
name=key
)
attr.value = value
attr.save()
Loading

0 comments on commit 40746ec

Please sign in to comment.