diff --git a/.github/workflows/deployment-staging.yml b/.github/workflows/deployment-staging.yml index 0d510c6..d82898c 100644 --- a/.github/workflows/deployment-staging.yml +++ b/.github/workflows/deployment-staging.yml @@ -33,28 +33,15 @@ jobs: # Build the lambdas in release mode and deploy them. - name: Build all lambdas run: cd lambdas && cargo lambda build --release - - run: > - cargo lambda deploy - --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} - --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} + - name: Deploy lambdas + run: | + LAMBDAS="get-bnas get-bnas-cities - - run: > - cargo lambda deploy - --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} - --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} - get-bnas - - run: > - cargo lambda deploy - --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} - --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} - get-cities-bnas - - run: > - cargo lambda deploy - --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} - --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} get-cities - - run: > - cargo lambda deploy - --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} - --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} - post-submissions-city + get-cities-bnas + post-submissions-city" + echo $LAMBDAS \ + | xargs -n1 -t \ + cargo lambda deploy \ + --iam-role ${{ secrets.BNAAPI_ROLE_ARN_STAGING }} \ + --env-var DATABASE_URL_SECRET_ID=${{ secrets.DATABASE_URL_SECRET_ID_STAGING }} diff --git a/entity/src/entities/census.rs b/entity/src/entities/census.rs index 2ce53ba..4587da4 100644 --- a/entity/src/entities/census.rs +++ b/entity/src/entities/census.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "census")] pub struct Model { #[sea_orm(primary_key)] + #[serde(skip_deserializing)] pub census_id: i32, pub city_id: Uuid, pub created_at: Option, diff --git a/entity/src/entities/city.rs b/entity/src/entities/city.rs index f6320f6..d8c5f3c 100644 --- a/entity/src/entities/city.rs +++ b/entity/src/entities/city.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "city")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub city_id: Uuid, pub country: String, #[sea_orm(column_type = "Double")] diff --git a/entity/src/entities/core_services.rs b/entity/src/entities/core_services.rs index 5b96093..a0964be 100644 --- a/entity/src/entities/core_services.rs +++ b/entity/src/entities/core_services.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "core_services")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, #[sea_orm(column_type = "Double")] pub dentists: f64, diff --git a/entity/src/entities/features.rs b/entity/src/entities/features.rs index e0b54ef..b4112a9 100644 --- a/entity/src/entities/features.rs +++ b/entity/src/entities/features.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "features")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, #[sea_orm(column_type = "Double")] pub people: f64, diff --git a/entity/src/entities/infrastructure.rs b/entity/src/entities/infrastructure.rs index bd87476..d67f348 100644 --- a/entity/src/entities/infrastructure.rs +++ b/entity/src/entities/infrastructure.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "infrastructure")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, #[sea_orm(column_type = "Double")] pub low_stress_miles: f64, diff --git a/entity/src/entities/opportunity.rs b/entity/src/entities/opportunity.rs index 195efae..195bd39 100644 --- a/entity/src/entities/opportunity.rs +++ b/entity/src/entities/opportunity.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "opportunity")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, #[sea_orm(column_type = "Double")] pub employment: f64, diff --git a/entity/src/entities/ranking.rs b/entity/src/entities/ranking.rs index f070943..884eca7 100644 --- a/entity/src/entities/ranking.rs +++ b/entity/src/entities/ranking.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "ranking")] pub struct Model { #[sea_orm(primary_key)] + #[serde(skip_deserializing)] pub ranking_id: i32, pub city_id: Uuid, pub country: i32, diff --git a/entity/src/entities/recreation.rs b/entity/src/entities/recreation.rs index 3481b6c..c0af874 100644 --- a/entity/src/entities/recreation.rs +++ b/entity/src/entities/recreation.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "recreation")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, #[sea_orm(column_type = "Double")] pub community_centers: f64, diff --git a/entity/src/entities/speed_limit.rs b/entity/src/entities/speed_limit.rs index f4f85e6..39ae83f 100644 --- a/entity/src/entities/speed_limit.rs +++ b/entity/src/entities/speed_limit.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "speed_limit")] pub struct Model { #[sea_orm(primary_key)] + #[serde(skip_deserializing)] pub speed_limit_id: i32, pub city_id: Uuid, pub created_at: Option, diff --git a/entity/src/entities/submission.rs b/entity/src/entities/submission.rs index 5734e7d..7744201 100644 --- a/entity/src/entities/submission.rs +++ b/entity/src/entities/submission.rs @@ -9,6 +9,11 @@ pub struct Model { #[sea_orm(primary_key)] #[serde(skip_deserializing)] pub id: i32, + pub first_name: String, + pub last_name: String, + pub title: Option, + pub organization: Option, + pub email: String, pub country: String, pub city: String, pub region: Option, diff --git a/entity/src/entities/summary.rs b/entity/src/entities/summary.rs index 0b9f7a6..4b158c9 100644 --- a/entity/src/entities/summary.rs +++ b/entity/src/entities/summary.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; #[sea_orm(table_name = "summary")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] + #[serde(skip_deserializing)] pub bna_uuid: Uuid, pub city_id: Uuid, pub created_at: Option, diff --git a/justfile b/justfile index f5bce3b..252e22f 100644 --- a/justfile +++ b/justfile @@ -35,7 +35,9 @@ lint-spellcheck: # Generate models db-generate-models: rm -fr {{ entites }} - sea-orm-cli generate entity -o {{ entites }} --with-serde both + sea-orm-cli generate entity -o {{ entites }} --with-serde both --serde-skip-deserializing-primary-key + # sea-orm-cli generate entity -o {{ entites }} --with-serde both -t submission --serde-skip-deserializing-primary-key + # Apply migrations and seed the database. db-init: db-migrate db-seed diff --git a/lambdas/README.md b/lambdas/README.md index 4c4a0f4..521d05c 100644 --- a/lambdas/README.md +++ b/lambdas/README.md @@ -41,7 +41,7 @@ Such payloads are stored in the `/src/fixtures` folder, and invoking request follows the following pattern: ```bash -cargo lambda invoke ${LAMBDA} --data-file lambdas/src/fixtures/${LAMBDA}.json +cargo lambda invoke --data-file lambdas/src/fixtures/${LAMBDA}.json ${LAMBDA} ``` For instance: diff --git a/lambdas/requests.rest b/lambdas/requests.rest index f74a81a..15fdf30 100644 --- a/lambdas/requests.rest +++ b/lambdas/requests.rest @@ -62,8 +62,13 @@ POST https://api.peopleforbikes.xyz/submissions/city content-type: application/json { - "country": "usa", "city": "santa rosa", + "country": "usa", + "email": "jane.dpe@orgllc.com", + "fips_code": "3570670", + "first_name": "Jane", + "last_name": "Doe", + "organization": "Organization LLC", "region": "new mexico", - "fips_code": "3570670" + "title": "CTO" } diff --git a/lambdas/src/fixtures/post-submissions-city.json b/lambdas/src/fixtures/post-submissions-city.json index df267cb..45c0db8 100644 --- a/lambdas/src/fixtures/post-submissions-city.json +++ b/lambdas/src/fixtures/post-submissions-city.json @@ -51,7 +51,7 @@ "time": "12/Mar/2020:19:03:58 +0000", "timeEpoch": 1583348638390 }, - "body": "{\"country\":\"usa\",\"city\":\"santa rosa\",\"region\":\"new mexico\",\"fips_code\":\"3570670\"}", + "body": "{\"first_name\": \"Jane\",\"last_name\": \"Doe\",\"organization\": \"Organization LLC\",\"title\": \"CTO\",\"email\": \"jane.dpe@orgllc.com\",\"country\": \"usa\",\"city\": \"santa rosa\",\"region\": \"new mexico\",\"fips_code\": \"3570670\"}", "pathParameters": { "parameter1": "value1" }, diff --git a/migration/src/m20231010_232527_city_submission.rs b/migration/src/m20231010_232527_city_submission.rs index 49694c0..6bf7d1e 100644 --- a/migration/src/m20231010_232527_city_submission.rs +++ b/migration/src/m20231010_232527_city_submission.rs @@ -18,6 +18,11 @@ impl MigrationTrait for Migration { .auto_increment() .primary_key(), ) + .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::Organization).string()) + .col(ColumnDef::new(Submission::Email).string().not_null()) .col(ColumnDef::new(Submission::Country).string().not_null()) .col(ColumnDef::new(Submission::City).string().not_null()) .col(ColumnDef::new(Submission::Region).string()) @@ -43,6 +48,11 @@ impl MigrationTrait for Migration { enum Submission { Table, Id, + FirstName, + LastName, + Title, + Organization, + Email, Country, City, Region,