Skip to content

Commit

Permalink
dec release 2
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegerrits committed Dec 17, 2024
1 parent cc4c2a7 commit 13aa52a
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 136 deletions.
54 changes: 20 additions & 34 deletions src/components/ObservationDetailsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,53 +205,42 @@
<span class="visually-hidden">Volgende</span>
</button>
</div>

<div class="row mb-2">
<label class="col-4 col-form-label">Type</label>
<div class="col-8">
<select v-if="selectedObservation.nest_type !== undefined"
v-model="editableObservation.nest_type" class="form-select"
:disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in nestTypeEnum" :key="value" :value="value">{{
label }}</option>
</select>
<p class="form-control-plaintext">
{{ selectedObservation.nest_type ? nestTypeEnum[selectedObservation.nest_type] :
'Geen' }}
</p>
</div>
</div>
<div class="row mb-2">
<label class="col-4 col-form-label">Locatie</label>
<div class="col-8">
<select v-if="selectedObservation.nest_location !== undefined"
v-model="editableObservation.nest_location" class="form-select"
:disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in nestLocationEnum" :key="value" :value="value">
{{ label }}</option>
</select>
<p class="form-control-plaintext">
{{ selectedObservation.nest_location ?
nestLocationEnum[selectedObservation.nest_location] :
'Geen' }}
</p>
</div>
</div>
<div class="row mb-2">
<label class="col-4 col-form-label">Grootte</label>
<div class="col-8">
<select v-if="selectedObservation.nest_size !== undefined"
v-model="editableObservation.nest_size" class="form-select"
:disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in nestSizeEnum" :key="value" :value="value">{{
label }}</option>
</select>
<p class="form-control-plaintext">
{{ selectedObservation.nest_size ? nestSizeEnum[selectedObservation.nest_size] :
'Geen' }}
</p>
</div>
</div>
<div class="row mb-2">
<label class="col-4 col-form-label">Hoogte</label>
<div class="col-8">
<select v-if="selectedObservation.nest_height !== undefined"
v-model="editableObservation.nest_height" class="form-select"
:disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in nestHeightEnum" :key="value" :value="value">{{
label }}</option>
</select>
<p class="form-control-plaintext">
{{ selectedObservation.nest_height ?
nestHeightEnum[selectedObservation.nest_height] :
'Geen' }}
</p>
</div>
</div>
<div class="row mb-2">
Expand Down Expand Up @@ -322,7 +311,8 @@
<div class="row mb-2">
<label class="col-4 col-form-label">Telefoon</label>
<div class="col-8">
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}</p>
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}
</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -498,10 +488,6 @@ export default {
};
const editableFields = [
"nest_height",
"nest_size",
"nest_location",
"nest_type",
"observation_datetime",
"eradication_date",
"admin_notes",
Expand Down
35 changes: 32 additions & 3 deletions vespadb/observations/tasks/observation_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
from datetime import datetime
from difflib import get_close_matches
from typing import Any, cast

import pytz
Expand All @@ -28,8 +27,10 @@

mapping_dict: dict[int, dict[str, str]] = {
329: {
"hoger_dan_4_meter": "hoger_dan_4_meter",
"Hoger dan 4 meter": "hoger_dan_4_meter",
"Higher than 4 meters": "hoger_dan_4_meter",
"lager_dan_4_meter": "lager_dan_4_meter",
"Lager dan 4 meter": "lager_dan_4_meter",
"Lower than 4 meters": "lager_dan_4_meter",
},
Expand All @@ -39,7 +40,7 @@
"Larger than 25cm": "groter_dan_25_cm",
"Smaller than 25cm": "kleiner_dan_25_cm",
},
331 : {
331: {
"Binnen, in gebouw of constructie": "binnen_in_gebouw_of_constructie",
"Buiten, maar overdekt door constructie": "buiten_maar_overdekt_door_constructie",
"Buiten, natuurlijk overdekt": "buiten_natuurlijk_overdekt",
Expand All @@ -50,7 +51,28 @@
"Outside, natural cover": "buiten_natuurlijk_overdekt",
"Outside, uncovered in a tree or bush": "buiten_onbedekt_in_boom_of_struik",
"Outside, uncovered on building": "buiten_onbedekt_op_gebouw",
}
},
368: {
"Actief embryonaal nest": "actief_embryonaal_nest",
"Actief embryonaal nest (van maart tot eind juni, nest met enkel koningin)": "actief_embryonaal_nest",
"Actief primair nest": "actief_primair_nest",
"Actief primair nest (van juni tot eind november, nest met werksters op lage hoogte (tot 6 meter))": "actief_primair_nest",
"Actief secundair nest": "actief_secundair_nest",
"Actief secundair nest (van augustus tot eind november, nest met werksters op grote hoogte (tot 30m))": "actief_secundair_nest",
"Active embryonic nest": "actief_embryonaal_nest",
"Active embryonic nest (from march to the end of june, nest with queen only)": "actief_embryonaal_nest",
"Active primary nest": "actief_primair_nest",
"Active primary nest (from june to the end of november, nest with workers at low altitude (up to 6m))": "actief_primair_nest",
"Active secondary nest": "actief_secundair_nest",
"Active secondary nest (from aug. to the end of nov., nest with workers at high altitude (up to 30m))": "actief_secundair_nest",
"Inactief/leeg nest (typisch tijdens wintermaanden, een leeg nest hoog in een boom)": "inactief_leeg_nest",
"Inactief/leeg nest (typisch tijdens wintermaanden, een leeg netst oog in een boom)": "inactief_leeg_nest",
"Inactive/empty nest": "inactief_leeg_nest",
"Inactive/empty nest (typically during the winter months, an empty nest high in a tree)": "inactief_leeg_nest",
"Potential nest": None,
"Potentieel nest": None,
"Potentieel nest (onzeker van de soort)": None,
},
}

ENUMS_MAPPING: dict[str, type[TextChoices]] = {
Expand All @@ -67,6 +89,7 @@
329: "nest_height",
330: "nest_size",
331: "nest_location",
368: "nest_type",
}
# Literal mapping functions
def map_nest_height_attribute_to_enum(value: str) -> Any | None:
Expand All @@ -81,6 +104,10 @@ def map_nest_location_attribute_to_enum(value: str) -> str | None:
"""Maps Nest location values to enums based on literal mapping."""
return mapping_dict[331].get(value.strip())

def map_nest_type_attribute_to_enum(value: str) -> str | None:
"""Maps Nest location values to enums based on literal mapping."""
return mapping_dict[368].get(value.strip())

def map_attribute_to_enum(attribute_id: int, value: str) -> str | None:
"""
Maps a single attribute value to an enum using literal mapping functions.
Expand All @@ -91,6 +118,8 @@ def map_attribute_to_enum(attribute_id: int, value: str) -> str | None:
return map_nest_size_attribute_to_enum(value)
elif attribute_id == 331:
return map_nest_location_attribute_to_enum(value)
elif attribute_id == 368:
return map_nest_type_attribute_to_enum(value)
else:
return None

Expand Down
2 changes: 1 addition & 1 deletion vespadb/observations/tasks/observation_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@ def fetch_and_update_observations(self: Task, since_week: int | None = None, dat

logger.info("Finished processing observations")
manage_observations_visibility(token)
logger.info("Finished managing observations visibility")
logger.info("Finished managing observations visibility")
Loading

0 comments on commit 13aa52a

Please sign in to comment.