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)> {
|
||||
let requirements = sqlx::query_as::<_, Requirement>(
|
||||
r#"
|
||||
SELECT id, customer_id, profession_key, title, description, location, budget,
|
||||
preferred_date, extra_data_json, status, rejection_reason, request_count, accepted_count,
|
||||
SELECT id, created_by_user_id, profession_key, title, description, location, budget_inr,
|
||||
required_date, extra_data_json, status, rejection_reason, request_count, accepted_count,
|
||||
expires_at, approved_at, approved_by, created_at, updated_at
|
||||
FROM requirements
|
||||
FROM leads
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 100
|
||||
"#,
|
||||
|
|
|
|||
|
|
@ -113,12 +113,20 @@ struct ExistingPackageRow {
|
|||
#[derive(Deserialize)]
|
||||
struct PackageQuery {
|
||||
role: Option<String>,
|
||||
#[serde(rename = "roleKey", alias = "role_key")]
|
||||
role_key: Option<String>,
|
||||
}
|
||||
|
||||
async fn public_list_packages(
|
||||
State(state): State<AppState>,
|
||||
Query(params): Query<PackageQuery>,
|
||||
) -> 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>(
|
||||
r#"
|
||||
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
|
||||
"#,
|
||||
)
|
||||
.bind(params.role)
|
||||
.bind(requested_role)
|
||||
.fetch_all(&state.pool)
|
||||
.await;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue