diff --git a/crates/job/src/sql/select.sql b/crates/job/src/sql/select.sql index b5aad47..ce3c595 100644 --- a/crates/job/src/sql/select.sql +++ b/crates/job/src/sql/select.sql @@ -42,12 +42,12 @@ SELECT json_concat_array( json_group_array( DISTINCT - coalesce(aco.emoji || ' ' || aco.name, abr.emoji || ' ' || abr.iso2, ar.name) + coalesce(aco.emoji || ' ' || aco.name, abr.emoji || ' ' || abr.iso2, asr.name, ar.name) ORDER BY aco.name, ar.name ) FILTER (WHERE j.applicant_region_id IS NOT NULL), json_group_array( DISTINCT - coalesce(jco.emoji || ' ' || jco.name, jr.name) + coalesce(jco.emoji || ' ' || jco.name, jsr.name, jr.name) ORDER BY jco.name, jr.name ) FILTER (WHERE j.job_region_id IS NOT NULL) ) AS locations, diff --git a/crates/model/src/job.rs b/crates/model/src/job.rs index 50aba1e..b9da73c 100644 --- a/crates/model/src/job.rs +++ b/crates/model/src/job.rs @@ -70,6 +70,7 @@ pub struct LocationSalary { pub region_name: Option, pub business_region_name: Option, pub business_region_flag: Option, + pub subregion_name: Option, pub country_id: Option, pub country_name: Option, pub country_flag: Option, diff --git a/crates/model/src/location.rs b/crates/model/src/location.rs index 4c16766..3fc5f08 100644 --- a/crates/model/src/location.rs +++ b/crates/model/src/location.rs @@ -5,6 +5,10 @@ use serde::{Deserialize, Serialize}; #[serde(transparent)] pub struct RegionId(pub i64); +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(transparent)] +pub struct SubregionId(pub i64); + #[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[serde(transparent)] pub struct CountryId(pub i64); @@ -36,6 +40,13 @@ impl FromSql for RegionId { } } +impl FromSql for SubregionId { + fn column_result(value: rusqlite::types::ValueRef<'_>) -> rusqlite::types::FromSqlResult { + let subregion_id = value.as_i64()?; + Ok(SubregionId(subregion_id)) + } +} + impl TryFrom<&rusqlite::Row<'_>> for Region { type Error = rusqlite::Error; diff --git a/templates/components/job.html b/templates/components/job.html index 97485ce..0fd95f3 100644 --- a/templates/components/job.html +++ b/templates/components/job.html @@ -97,9 +97,11 @@ {{ location.city_name }} ({{ location.country_iso2 }}) {%- elif location.country_name is not none -%} {{ location.country_name }} - {%- elif location.state_name is not none -%} - {{ location.state_name or location.region_name }} - {%- elif location.business_region_name is not none -%} + {%- elif location.state_name -%} + {{ location.state_name }} + {%- elif location.subregion_name -%} + {{ location.subregion_name }} + {%- elif location.business_region_name -%} {{ location.business_region_flag }} {{ location.business_region_name }} {%- else -%} {{ location.region_name }} diff --git a/templates/partials/job_details.html b/templates/partials/job_details.html index dc4944a..839a4a9 100644 --- a/templates/partials/job_details.html +++ b/templates/partials/job_details.html @@ -68,6 +68,8 @@ {{ location.country_flag }} {{ location.country_name }} (any) {%- elif location.business_region_name -%} {{ location.business_region_flag }} {{ location.business_region_name }} (any) + {%- elif location.subregion_name -%} + {{ location.subregion_name }} {%- else -%} {{ location.region_name }} {%- endif -%} @@ -93,6 +95,8 @@ {{ location_salary.country_name }} (any) {%- elif location_salary.country_name -%} {{ location_salary.country_flag }} {{ location_salary.country_name }} (any) + {%- elif location_salary.subregion_name -%} + {{ location_salary.subregion_name }} {%- else -%} {{ location_salary.region_name }} {%- endif -%}