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
This commit is contained in:
@@ -121,6 +121,19 @@ pub struct Species {
|
||||
pub gbif_id: Option<String>,
|
||||
pub eppo_code: Option<String>,
|
||||
pub pfaf_url: Option<String>,
|
||||
pub nectar_value: Option<i16>,
|
||||
pub pollen_value: Option<i16>,
|
||||
pub wild_bee_count: Option<i32>,
|
||||
pub wild_bee_specialist_count: Option<i32>,
|
||||
pub butterfly_moth_count: Option<i32>,
|
||||
pub caterpillar_host_count: Option<i32>,
|
||||
pub caterpillar_specialist_count: Option<i32>,
|
||||
pub hoverfly_count: Option<i32>,
|
||||
pub beetle_count: Option<i32>,
|
||||
pub bird_count: Option<i32>,
|
||||
pub mammal_count: Option<i32>,
|
||||
pub native_status: Option<String>,
|
||||
pub naturadb_tags: Option<String>,
|
||||
pub primary_image_key: Option<String>,
|
||||
pub source_urls: Option<Vec<String>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
@@ -169,6 +182,19 @@ pub struct CreateSpecies {
|
||||
pub gbif_id: Option<String>,
|
||||
pub eppo_code: Option<String>,
|
||||
pub pfaf_url: Option<String>,
|
||||
pub nectar_value: Option<i16>,
|
||||
pub pollen_value: Option<i16>,
|
||||
pub wild_bee_count: Option<i32>,
|
||||
pub wild_bee_specialist_count: Option<i32>,
|
||||
pub butterfly_moth_count: Option<i32>,
|
||||
pub caterpillar_host_count: Option<i32>,
|
||||
pub caterpillar_specialist_count: Option<i32>,
|
||||
pub hoverfly_count: Option<i32>,
|
||||
pub beetle_count: Option<i32>,
|
||||
pub bird_count: Option<i32>,
|
||||
pub mammal_count: Option<i32>,
|
||||
pub native_status: Option<String>,
|
||||
pub naturadb_tags: Option<String>,
|
||||
pub source_urls: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -119,11 +119,16 @@ pub async fn create(pool: &PgPool, req: &CreateSpecies) -> Result<Species> {
|
||||
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<Species> {
|
||||
.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<Spec
|
||||
wildlife_value=$32, mulch_plant=$33, ground_cover_quality=$34, allelopathic=$35,
|
||||
guild_role=$36, succession_stage=$37, heavy_metal_tolerance=$38,
|
||||
wikidata_qid=$39, gbif_id=$40, eppo_code=$41, pfaf_url=$42, source_urls=$43,
|
||||
nectar_value=$44, pollen_value=$45, wild_bee_count=$46, wild_bee_specialist_count=$47,
|
||||
butterfly_moth_count=$48, caterpillar_host_count=$49, caterpillar_specialist_count=$50,
|
||||
hoverfly_count=$51, beetle_count=$52, bird_count=$53, mammal_count=$54,
|
||||
native_status=$55, naturadb_tags=$56,
|
||||
updated_at=NOW()
|
||||
WHERE id=$1 RETURNING *"
|
||||
)
|
||||
@@ -188,6 +203,12 @@ pub async fn update(pool: &PgPool, id: Uuid, req: &CreateSpecies) -> Result<Spec
|
||||
.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)
|
||||
|
||||
Reference in New Issue
Block a user