realtor last commit :(
This commit is contained in:
parent
bfb246ca7a
commit
b862782fd0
@ -10,7 +10,6 @@ CREATE TABLE IF NOT EXISTS "property" (
|
|||||||
district VARCHAR NOT NULL,
|
district VARCHAR NOT NULL,
|
||||||
order_index INT NOT NULL,
|
order_index INT NOT NULL,
|
||||||
thumbnail_format VARCHAR NOT NULL,
|
thumbnail_format VARCHAR NOT NULL,
|
||||||
price_usd FLOAT8 NOT NULL,
|
|
||||||
rooms SMALLINT NOT NULL,
|
rooms SMALLINT NOT NULL,
|
||||||
bathrooms FLOAT4 NOT NULL,
|
bathrooms FLOAT4 NOT NULL,
|
||||||
area FLOAT4 NOT NULL,
|
area FLOAT4 NOT NULL,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use realtor_lp_types::domain::realtor::Realtor;
|
use realtor_lp_types::domain::realtor::Realtor;
|
||||||
use sqlx::PgPool;
|
use sqlx::{PgPool, Transaction, Postgres};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub async fn insert_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
pub async fn insert_realtor(tx: &mut Transaction<'_, Postgres>, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
||||||
sqlx::query_file_as!(
|
sqlx::query_file_as!(
|
||||||
Realtor,
|
Realtor,
|
||||||
"sql/realtor/insert.sql",
|
"sql/realtor/insert.sql",
|
||||||
@ -18,7 +18,7 @@ pub async fn insert_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor,
|
|||||||
realtor.remax_agent_id,
|
realtor.remax_agent_id,
|
||||||
realtor.time_created
|
realtor.time_created
|
||||||
)
|
)
|
||||||
.fetch_one(conn)
|
.fetch_one(tx)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ pub async fn get_realtor_with_shortcode(
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
pub async fn update_realtor(tx: &mut Transaction<'_, Postgres>, realtor: Realtor) -> Result<Realtor, sqlx::Error> {
|
||||||
sqlx::query_file_as!(
|
sqlx::query_file_as!(
|
||||||
Realtor,
|
Realtor,
|
||||||
"sql/realtor/update.sql",
|
"sql/realtor/update.sql",
|
||||||
@ -59,6 +59,6 @@ pub async fn update_realtor(conn: &PgPool, realtor: Realtor) -> Result<Realtor,
|
|||||||
realtor.remax_agent_id,
|
realtor.remax_agent_id,
|
||||||
realtor.last_updated
|
realtor.last_updated
|
||||||
)
|
)
|
||||||
.fetch_one(conn)
|
.fetch_one(tx)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use crate::utils::s3;
|
|||||||
use super::{click, property, realtor, trackable, view, arrangement};
|
use super::{click, property, realtor, trackable, view, arrangement};
|
||||||
|
|
||||||
pub const HOST_ADDR: &str = "0.0.0.0";
|
pub const HOST_ADDR: &str = "0.0.0.0";
|
||||||
pub const HOST_PORT: u16 = 8080;
|
pub const HOST_PORT: u16 = 8085;
|
||||||
|
|
||||||
pub async fn start_all_routes(start_time: i64, db_conn: Arc<PgPool>) -> Result<(), std::io::Error> {
|
pub async fn start_all_routes(start_time: i64, db_conn: Arc<PgPool>) -> Result<(), std::io::Error> {
|
||||||
let client_state = web::Data::new(Arc::new(Client::new()));
|
let client_state = web::Data::new(Arc::new(Client::new()));
|
||||||
|
@ -10,9 +10,9 @@ pub async fn add_arrangement_to_property(conn: &PgPool, arrangement: PropertyPri
|
|||||||
let existing_arrangement = handle_db_read_op!(dao::property_arrangement::fetch_arrangements_with_property_id(conn, &arrangement.property_id));
|
let existing_arrangement = handle_db_read_op!(dao::property_arrangement::fetch_arrangements_with_property_id(conn, &arrangement.property_id));
|
||||||
if existing_arrangement.iter().any(|persisted_arrangement| persisted_arrangement.arrangement == arrangement.arrangement) {
|
if existing_arrangement.iter().any(|persisted_arrangement| persisted_arrangement.arrangement == arrangement.arrangement) {
|
||||||
let persisted_arrangement = handle_db_write_op!(dao::property_arrangement::update_arrangement(&mut tx, arrangement.into()), tx);
|
let persisted_arrangement = handle_db_write_op!(dao::property_arrangement::update_arrangement(&mut tx, arrangement.into()), tx);
|
||||||
success!(persisted_arrangement)
|
success!(persisted_arrangement, tx);
|
||||||
} else {
|
} else {
|
||||||
let persisted_arrangement = handle_db_write_op!(dao::property_arrangement::insert_arrangement(&mut tx, arrangement.into()), tx);
|
let persisted_arrangement = handle_db_write_op!(dao::property_arrangement::insert_arrangement(&mut tx, arrangement.into()), tx);
|
||||||
success!(persisted_arrangement)
|
success!(persisted_arrangement, tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,7 +45,7 @@ pub async fn create_property(
|
|||||||
success!(handle_db_write_op!(
|
success!(handle_db_write_op!(
|
||||||
dao::property::insert_property(&mut transaction, property.into()),
|
dao::property::insert_property(&mut transaction, property.into()),
|
||||||
transaction
|
transaction
|
||||||
))
|
), transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn udpate_property(
|
pub async fn udpate_property(
|
||||||
@ -85,7 +85,7 @@ pub async fn udpate_property(
|
|||||||
success!(handle_db_write_op!(
|
success!(handle_db_write_op!(
|
||||||
dao::property::update_property(&mut transaction, property_insertable),
|
dao::property::update_property(&mut transaction, property_insertable),
|
||||||
transaction
|
transaction
|
||||||
))
|
), transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_realtor_properties_paged(
|
pub async fn fetch_realtor_properties_paged(
|
||||||
|
@ -13,9 +13,9 @@ pub async fn new_realtor_profile(
|
|||||||
) -> TypedHttpResponse<Realtor> {
|
) -> TypedHttpResponse<Realtor> {
|
||||||
let mut transaction = handle_tx!(conn.begin());
|
let mut transaction = handle_tx!(conn.begin());
|
||||||
success!(handle_db_write_op!(
|
success!(handle_db_write_op!(
|
||||||
dao::realtor::insert_realtor(conn, realtor.into()),
|
dao::realtor::insert_realtor(&mut transaction, realtor.into()),
|
||||||
transaction
|
transaction
|
||||||
));
|
), transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_realtor_profile(
|
pub async fn update_realtor_profile(
|
||||||
@ -27,9 +27,9 @@ pub async fn update_realtor_profile(
|
|||||||
let mut realtor_insertable: Realtor = realtor.into();
|
let mut realtor_insertable: Realtor = realtor.into();
|
||||||
realtor_insertable.id = realtor_id;
|
realtor_insertable.id = realtor_id;
|
||||||
success!(handle_db_write_op!(
|
success!(handle_db_write_op!(
|
||||||
dao::realtor::update_realtor(conn, realtor_insertable),
|
dao::realtor::update_realtor(&mut transaction, realtor_insertable),
|
||||||
transaction
|
transaction
|
||||||
));
|
), transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_realtor_by_shortcode(
|
pub async fn get_realtor_by_shortcode(
|
||||||
|
@ -41,6 +41,12 @@ macro_rules! success {
|
|||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_response(200, $e)
|
return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_response(200, $e)
|
||||||
};
|
};
|
||||||
|
($e:expr, $tx:expr) => {
|
||||||
|
|
||||||
|
let resp = actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_response(200, $e);
|
||||||
|
handle_tx!($tx.commit());
|
||||||
|
return resp;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This macro just returns a TypedHttpResponse with a not found status code (404) and an error concatenated.
|
/// This macro just returns a TypedHttpResponse with a not found status code (404) and an error concatenated.
|
||||||
|
Loading…
Reference in New Issue
Block a user