From 6ecad18e6e8cab6371c0f9a2a50f328c9ba18a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Thu, 8 Aug 2024 10:39:52 -0500 Subject: [PATCH] Refactor /cities endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactors the /cities endpoints. Signed-off-by: Rémy Greinhofer --- Cargo.toml | 2 +- entity/src/entities/census.rs | 4 +- entity/src/entities/city.rs | 2 +- entity/src/entities/core_services.rs | 6 +- entity/src/entities/country.rs | 2 +- entity/src/entities/features.rs | 6 +- entity/src/entities/infrastructure.rs | 6 +- entity/src/entities/opportunity.rs | 6 +- entity/src/entities/recreation.rs | 6 +- entity/src/entities/speed_limit.rs | 4 +- entity/src/entities/submission.rs | 2 +- entity/src/entities/summary.rs | 4 +- entity/src/wrappers/census.rs | 4 +- entity/src/wrappers/city.rs | 4 +- entity/src/wrappers/submission.rs | 24 ++--- examples/query.rs | 2 +- examples/seeder.rs | 18 ++-- justfile | 2 - lambdas/Cargo.toml | 6 +- lambdas/src/bnas/post-bnas.rs | 12 +-- lambdas/src/cities/get-cities-bnas.rs | 4 +- lambdas/src/cities/get-cities-census.rs | 4 +- .../get-cities-submissions.rs | 0 lambdas/src/cities/get-cities.rs | 4 +- lambdas/src/cities/mod.rs | 6 +- .../patch-cities-submissions.rs | 14 +-- .../post-cities-submissions.rs | 18 +++- lambdas/src/cities/post-cities.rs | 2 +- .../tests/{enpoints => endpoints}/bnas.hurl | 11 ++- .../tests/{enpoints => endpoints}/cities.hurl | 0 lambdas/tests/justfile | 7 +- lambdas/tests/openapi.yml | 80 ---------------- migration/src/m20220101_000001_main.rs | 91 +++++++++---------- .../src/m20231010_232527_city_submission.rs | 6 +- 34 files changed, 150 insertions(+), 219 deletions(-) rename lambdas/src/{cities-submissions => cities}/get-cities-submissions.rs (100%) rename lambdas/src/{cities-submissions => cities}/patch-cities-submissions.rs (90%) rename lambdas/src/{cities-submissions => cities}/post-cities-submissions.rs (69%) rename lambdas/tests/{enpoints => endpoints}/bnas.hurl (67%) rename lambdas/tests/{enpoints => endpoints}/cities.hurl (100%) delete mode 100644 lambdas/tests/openapi.yml diff --git a/Cargo.toml b/Cargo.toml index 25653c1..114589a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ nom = "7.1.3" once_cell = "1.17.1" reqwest = "0.12.1" rstest = "0.22.0" -sea-orm = "0.12.1" +sea-orm = "1" sea-orm-migration = "1.0.0" serde = "1.0.159" serde_json = "1.0.95" diff --git a/entity/src/entities/census.rs b/entity/src/entities/census.rs index a86e35c..865f1c6 100644 --- a/entity/src/entities/census.rs +++ b/entity/src/entities/census.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "census")] pub struct Model { #[sea_orm(primary_key)] - pub census_id: i32, + pub id: i32, pub city_id: Uuid, pub created_at: TimeDateTimeWithTimeZone, pub fips_code: String, @@ -20,7 +20,7 @@ pub enum Relation { #[sea_orm( belongs_to = "super::city::Entity", from = "Column::CityId", - to = "super::city::Column::CityId", + to = "super::city::Column::Id", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/city.rs b/entity/src/entities/city.rs index e6f4cab..8c14c6b 100644 --- a/entity/src/entities/city.rs +++ b/entity/src/entities/city.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "city")] pub struct Model { #[sea_orm(unique)] - pub city_id: Uuid, + pub id: Uuid, #[sea_orm(primary_key, auto_increment = false)] pub country: String, #[sea_orm(primary_key, auto_increment = false)] diff --git a/entity/src/entities/core_services.rs b/entity/src/entities/core_services.rs index cca091b..f890de4 100644 --- a/entity/src/entities/core_services.rs +++ b/entity/src/entities/core_services.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "core_services")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, #[sea_orm(column_type = "Double", nullable)] pub dentists: Option, #[sea_orm(column_type = "Double", nullable)] @@ -28,8 +28,8 @@ pub struct Model { pub enum Relation { #[sea_orm( belongs_to = "super::summary::Entity", - from = "Column::BnaUuid", - to = "super::summary::Column::BnaUuid", + from = "Column::BnaId", + to = "super::summary::Column::BnaId", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/country.rs b/entity/src/entities/country.rs index 0f17c93..b352dd6 100644 --- a/entity/src/entities/country.rs +++ b/entity/src/entities/country.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "country")] pub struct Model { #[sea_orm(primary_key)] - pub country_id: i32, + pub id: i32, #[sea_orm(unique)] pub name: String, } diff --git a/entity/src/entities/features.rs b/entity/src/entities/features.rs index 139c0ad..ff55f40 100644 --- a/entity/src/entities/features.rs +++ b/entity/src/entities/features.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "features")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, #[sea_orm(column_type = "Double", nullable)] pub people: Option, #[sea_orm(column_type = "Double", nullable)] @@ -20,8 +20,8 @@ pub struct Model { pub enum Relation { #[sea_orm( belongs_to = "super::summary::Entity", - from = "Column::BnaUuid", - to = "super::summary::Column::BnaUuid", + from = "Column::BnaId", + to = "super::summary::Column::BnaId", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/infrastructure.rs b/entity/src/entities/infrastructure.rs index c70a1b7..13c155b 100644 --- a/entity/src/entities/infrastructure.rs +++ b/entity/src/entities/infrastructure.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "infrastructure")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, #[sea_orm(column_type = "Double", nullable)] pub low_stress_miles: Option, #[sea_orm(column_type = "Double", nullable)] @@ -18,8 +18,8 @@ pub struct Model { pub enum Relation { #[sea_orm( belongs_to = "super::summary::Entity", - from = "Column::BnaUuid", - to = "super::summary::Column::BnaUuid", + from = "Column::BnaId", + to = "super::summary::Column::BnaId", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/opportunity.rs b/entity/src/entities/opportunity.rs index 28fe720..7e26b10 100644 --- a/entity/src/entities/opportunity.rs +++ b/entity/src/entities/opportunity.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "opportunity")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, #[sea_orm(column_type = "Double", nullable)] pub employment: Option, #[sea_orm(column_type = "Double", nullable)] @@ -24,8 +24,8 @@ pub struct Model { pub enum Relation { #[sea_orm( belongs_to = "super::summary::Entity", - from = "Column::BnaUuid", - to = "super::summary::Column::BnaUuid", + from = "Column::BnaId", + to = "super::summary::Column::BnaId", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/recreation.rs b/entity/src/entities/recreation.rs index d815b0d..e8c1e8c 100644 --- a/entity/src/entities/recreation.rs +++ b/entity/src/entities/recreation.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "recreation")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, #[sea_orm(column_type = "Double", nullable)] pub community_centers: Option, #[sea_orm(column_type = "Double", nullable)] @@ -22,8 +22,8 @@ pub struct Model { pub enum Relation { #[sea_orm( belongs_to = "super::summary::Entity", - from = "Column::BnaUuid", - to = "super::summary::Column::BnaUuid", + from = "Column::BnaId", + to = "super::summary::Column::BnaId", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/speed_limit.rs b/entity/src/entities/speed_limit.rs index a73a007..fd40765 100644 --- a/entity/src/entities/speed_limit.rs +++ b/entity/src/entities/speed_limit.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "speed_limit")] pub struct Model { #[sea_orm(primary_key)] - pub speed_limit_id: i32, + pub id: i32, pub city_id: Uuid, pub created_at: TimeDateTimeWithTimeZone, pub residential: i32, @@ -18,7 +18,7 @@ pub enum Relation { #[sea_orm( belongs_to = "super::city::Entity", from = "Column::CityId", - to = "super::city::Column::CityId", + to = "super::city::Column::Id", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/entities/submission.rs b/entity/src/entities/submission.rs index 8df13db..b251e9c 100644 --- a/entity/src/entities/submission.rs +++ b/entity/src/entities/submission.rs @@ -11,7 +11,7 @@ pub struct Model { pub id: i32, pub first_name: String, pub last_name: String, - pub title: Option, + pub occupation: Option, pub organization: Option, pub email: String, pub country: String, diff --git a/entity/src/entities/summary.rs b/entity/src/entities/summary.rs index b81bd25..cc58dc8 100644 --- a/entity/src/entities/summary.rs +++ b/entity/src/entities/summary.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "summary")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] - pub bna_uuid: Uuid, + pub bna_id: Uuid, pub city_id: Uuid, pub created_at: TimeDateTimeWithTimeZone, #[sea_orm(column_type = "Double")] @@ -20,7 +20,7 @@ pub enum Relation { #[sea_orm( belongs_to = "super::city::Entity", from = "Column::CityId", - to = "super::city::Column::CityId", + to = "super::city::Column::Id", on_update = "NoAction", on_delete = "Cascade" )] diff --git a/entity/src/wrappers/census.rs b/entity/src/wrappers/census.rs index cf72d4e..c3a6117 100644 --- a/entity/src/wrappers/census.rs +++ b/entity/src/wrappers/census.rs @@ -11,7 +11,7 @@ pub struct CensusPost { impl IntoActiveModel for CensusPost { fn into_active_model(self) -> census::ActiveModel { census::ActiveModel { - census_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, city_id: ActiveValue::Set(self.city_id), created_at: ActiveValue::NotSet, fips_code: ActiveValue::Set(self.fips_code), @@ -31,7 +31,7 @@ pub struct CensusPatch { impl IntoActiveModel for CensusPatch { fn into_active_model(self) -> census::ActiveModel { census::ActiveModel { - census_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, city_id: self.city_id.map_or(ActiveValue::NotSet, ActiveValue::Set), created_at: ActiveValue::NotSet, fips_code: self.fips_code.map_or(ActiveValue::NotSet, ActiveValue::Set), diff --git a/entity/src/wrappers/city.rs b/entity/src/wrappers/city.rs index 9da4e84..df249b8 100644 --- a/entity/src/wrappers/city.rs +++ b/entity/src/wrappers/city.rs @@ -17,7 +17,7 @@ pub struct CityPost { impl IntoActiveModel for CityPost { fn into_active_model(self) -> city::ActiveModel { city::ActiveModel { - city_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, country: ActiveValue::Set(self.country), latitude: ActiveValue::Set(self.latitude), longitude: ActiveValue::Set(self.longitude), @@ -47,7 +47,7 @@ pub struct CityPatch { impl IntoActiveModel for CityPatch { fn into_active_model(self) -> city::ActiveModel { city::ActiveModel { - city_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, country: self.country.map_or(ActiveValue::NotSet, ActiveValue::Set), latitude: self.latitude.map_or(ActiveValue::NotSet, ActiveValue::Set), longitude: self.longitude.map_or(ActiveValue::NotSet, ActiveValue::Set), diff --git a/entity/src/wrappers/submission.rs b/entity/src/wrappers/submission.rs index dc6605f..eddc73f 100644 --- a/entity/src/wrappers/submission.rs +++ b/entity/src/wrappers/submission.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; pub struct SubmissionPost { pub first_name: String, pub last_name: String, - pub title: Option, + pub occupation: Option, pub organization: Option, pub email: String, pub country: String, @@ -23,7 +23,7 @@ impl IntoActiveModel for SubmissionPost { id: ActiveValue::NotSet, first_name: ActiveValue::Set(self.first_name), last_name: ActiveValue::Set(self.last_name), - title: ActiveValue::Set(self.title), + occupation: ActiveValue::Set(self.occupation), organization: ActiveValue::Set(self.organization), email: ActiveValue::Set(self.email), country: ActiveValue::Set(self.country), @@ -41,7 +41,7 @@ impl IntoActiveModel for SubmissionPost { pub struct SubmissionPatch { pub first_name: Option, pub last_name: Option, - pub title: Option>, + pub occupation: Option>, pub organization: Option>, pub email: Option, pub country: Option, @@ -60,7 +60,9 @@ impl IntoActiveModel for SubmissionPatch { .first_name .map_or(ActiveValue::NotSet, ActiveValue::Set), last_name: self.last_name.map_or(ActiveValue::NotSet, ActiveValue::Set), - title: self.title.map_or(ActiveValue::NotSet, ActiveValue::Set), + occupation: self + .occupation + .map_or(ActiveValue::NotSet, ActiveValue::Set), organization: self .organization .map_or(ActiveValue::NotSet, ActiveValue::Set), @@ -84,7 +86,7 @@ mod tests { fn test_submission_post_into_active_model_full() { let first_name = "John".to_string(); let last_name = "Doe".to_string(); - let title = Some("Director".to_owned()); + let occupation = Some("Director".to_owned()); let organization = Some("ACME".to_string()); let email = "john.doe@acme.org".to_string(); let country = "usa".to_string(); @@ -96,7 +98,7 @@ mod tests { let wrapper = SubmissionPost { first_name: first_name.clone(), last_name: last_name.clone(), - title: title.clone(), + occupation: occupation.clone(), organization: organization.clone(), email: email.clone(), country: country.clone(), @@ -111,7 +113,7 @@ mod tests { id: ActiveValue::NotSet, first_name: ActiveValue::Set(first_name), last_name: ActiveValue::Set(last_name), - title: ActiveValue::Set(title), + occupation: ActiveValue::Set(occupation), organization: ActiveValue::Set(organization), email: ActiveValue::Set(email), country: ActiveValue::Set(country), @@ -141,7 +143,7 @@ mod tests { let wrapper = SubmissionPost { first_name: first_name.clone(), last_name: last_name.clone(), - title: title.clone(), + occupation: title.clone(), organization: organization.clone(), email: email.clone(), country: country.clone(), @@ -156,7 +158,7 @@ mod tests { id: ActiveValue::NotSet, first_name: ActiveValue::Set(first_name), last_name: ActiveValue::Set(last_name), - title: ActiveValue::Set(title), + occupation: ActiveValue::Set(title), organization: ActiveValue::Set(organization), email: ActiveValue::Set(email), country: ActiveValue::Set(country), @@ -176,7 +178,7 @@ mod tests { let wrapper = SubmissionPatch { first_name: Some(first_name.clone()), last_name: None, - title: None, + occupation: None, organization: None, email: None, country: None, @@ -191,7 +193,7 @@ mod tests { id: ActiveValue::NotSet, first_name: ActiveValue::Set(first_name), last_name: ActiveValue::NotSet, - title: ActiveValue::NotSet, + occupation: ActiveValue::NotSet, organization: ActiveValue::NotSet, email: ActiveValue::NotSet, country: ActiveValue::NotSet, diff --git a/examples/query.rs b/examples/query.rs index f8b6284..3bd1aa9 100644 --- a/examples/query.rs +++ b/examples/query.rs @@ -77,7 +77,7 @@ async fn main() -> Result<(), Report> { id: ActiveValue::NotSet, first_name: ActiveValue::Set("Floyd".to_string()), last_name: ActiveValue::Set("Martin".to_string()), - title: ActiveValue::Set(None), + occupation: ActiveValue::Set(None), organization: ActiveValue::Set(Some("organization".to_string())), email: ActiveValue::Set("floyd.martin@organization.com".to_string()), country: ActiveValue::Set("usa".to_string()), diff --git a/examples/seeder.rs b/examples/seeder.rs index 814a742..7419d07 100644 --- a/examples/seeder.rs +++ b/examples/seeder.rs @@ -142,7 +142,7 @@ async fn main() -> Result<(), Report> { .unwrap_or(scorecard.country.clone()); let city_model = city::ActiveModel { - city_id: ActiveValue::Set(city_uuid), + id: ActiveValue::Set(city_uuid), country: ActiveValue::Set(scorecard.country.clone()), latitude: ActiveValue::Set(Some(scorecard.census_latitude)), longitude: ActiveValue::Set(Some(scorecard.census_longitude)), @@ -159,7 +159,7 @@ async fn main() -> Result<(), Report> { // Populate the census population model. let census_model = census::ActiveModel { - census_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, city_id: ActiveValue::Set(city_uuid), created_at: ActiveValue::Set(created_at), fips_code: scorecard @@ -176,7 +176,7 @@ async fn main() -> Result<(), Report> { // Populate the speed limit model. let speed_limit_model = speed_limit::ActiveModel { - speed_limit_id: ActiveValue::NotSet, + id: ActiveValue::NotSet, city_id: ActiveValue::Set(city_uuid), created_at: ActiveValue::Set(created_at), residential: scorecard @@ -188,7 +188,7 @@ async fn main() -> Result<(), Report> { // Populate the summary model. let bna_uuid = Uuid::parse_str(scorecard.bna_uuid.as_str()).unwrap(); let summary_model = summary::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid), + bna_id: ActiveValue::Set(bna_uuid), city_id: ActiveValue::Set(city_uuid), created_at: ActiveValue::Set(created_at), score: ActiveValue::Set(scorecard.bna_rounded_score.into()), @@ -198,7 +198,7 @@ async fn main() -> Result<(), Report> { // Populate the features model. let feature_model = features::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid), + bna_id: ActiveValue::Set(bna_uuid), people: ActiveValue::Set(scorecard.bna_people), transit: ActiveValue::Set(scorecard.bna_transit), retail: ActiveValue::Set(scorecard.bna_retail), @@ -207,7 +207,7 @@ async fn main() -> Result<(), Report> { // Populate the Core Services model. let core_services_model = core_services::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid), + bna_id: ActiveValue::Set(bna_uuid), dentists: ActiveValue::Set(scorecard.bna_core_services_dentists), doctors: ActiveValue::Set(scorecard.bna_core_services_doctors), grocery: ActiveValue::Set(scorecard.bna_core_services_grocery), @@ -220,7 +220,7 @@ async fn main() -> Result<(), Report> { // Populate the recreation model. let recreation_model = recreation::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid.clone()), + bna_id: ActiveValue::Set(bna_uuid.clone()), community_centers: ActiveValue::Set(scorecard.bna_recreation_community_centers), parks: ActiveValue::Set(scorecard.bna_recreation_parks), recreation_trails: ActiveValue::Set(scorecard.bna_recreation_trails), @@ -230,7 +230,7 @@ async fn main() -> Result<(), Report> { // Populate the opportunity model. let opportunity_model = opportunity::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid), + bna_id: ActiveValue::Set(bna_uuid), employment: ActiveValue::Set(scorecard.bna_opportunity_employment), higher_education: ActiveValue::Set(scorecard.bna_opportunity_higher_education), k12_education: ActiveValue::Set(scorecard.bna_opportunity_k12_education), @@ -243,7 +243,7 @@ async fn main() -> Result<(), Report> { // Populate the infrastructure model. let infratructure_model = infrastructure::ActiveModel { - bna_uuid: ActiveValue::Set(bna_uuid), + bna_id: ActiveValue::Set(bna_uuid), low_stress_miles: ActiveValue::Set(scorecard.bna_total_low_stress_miles), high_stress_miles: ActiveValue::Set(scorecard.bna_total_high_stress_miles), }; diff --git a/justfile b/justfile index ad6fba3..7aff9cc 100644 --- a/justfile +++ b/justfile @@ -80,8 +80,6 @@ dbml-from-sql: dbml-svg: npx -y --package=@softwaretechnik/dbml-renderer dbml-renderer -i {{ dbml }} -o docs/database.svg - - # Spin up Docker Compose. compose-up: docker compose up -d diff --git a/lambdas/Cargo.toml b/lambdas/Cargo.toml index e1a904a..4d691d3 100644 --- a/lambdas/Cargo.toml +++ b/lambdas/Cargo.toml @@ -66,7 +66,7 @@ path = "src/cities/get-cities-census.rs" [[bin]] name = "get-cities-submissions" -path = "src/cities-submissions/get-cities-submissions.rs" +path = "src/cities/get-cities-submissions.rs" [[bin]] name = "get-price-fargate" @@ -78,11 +78,11 @@ path = "src/bnas-analysis/patch-bnas-analysis.rs" [[bin]] name = "patch-cities-submissions" -path = "src/cities-submissions/patch-cities-submissions.rs" +path = "src/cities/patch-cities-submissions.rs" [[bin]] name = "post-cities-submissions" -path = "src/cities-submissions/post-cities-submissions.rs" +path = "src/cities/post-cities-submissions.rs" [[bin]] name = "post-bnas-analysis" diff --git a/lambdas/src/bnas/post-bnas.rs b/lambdas/src/bnas/post-bnas.rs index 96b4350..d2ac082 100644 --- a/lambdas/src/bnas/post-bnas.rs +++ b/lambdas/src/bnas/post-bnas.rs @@ -46,7 +46,7 @@ async fn function_handler(event: Request) -> Result, Error> { // Turn the model wrapper into active models. let summary = summary::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), city_id: ActiveValue::Set(wrapper.summary.city_id), created_at: ActiveValue::NotSet, score: ActiveValue::Set(wrapper.summary.score), @@ -54,7 +54,7 @@ async fn function_handler(event: Request) -> Result, Error> { }; info!("{:?}", summary); let core_services = core_services::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), dentists: ActiveValue::Set(wrapper.core_services.dentists), doctors: ActiveValue::Set(wrapper.core_services.doctors), grocery: ActiveValue::Set(wrapper.core_services.grocery), @@ -65,20 +65,20 @@ async fn function_handler(event: Request) -> Result, Error> { }; info!("{:?}", core_services); let features = features::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), people: ActiveValue::Set(wrapper.features.people), retail: ActiveValue::Set(wrapper.features.retail), transit: ActiveValue::Set(wrapper.features.transit), }; info!("{:?}", features); let infrastructure = infrastructure::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), low_stress_miles: ActiveValue::Set(wrapper.infrastructure.low_stress_miles), high_stress_miles: ActiveValue::Set(wrapper.infrastructure.high_stress_miles), }; info!("{:?}", infrastructure); let opportunity = opportunity::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), employment: ActiveValue::Set(wrapper.opportunity.employment), higher_education: ActiveValue::Set(wrapper.opportunity.higher_education), k12_education: ActiveValue::Set(wrapper.opportunity.k12_education), @@ -89,7 +89,7 @@ async fn function_handler(event: Request) -> Result, Error> { }; info!("{:?}", opportunity); let recreation = recreation::ActiveModel { - bna_uuid: ActiveValue::Set(wrapper.summary.bna_uuid), + bna_id: ActiveValue::Set(wrapper.summary.bna_uuid), community_centers: ActiveValue::Set(wrapper.recreation.community_centers), parks: ActiveValue::Set(wrapper.recreation.parks), recreation_trails: ActiveValue::Set(wrapper.recreation.recreation_trails), diff --git a/lambdas/src/cities/get-cities-bnas.rs b/lambdas/src/cities/get-cities-bnas.rs index 7174d6b..126b93b 100644 --- a/lambdas/src/cities/get-cities-bnas.rs +++ b/lambdas/src/cities/get-cities-bnas.rs @@ -4,7 +4,7 @@ use entity::{city, summary}; use lambda_http::{run, service_fn, Body, Error, Request, Response}; use lambdas::{ build_paginated_response, - cities::{extract_path_parameters, PathParameters}, + cities::{extract_path_parameters, CitiesPathParameters}, database_connect, pagination_parameters, }; use sea_orm::{EntityTrait, PaginatorTrait}; @@ -15,7 +15,7 @@ async fn function_handler(event: Request) -> Result, Error> { dotenv().ok(); // Extract the path parameters. - let params: PathParameters = match extract_path_parameters(&event) { + let params: CitiesPathParameters = match extract_path_parameters(&event) { Ok(p) => p, Err(e) => return Ok(e.into()), }; diff --git a/lambdas/src/cities/get-cities-census.rs b/lambdas/src/cities/get-cities-census.rs index 89c8811..621a112 100644 --- a/lambdas/src/cities/get-cities-census.rs +++ b/lambdas/src/cities/get-cities-census.rs @@ -4,7 +4,7 @@ use entity::{census, city}; use lambda_http::{run, service_fn, Body, Error, Request, Response}; use lambdas::{ build_paginated_response, - cities::{extract_path_parameters, PathParameters}, + cities::{extract_path_parameters, CitiesPathParameters}, database_connect, pagination_parameters, }; use sea_orm::{EntityTrait, PaginatorTrait}; @@ -31,7 +31,7 @@ async fn function_handler(event: Request) -> Result, Error> { dotenv().ok(); // Extract the path parameters. - let params: PathParameters = match extract_path_parameters(&event) { + let params: CitiesPathParameters = match extract_path_parameters(&event) { Ok(p) => p, Err(e) => return Ok(e.into()), }; diff --git a/lambdas/src/cities-submissions/get-cities-submissions.rs b/lambdas/src/cities/get-cities-submissions.rs similarity index 100% rename from lambdas/src/cities-submissions/get-cities-submissions.rs rename to lambdas/src/cities/get-cities-submissions.rs diff --git a/lambdas/src/cities/get-cities.rs b/lambdas/src/cities/get-cities.rs index 75d90e6..4e08d3d 100644 --- a/lambdas/src/cities/get-cities.rs +++ b/lambdas/src/cities/get-cities.rs @@ -4,7 +4,7 @@ use entity::city; use lambda_http::{run, service_fn, Body, Error, IntoResponse, Request, Response}; use lambdas::{ build_paginated_response, - cities::{extract_path_parameters, PathParameters}, + cities::{extract_path_parameters, CitiesPathParameters}, database_connect, pagination_parameters_2, }; use sea_orm::{EntityTrait, PaginatorTrait}; @@ -19,7 +19,7 @@ async fn function_handler(event: Request) -> Result, Error> { // With params. if event.has_path_parameters() { - let params: PathParameters = match extract_path_parameters(&event) { + let params: CitiesPathParameters = match extract_path_parameters(&event) { Ok(p) => p, Err(e) => return Ok(e.into()), }; diff --git a/lambdas/src/cities/mod.rs b/lambdas/src/cities/mod.rs index 048c902..7064024 100644 --- a/lambdas/src/cities/mod.rs +++ b/lambdas/src/cities/mod.rs @@ -4,7 +4,7 @@ use effortless::{api::parse_path_parameter, error::APIErrors}; use lambda_http::Request; /// Represent the path parameters for the /cities enpoint. -pub struct PathParameters { +pub struct CitiesPathParameters { /// Country name. pub country: String, /// Region name. @@ -14,7 +14,7 @@ pub struct PathParameters { } /// Extract the path parameters for the /cities endpoint. -pub fn extract_path_parameters(event: &Request) -> Result { +pub fn extract_path_parameters(event: &Request) -> Result { let mut api_errors = APIErrors::empty(); let country = match parse_path_parameter::(event, "country") { @@ -44,7 +44,7 @@ pub fn extract_path_parameters(event: &Request) -> Result Result, Error> { Ok(model) => model, Err(e) => return Ok(e.into()), }; - info!( "updating Submission {:?} into database: {:?}", active_model.id, active_model @@ -28,8 +30,8 @@ async fn function_handler(event: Request) -> Result, Error> { let db = database_connect(Some("DATABASE_URL_SECRET_ID")).await?; // Update the entry. - let res = Submission::update(active_model).exec(&db).await?; - Ok(json!(res.id).into_response().await) + let model: submission::Model = active_model.update(&db).await?; + Ok(json!(model).into_response().await) } #[tokio::main] @@ -50,7 +52,7 @@ async fn main() -> Result<(), Error> { pub fn prepare_active_model(event: &Request) -> Result { // Retrieve the ID of the Submission to update. - let parameter = "id"; + let parameter = "submission_id"; let submission_id = parse_path_parameter::(event, parameter)? .ok_or(missing_parameter(event, parameter))?; diff --git a/lambdas/src/cities-submissions/post-cities-submissions.rs b/lambdas/src/cities/post-cities-submissions.rs similarity index 69% rename from lambdas/src/cities-submissions/post-cities-submissions.rs rename to lambdas/src/cities/post-cities-submissions.rs index 119f9b3..8ef563e 100644 --- a/lambdas/src/cities-submissions/post-cities-submissions.rs +++ b/lambdas/src/cities/post-cities-submissions.rs @@ -1,9 +1,12 @@ use dotenv::dotenv; use effortless::api::parse_request_body; -use entity::{prelude::*, wrappers::submission::SubmissionPost}; -use lambda_http::{run, service_fn, Body, Error, IntoResponse, Request, Response}; +use entity::wrappers::submission::SubmissionPost; +use lambda_http::{ + http::{header, StatusCode}, + run, service_fn, Body, Error, Request, Response, +}; use lambdas::database_connect; -use sea_orm::{EntityTrait, IntoActiveModel}; +use sea_orm::{ActiveModelTrait, IntoActiveModel}; use serde_json::json; use tracing::info; @@ -27,8 +30,13 @@ async fn function_handler(event: Request) -> Result, Error> { "inserting Submission into database: {:?}", active_submission ); - let res = Submission::insert(active_submission).exec(&db).await?; - Ok(json!(res.last_insert_id).into_response().await) + let submission = active_submission.insert(&db).await?; + let response = Response::builder() + .status(StatusCode::CREATED) + .header(header::CONTENT_TYPE, "application/json") + .body(Body::Text(json!(submission).to_string())) + .expect("unable to build http::Response"); + Ok(response) } #[tokio::main] diff --git a/lambdas/src/cities/post-cities.rs b/lambdas/src/cities/post-cities.rs index ad7f57e..c609af7 100644 --- a/lambdas/src/cities/post-cities.rs +++ b/lambdas/src/cities/post-cities.rs @@ -51,7 +51,7 @@ async fn function_handler(event: Request) -> Result, Error> { let mut active_city = wrapper.into_active_model(); // Assign a city_id. - active_city.city_id = ActiveValue::Set(Uuid::new_v4()); + active_city.id = ActiveValue::Set(Uuid::new_v4()); // Get the database connection. let db = database_connect(Some("DATABASE_URL_SECRET_ID")).await?; diff --git a/lambdas/tests/enpoints/bnas.hurl b/lambdas/tests/endpoints/bnas.hurl similarity index 67% rename from lambdas/tests/enpoints/bnas.hurl rename to lambdas/tests/endpoints/bnas.hurl index b4cdbc7..30bfad8 100644 --- a/lambdas/tests/enpoints/bnas.hurl +++ b/lambdas/tests/endpoints/bnas.hurl @@ -4,6 +4,9 @@ GET {{host}}/bnas HTTP 200 [Asserts] jsonpath "$" count > 0 +[Captures] +bna_id: jsonpath "$.[0].bna_uuid" + # Queries a specific bna run. GET {{host}}/bnas/{{bna_id}} @@ -16,15 +19,15 @@ GET {{host}}/bnas/1 HTTP 400 [Asserts] jsonpath "$.errors" count == 1 -jsonpath "$.errors[0].source.Parameter" == "bna_id" +jsonpath "$.errors[0].source.Pointer" == "id" # Queries a non-existing bna run -GET {{host}}/bnas/eac1dbfb-2137-44c5-be59-71fc613f2962 +GET {{host}}/bnas/eac1dbfb-2137-44c5-be59-71fc613f2963 HTTP 404 [Asserts] jsonpath "$.errors" count == 1 -jsonpath "$.errors[0].source.Pointer" == "/bnas/eac1dbfb-2137-44c5-be59-71fc613f2962" +jsonpath "$.errors[0].source.Parameter" == "/bnas/eac1dbfb-2137-44c5-be59-71fc613f2963" # Queries a specific bna run and its associated city. GET {{host}}/bnas/{{bna_id}}/city @@ -39,4 +42,4 @@ GET {{host}}/bnas/374386aa-c34a-4cd6-b296-ae420017847e/city HTTP 404 [Asserts] jsonpath "$.errors" count == 1 -jsonpath "$.errors[0].source.Pointer" == "/bnas/374386aa-c34a-4cd6-b296-ae420017847e/city" +jsonpath "$.errors[0].source.Parameter" == "/bnas/374386aa-c34a-4cd6-b296-ae420017847e/city" diff --git a/lambdas/tests/enpoints/cities.hurl b/lambdas/tests/endpoints/cities.hurl similarity index 100% rename from lambdas/tests/enpoints/cities.hurl rename to lambdas/tests/endpoints/cities.hurl diff --git a/lambdas/tests/justfile b/lambdas/tests/justfile index ac02ce0..0147b61 100644 --- a/lambdas/tests/justfile +++ b/lambdas/tests/justfile @@ -25,8 +25,11 @@ test-staging-schemathesis: # Run the integration tests against the staging environment. test-staging: - hurl --variables-file staging.vars --test pagination.hurl bnas.hurl cities.hurl + hurl --variables-file staging.vars --test \ + scenario/pagination.hurl \ + endpoints/bnas.hurl \ + endpoints/cities.hurl # Run the smoke tests against the staging environment. -test-smoke-readonly-staging: +test-staging-smoke-readonly: hurl --variables-file staging.vars --test smoke/public-readonly.hurl diff --git a/lambdas/tests/openapi.yml b/lambdas/tests/openapi.yml deleted file mode 100644 index 811fc26..0000000 --- a/lambdas/tests/openapi.yml +++ /dev/null @@ -1,80 +0,0 @@ -openapi: "3.0.1" -info: - title: "bna-api" - description: "BNA API" - version: "2023-04-21 00:58:00UTC" - license: - name: MIT - url: "https://api.peopleforbikes.xyz/{basePath}" -tags: - - name: tag name - description: | - tag description. -servers: - - url: "https://api.peopleforbikes.xyz/{basePath}" - variables: - basePath: - default: "" - x-amazon-apigateway-endpoint-configuration: - disableExecuteApiEndpoint: true -paths: - /bnas: - get: - responses: - default: - description: "Default response for GET /bnas" - /bnas/{bna_id}: - get: - responses: - default: - description: "Default response for GET /bnas/{bna_id}" - parameters: - - name: "bna_id" - in: "path" - description: "Generated path parameter for bna_id" - required: true - schema: - type: "string" - format: "uuid" - /bnas/{bna_id}/city: - get: - responses: - default: - description: "Default response for GET /bnas/{bna_id}/city" - parameters: - - name: "bna_id" - in: "path" - description: "Generated path parameter for bna_id" - required: true - schema: - type: "string" - format: "uuid" - /cities: - get: - responses: - default: - description: "Default response for GET /cities" - /cities/{city_id}: - get: - responses: - default: - description: "Default response for GET /cities/{city_id}" - parameters: - - name: "city_id" - in: "path" - description: "Generated path parameter for city_id" - required: true - schema: - type: "string" - /cities/{city_id}/bnas: - get: - responses: - default: - description: "Default response for GET /cities/{city_id}/bnas" - parameters: - - name: "city_id" - in: "path" - description: "Generated path parameter for city_id" - required: true - schema: - type: "string" diff --git a/migration/src/m20220101_000001_main.rs b/migration/src/m20220101_000001_main.rs index 954ebe1..6b64121 100644 --- a/migration/src/m20220101_000001_main.rs +++ b/migration/src/m20220101_000001_main.rs @@ -1,4 +1,3 @@ -#![allow(clippy::enum_variant_names)] use sea_orm_migration::{ prelude::*, sea_orm::{EnumIter, Iterable}, @@ -76,7 +75,7 @@ impl MigrationTrait for Migration { .table(Country::Table) .if_not_exists() .col( - ColumnDef::new(Country::CountryId) + ColumnDef::new(Country::Id) .integer() .primary_key() .auto_increment() @@ -128,7 +127,7 @@ impl MigrationTrait for Migration { Table::create() .table(City::Table) .if_not_exists() - .col(ColumnDef::new(City::CityId).uuid().unique_key().not_null()) + .col(ColumnDef::new(City::Id).uuid().unique_key().not_null()) .col(ColumnDef::new(City::Country).string().not_null()) .col(ColumnDef::new(City::State).string().not_null()) .col(ColumnDef::new(City::Name).string().not_null()) @@ -154,12 +153,7 @@ impl MigrationTrait for Migration { ) .await?; manager - .create_index( - Index::create() - .table(City::Table) - .col(City::CityId) - .to_owned(), - ) + .create_index(Index::create().table(City::Table).col(City::Id).to_owned()) .await?; // Create CensusPopulation table. @@ -169,7 +163,7 @@ impl MigrationTrait for Migration { .table(Census::Table) .if_not_exists() .col( - ColumnDef::new(Census::CensusId) + ColumnDef::new(Census::Id) .integer() .not_null() .auto_increment() @@ -188,7 +182,7 @@ impl MigrationTrait for Migration { .foreign_key( ForeignKey::create() .from(Census::Table, Census::CityId) - .to(City::Table, City::CityId) + .to(City::Table, City::Id) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -198,7 +192,7 @@ impl MigrationTrait for Migration { .create_index( Index::create() .table(Census::Table) - .col(Census::CensusId) + .col(Census::Id) .to_owned(), ) .await?; @@ -217,7 +211,7 @@ impl MigrationTrait for Migration { Table::create() .table(SpeedLimit::Table) .col( - ColumnDef::new(SpeedLimit::SpeedLimitId) + ColumnDef::new(SpeedLimit::Id) .integer() .not_null() .auto_increment() @@ -234,7 +228,7 @@ impl MigrationTrait for Migration { .foreign_key( ForeignKey::create() .from(SpeedLimit::Table, SpeedLimit::CityId) - .to(City::Table, City::CityId) + .to(City::Table, City::Id) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -244,7 +238,7 @@ impl MigrationTrait for Migration { .create_index( Index::create() .table(SpeedLimit::Table) - .col(SpeedLimit::SpeedLimitId) + .col(SpeedLimit::Id) .to_owned(), ) .await?; @@ -262,7 +256,7 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(Summary::Table) - .col(ColumnDef::new(Summary::BNAUuid).uuid().not_null()) + .col(ColumnDef::new(Summary::BNAId).uuid().not_null()) .col(ColumnDef::new(Summary::CityId).uuid().not_null()) .col( ColumnDef::new(Summary::CreatedAt) @@ -272,11 +266,11 @@ impl MigrationTrait for Migration { ) .col(ColumnDef::new(Summary::Score).double().not_null()) .col(ColumnDef::new(Summary::Version).string().not_null()) - .primary_key(Index::create().col(Summary::BNAUuid)) + .primary_key(Index::create().col(Summary::BNAId)) .foreign_key( ForeignKey::create() .from(Summary::Table, Summary::CityId) - .to(City::Table, City::CityId) + .to(City::Table, City::Id) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -288,15 +282,15 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(Features::Table) - .col(ColumnDef::new(Features::BNAUuid).uuid().not_null()) + .col(ColumnDef::new(Features::BNAId).uuid().not_null()) .col(ColumnDef::new(Features::People).double()) .col(ColumnDef::new(Features::Retail).double()) .col(ColumnDef::new(Features::Transit).double()) - .primary_key(Index::create().col(Features::BNAUuid)) + .primary_key(Index::create().col(Features::BNAId)) .foreign_key( ForeignKey::create() - .from(Features::Table, Features::BNAUuid) - .to(Summary::Table, Summary::BNAUuid) + .from(Features::Table, Features::BNAId) + .to(Summary::Table, Summary::BNAId) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -308,7 +302,7 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(CoreServices::Table) - .col(ColumnDef::new(CoreServices::BNAUuid).uuid()) + .col(ColumnDef::new(CoreServices::BNAId).uuid()) .col(ColumnDef::new(CoreServices::Dentists).double()) .col(ColumnDef::new(CoreServices::Doctors).double()) .col(ColumnDef::new(CoreServices::Grocery).double()) @@ -316,11 +310,11 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(CoreServices::Pharmacies).double()) .col(ColumnDef::new(CoreServices::Score).double()) .col(ColumnDef::new(CoreServices::SocialServices).double()) - .primary_key(Index::create().col(CoreServices::BNAUuid)) + .primary_key(Index::create().col(CoreServices::BNAId)) .foreign_key( ForeignKey::create() - .from(CoreServices::Table, CoreServices::BNAUuid) - .to(Summary::Table, Summary::BNAUuid) + .from(CoreServices::Table, CoreServices::BNAId) + .to(Summary::Table, Summary::BNAId) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -332,17 +326,17 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(Opportunity::Table) - .col(ColumnDef::new(Opportunity::BNAUuid).uuid().not_null()) + .col(ColumnDef::new(Opportunity::BNAId).uuid().not_null()) .col(ColumnDef::new(Opportunity::Employment).double()) .col(ColumnDef::new(Opportunity::HigherEducation).double()) .col(ColumnDef::new(Opportunity::K12Education).double()) .col(ColumnDef::new(Opportunity::Score).double()) .col(ColumnDef::new(Opportunity::TechnicalVocationalCollege).double()) - .primary_key(Index::create().col(Opportunity::BNAUuid)) + .primary_key(Index::create().col(Opportunity::BNAId)) .foreign_key( ForeignKey::create() - .from(Opportunity::Table, Opportunity::BNAUuid) - .to(Summary::Table, Summary::BNAUuid) + .from(Opportunity::Table, Opportunity::BNAId) + .to(Summary::Table, Summary::BNAId) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -354,16 +348,16 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(Recreation::Table) - .col(ColumnDef::new(Recreation::BNAUuid).uuid().not_null()) + .col(ColumnDef::new(Recreation::BNAId).uuid().not_null()) .col(ColumnDef::new(Recreation::CommunityCenters).double()) .col(ColumnDef::new(Recreation::Parks).double()) .col(ColumnDef::new(Recreation::RecreationTrails).double()) .col(ColumnDef::new(Recreation::Score).double()) - .primary_key(Index::create().col(Recreation::BNAUuid)) + .primary_key(Index::create().col(Recreation::BNAId)) .foreign_key( ForeignKey::create() - .from(Recreation::Table, Recreation::BNAUuid) - .to(Summary::Table, Summary::BNAUuid) + .from(Recreation::Table, Recreation::BNAId) + .to(Summary::Table, Summary::BNAId) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -375,14 +369,14 @@ impl MigrationTrait for Migration { .create_table( Table::create() .table(Infrastructure::Table) - .col(ColumnDef::new(Infrastructure::BNAUuid).uuid().not_null()) + .col(ColumnDef::new(Infrastructure::BNAId).uuid().not_null()) .col(ColumnDef::new(Infrastructure::LowStressMiles).double()) .col(ColumnDef::new(Infrastructure::HighStressMiles).double()) - .primary_key(Index::create().col(Infrastructure::BNAUuid)) + .primary_key(Index::create().col(Infrastructure::BNAId)) .foreign_key( ForeignKey::create() - .from(Infrastructure::Table, Infrastructure::BNAUuid) - .to(Summary::Table, Summary::BNAUuid) + .from(Infrastructure::Table, Infrastructure::BNAId) + .to(Summary::Table, Summary::BNAId) .on_delete(ForeignKeyAction::Cascade), ) .to_owned(), @@ -432,7 +426,7 @@ impl MigrationTrait for Migration { enum City { Table, /// City identifier. - CityId, + Id, /// Country. Country, /// Creation date. @@ -458,7 +452,7 @@ enum City { #[derive(Iden)] enum Census { Table, - CensusId, + Id, /// City identifier. CityId, /// Creation date. @@ -474,7 +468,7 @@ enum Census { #[derive(Iden)] enum SpeedLimit { Table, - SpeedLimitId, + Id, /// City identifier. CityId, /// Creation date. @@ -487,7 +481,7 @@ enum SpeedLimit { enum Summary { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// City identifier. CityId, /// Creation date. @@ -502,7 +496,7 @@ enum Summary { enum Features { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// BNA category score for access to residential areas. People, /// BNA category score for access to major retail centers. @@ -515,7 +509,7 @@ enum Features { enum CoreServices { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// BNA category subscore for access to dentists. Dentists, /// BNA category subscore for access to doctors. @@ -536,7 +530,7 @@ enum CoreServices { enum Opportunity { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// BNA category subscore for access to job location areas. Employment, /// BNA category subscore for access to universities and colleges. @@ -553,12 +547,13 @@ enum Opportunity { enum Recreation { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// BNA category subscore for access to community centers. CommunityCenters, /// BNA category subscore for access to parks. Parks, /// BNA category subscore for access to bikeable trails. + #[allow(clippy::enum_variant_names)] RecreationTrails, /// BNA category score for access to recreational facilities. Score, @@ -568,7 +563,7 @@ enum Recreation { enum Infrastructure { Table, /// Analysis unique identifier. - BNAUuid, + BNAId, /// Total miles of low-stress streets and paths in the measured area. LowStressMiles, /// Total miles of high-stress streets in the measured area. @@ -620,7 +615,7 @@ enum StateRegionCrosswalk { enum Country { Table, /// Country ID. - CountryId, + Id, /// Country name. Name, } diff --git a/migration/src/m20231010_232527_city_submission.rs b/migration/src/m20231010_232527_city_submission.rs index a02fdfb..b23a106 100644 --- a/migration/src/m20231010_232527_city_submission.rs +++ b/migration/src/m20231010_232527_city_submission.rs @@ -32,7 +32,7 @@ impl MigrationTrait for Migration { ) .col(ColumnDef::new(Submission::FirstName).string().not_null()) .col(ColumnDef::new(Submission::LastName).string().not_null()) - .col(ColumnDef::new(Submission::Title).string()) + .col(ColumnDef::new(Submission::Occupation).string()) .col(ColumnDef::new(Submission::Organization).string()) .col(ColumnDef::new(Submission::Email).string().not_null()) .col(ColumnDef::new(Submission::Country).string().not_null()) @@ -71,13 +71,13 @@ impl MigrationTrait for Migration { } } -#[derive(DeriveIden)] +#[derive(Iden)] enum Submission { Table, Id, FirstName, LastName, - Title, + Occupation, Organization, Email, Country,