A
This commit is contained in:
parent
613b7308cd
commit
0ba5f7344a
@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS "unit" (
|
||||
price_usd FLOAT8 NOT NULL,
|
||||
unit_type VARCHAR NOT NULL,
|
||||
rooms SMALLINT NOT NULL,
|
||||
bathrooms SMALLINT NOT NULL,
|
||||
bathrooms FLOAT4 NOT NULL,
|
||||
area FLOAT4 NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
media TEXT NOT NULL,
|
||||
|
@ -4,7 +4,7 @@ SELECT
|
||||
p.project_type as "project_type: _",
|
||||
p.project_condition as "project_condition: _",
|
||||
l.city,
|
||||
(SELECT (SELECT u.price_usd FROM unit u WHERE u.project_id = p.id ORDER BY u.price_usd DESC LIMIT 1)) as starts_from,
|
||||
(SELECT (SELECT u.price_usd FROM unit u WHERE u.project_id = p.id ORDER BY u.price_usd ASC LIMIT 1)) as starts_from,
|
||||
l.district,
|
||||
p.finish_date,
|
||||
p.media as "media: _",
|
||||
|
160
sqlx-data.json
160
sqlx-data.json
@ -546,86 +546,6 @@
|
||||
},
|
||||
"query": "INSERT INTO agent (\n id, shortcode, full_name, credential, credential_type, profile_picture_url, time_created, last_updated\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $7\n) RETURNING\nid,\nshortcode,\nfull_name,\ncredential,\ncredential_type as \"credential_type: _\",\nprofile_picture_url,\ntime_created,\nlast_updated;"
|
||||
},
|
||||
"919dc414e70785bed4b999412b2ce5c46cb07e4aefb6a8c74bde23fcca9a4759": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"name": "project_state: _",
|
||||
"ordinal": 1,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_type: _",
|
||||
"ordinal": 2,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_condition: _",
|
||||
"ordinal": 3,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "city",
|
||||
"ordinal": 4,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "starts_from",
|
||||
"ordinal": 5,
|
||||
"type_info": "Float8"
|
||||
},
|
||||
{
|
||||
"name": "district",
|
||||
"ordinal": 6,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "finish_date",
|
||||
"ordinal": 7,
|
||||
"type_info": "Timestamp"
|
||||
},
|
||||
{
|
||||
"name": "media: _",
|
||||
"ordinal": 8,
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "admin_tag",
|
||||
"ordinal": 9,
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Int2",
|
||||
"Int8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT \n p.id,\n p.project_state as \"project_state: _\",\n p.project_type as \"project_type: _\",\n p.project_condition as \"project_condition: _\",\n l.city,\n (SELECT (SELECT u.price_usd FROM unit u WHERE u.project_id = p.id ORDER BY u.price_usd DESC LIMIT 1)) as starts_from,\n l.district,\n p.finish_date,\n p.media as \"media: _\",\n p.admin_tag\nFROM project p, location l\nWHERE p.location_id = l.id\n-- Filters here:\nAND (LOWER(l.city) LIKE '%' || LOWER($1) || '%' OR $1 IS null) -- City Filter\nAND (LOWER(l.district) LIKE '%' || LOWER($2) || '%' OR $2 IS null) -- District Filter\nAND (p.project_type = $3 OR $3 IS null) -- ProjectType\nAND (p.project_condition = $4 OR $4 IS null) -- ProjectCondition\nAND (p.project_state = $5 OR $5 IS null) -- ProjectState\nAND ((SELECT COUNT(*) FROM unit u WHERE u.project_id = p.id AND u.rooms = $6) > 0 OR $6 IS NULL)\n-- End of filters\nORDER BY p.time_created DESC\nLIMIT 50 OFFSET $7;"
|
||||
},
|
||||
"924abcf88270de74ab6524fbd4247b2c23ab96b4569c8b81ff6b0e1d7dacada7": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@ -1541,5 +1461,85 @@
|
||||
}
|
||||
},
|
||||
"query": "INSERT INTO unit (\n id,\n project_id,\n price_usd,\n unit_type,\n rooms,\n bathrooms,\n area,\n description,\n media,\n admin_tag,\n time_created,\n last_updated\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $11\n)\nRETURNING \n id,\n project_id,\n price_usd,\n unit_type as \"unit_type: _\",\n rooms,\n bathrooms,\n area,\n description,\n media as \"media: _\",\n admin_tag,\n time_created,\n last_updated;"
|
||||
},
|
||||
"f31a7e8287470f8e6328ccf6a8c73c2f476ebcf976b0f70944c2a80c1bfaa246": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"name": "project_state: _",
|
||||
"ordinal": 1,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_type: _",
|
||||
"ordinal": 2,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "project_condition: _",
|
||||
"ordinal": 3,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "city",
|
||||
"ordinal": 4,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "starts_from",
|
||||
"ordinal": 5,
|
||||
"type_info": "Float8"
|
||||
},
|
||||
{
|
||||
"name": "district",
|
||||
"ordinal": 6,
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"name": "finish_date",
|
||||
"ordinal": 7,
|
||||
"type_info": "Timestamp"
|
||||
},
|
||||
{
|
||||
"name": "media: _",
|
||||
"ordinal": 8,
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "admin_tag",
|
||||
"ordinal": 9,
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Text",
|
||||
"Int2",
|
||||
"Int8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT \n p.id,\n p.project_state as \"project_state: _\",\n p.project_type as \"project_type: _\",\n p.project_condition as \"project_condition: _\",\n l.city,\n (SELECT (SELECT u.price_usd FROM unit u WHERE u.project_id = p.id ORDER BY u.price_usd ASC LIMIT 1)) as starts_from,\n l.district,\n p.finish_date,\n p.media as \"media: _\",\n p.admin_tag\nFROM project p, location l\nWHERE p.location_id = l.id\n-- Filters here:\nAND (LOWER(l.city) LIKE '%' || LOWER($1) || '%' OR $1 IS null) -- City Filter\nAND (LOWER(l.district) LIKE '%' || LOWER($2) || '%' OR $2 IS null) -- District Filter\nAND (p.project_type = $3 OR $3 IS null) -- ProjectType\nAND (p.project_condition = $4 OR $4 IS null) -- ProjectCondition\nAND (p.project_state = $5 OR $5 IS null) -- ProjectState\nAND ((SELECT COUNT(*) FROM unit u WHERE u.project_id = p.id AND u.rooms = $6) > 0 OR $6 IS NULL)\n-- End of filters\nORDER BY p.time_created DESC\nLIMIT 50 OFFSET $7;"
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ use uuid::Uuid;
|
||||
|
||||
use crate::{services, utils::visit::store_visit_concurrent};
|
||||
|
||||
|
||||
#[get("/agent")]
|
||||
pub async fn get_all_agents(db_conn: web::Data<Arc<PgPool>>) -> TypedHttpResponse<Vec<Agent>> {
|
||||
services::read::get_all_agents(&db_conn).await
|
||||
|
@ -56,7 +56,7 @@ macro_rules! unwrap_or_not_found {
|
||||
};
|
||||
}
|
||||
|
||||
/// This macro does the authentication needed for all the admin routes. give it a user and password as params.
|
||||
/// This macro does the authentication needed for all the admin routes.
|
||||
#[macro_export]
|
||||
macro_rules! auth {
|
||||
($request:expr) => {
|
||||
|
Loading…
Reference in New Issue
Block a user