fix(pricing): support roleKey alias and leads schema
This commit is contained in:
parent
acb817b9da
commit
8128bd0d30
2 changed files with 12 additions and 4 deletions
|
|
@ -42,10 +42,10 @@ async fn list_leads(
|
||||||
) -> Result<impl IntoResponse, (StatusCode, String)> {
|
) -> Result<impl IntoResponse, (StatusCode, String)> {
|
||||||
let requirements = sqlx::query_as::<_, Requirement>(
|
let requirements = sqlx::query_as::<_, Requirement>(
|
||||||
r#"
|
r#"
|
||||||
SELECT id, customer_id, profession_key, title, description, location, budget,
|
SELECT id, created_by_user_id, profession_key, title, description, location, budget_inr,
|
||||||
preferred_date, extra_data_json, status, rejection_reason, request_count, accepted_count,
|
required_date, extra_data_json, status, rejection_reason, request_count, accepted_count,
|
||||||
expires_at, approved_at, approved_by, created_at, updated_at
|
expires_at, approved_at, approved_by, created_at, updated_at
|
||||||
FROM requirements
|
FROM leads
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT 100
|
LIMIT 100
|
||||||
"#,
|
"#,
|
||||||
|
|
|
||||||
|
|
@ -113,12 +113,20 @@ struct ExistingPackageRow {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct PackageQuery {
|
struct PackageQuery {
|
||||||
role: Option<String>,
|
role: Option<String>,
|
||||||
|
#[serde(rename = "roleKey", alias = "role_key")]
|
||||||
|
role_key: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn public_list_packages(
|
async fn public_list_packages(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
Query(params): Query<PackageQuery>,
|
Query(params): Query<PackageQuery>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
|
let requested_role = params
|
||||||
|
.role
|
||||||
|
.or(params.role_key)
|
||||||
|
.map(|r| r.trim().to_uppercase())
|
||||||
|
.filter(|r| !r.is_empty() && r != "PROFESSIONAL");
|
||||||
|
|
||||||
let rows = sqlx::query_as::<_, PackageRow>(
|
let rows = sqlx::query_as::<_, PackageRow>(
|
||||||
r#"
|
r#"
|
||||||
SELECT id, name, role_key, package_type, tracecoins_amount, price_inr, description, is_active
|
SELECT id, name, role_key, package_type, tracecoins_amount, price_inr, description, is_active
|
||||||
|
|
@ -128,7 +136,7 @@ async fn public_list_packages(
|
||||||
ORDER BY role_key, price_inr
|
ORDER BY role_key, price_inr
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.bind(params.role)
|
.bind(requested_role)
|
||||||
.fetch_all(&state.pool)
|
.fetch_all(&state.pool)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue