From 97f651572b326abc7fb5d6645068d080dfce415e Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Sun, 15 Mar 2026 00:55:29 +0100 Subject: [PATCH] Add 13 structured wildlife fields to Species API nectar_value, pollen_value, wild_bee_count, wild_bee_specialist_count, butterfly_moth_count, caterpillar_host_count, caterpillar_specialist_count, hoverfly_count, beetle_count, bird_count, mammal_count, native_status, naturadb_tags --- herbapi-api/src/db/models.rs | 26 ++++++++++++++++++++++++++ herbapi-api/src/db/species.rs | 25 +++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/herbapi-api/src/db/models.rs b/herbapi-api/src/db/models.rs index 55c6bd6..f0a1fe7 100644 --- a/herbapi-api/src/db/models.rs +++ b/herbapi-api/src/db/models.rs @@ -121,6 +121,19 @@ pub struct Species { pub gbif_id: Option, pub eppo_code: Option, pub pfaf_url: Option, + pub nectar_value: Option, + pub pollen_value: Option, + pub wild_bee_count: Option, + pub wild_bee_specialist_count: Option, + pub butterfly_moth_count: Option, + pub caterpillar_host_count: Option, + pub caterpillar_specialist_count: Option, + pub hoverfly_count: Option, + pub beetle_count: Option, + pub bird_count: Option, + pub mammal_count: Option, + pub native_status: Option, + pub naturadb_tags: Option, pub primary_image_key: Option, pub source_urls: Option>, pub created_at: DateTime, @@ -169,6 +182,19 @@ pub struct CreateSpecies { pub gbif_id: Option, pub eppo_code: Option, pub pfaf_url: Option, + pub nectar_value: Option, + pub pollen_value: Option, + pub wild_bee_count: Option, + pub wild_bee_specialist_count: Option, + pub butterfly_moth_count: Option, + pub caterpillar_host_count: Option, + pub caterpillar_specialist_count: Option, + pub hoverfly_count: Option, + pub beetle_count: Option, + pub bird_count: Option, + pub mammal_count: Option, + pub native_status: Option, + pub naturadb_tags: Option, pub source_urls: Option>, } diff --git a/herbapi-api/src/db/species.rs b/herbapi-api/src/db/species.rs index 48b65c7..33067f5 100644 --- a/herbapi-api/src/db/species.rs +++ b/herbapi-api/src/db/species.rs @@ -119,11 +119,16 @@ pub async fn create(pool: &PgPool, req: &CreateSpecies) -> Result { plant_layer, nitrogen_fixer, dynamic_accumulator, dynamic_accumulator_nutrients, attracts_pollinators, attracts_beneficial_insects, wildlife_value, mulch_plant, ground_cover_quality, allelopathic, guild_role, succession_stage, heavy_metal_tolerance, - wikidata_qid, gbif_id, eppo_code, pfaf_url, source_urls) + wikidata_qid, gbif_id, eppo_code, pfaf_url, source_urls, + nectar_value, pollen_value, wild_bee_count, wild_bee_specialist_count, + butterfly_moth_count, caterpillar_host_count, caterpillar_specialist_count, + hoverfly_count, beetle_count, bird_count, mammal_count, + native_status, naturadb_tags) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16, $17,$18,$19,$20,$21,$22,$23, $24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36, - $37,$38,$39,$40,$41,$42,$43) + $37,$38,$39,$40,$41,$42,$43, + $44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56) RETURNING *" ) .bind(id).bind(&slug).bind(req.family_id).bind(&req.name_scientific) @@ -143,6 +148,12 @@ pub async fn create(pool: &PgPool, req: &CreateSpecies) -> Result { .bind(&req.succession_stage).bind(req.heavy_metal_tolerance) .bind(&req.wikidata_qid).bind(&req.gbif_id).bind(&req.eppo_code).bind(&req.pfaf_url) .bind(&req.source_urls) + .bind(req.nectar_value).bind(req.pollen_value) + .bind(req.wild_bee_count).bind(req.wild_bee_specialist_count) + .bind(req.butterfly_moth_count).bind(req.caterpillar_host_count) + .bind(req.caterpillar_specialist_count).bind(req.hoverfly_count) + .bind(req.beetle_count).bind(req.bird_count).bind(req.mammal_count) + .bind(&req.native_status).bind(&req.naturadb_tags) .fetch_one(pool) .await .map_err(Into::into) @@ -168,6 +179,10 @@ pub async fn update(pool: &PgPool, id: Uuid, req: &CreateSpecies) -> Result Result