Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update submission endpoint #50

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions .github/workflows/deployment-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions entity/src/entities/census.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTimeWithTimeZone>,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/city.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/core_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/infrastructure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/opportunity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/ranking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/recreation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/speed_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTimeWithTimeZone>,
Expand Down
5 changes: 5 additions & 0 deletions entity/src/entities/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub organization: Option<String>,
pub email: String,
pub country: String,
pub city: String,
pub region: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions entity/src/entities/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTimeWithTimeZone>,
Expand Down
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lambdas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions lambdas/requests.rest
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ POST https://api.peopleforbikes.xyz/submissions/city
content-type: application/json

{
"country": "usa",
"city": "santa rosa",
"country": "usa",
"email": "[email protected]",
"fips_code": "3570670",
"first_name": "Jane",
"last_name": "Doe",
"organization": "Organization LLC",
"region": "new mexico",
"fips_code": "3570670"
"title": "CTO"
}
2 changes: 1 addition & 1 deletion lambdas/src/fixtures/post-submissions-city.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\": \"[email protected]\",\"country\": \"usa\",\"city\": \"santa rosa\",\"region\": \"new mexico\",\"fips_code\": \"3570670\"}",
"pathParameters": {
"parameter1": "value1"
},
Expand Down
10 changes: 10 additions & 0 deletions migration/src/m20231010_232527_city_submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -43,6 +48,11 @@ impl MigrationTrait for Migration {
enum Submission {
Table,
Id,
FirstName,
LastName,
Title,
Organization,
Email,
Country,
City,
Region,
Expand Down