Skip to content

Commit

Permalink
tiny bit more idiomatic param parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-r-ph committed Feb 23, 2025
1 parent 54433dc commit eab1854
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions rust/property-defs-rs/src/api/v1/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Manager {
qb.sql().into()
}

pub fn property_definitions_query<'a>(
pub fn property_definitions_query(
&self,
project_id: i32,
search_terms: &Option<Vec<String>>,
Expand All @@ -115,7 +115,7 @@ impl Manager {
group_type_index: i32,
properties: &Option<Vec<String>>,
excluded_properties: &Option<Vec<String>>,
event_names: &'a Option<Vec<String>>,
event_names: &Option<Vec<String>>,
is_feature_flag: &Option<bool>,
is_numerical: &Option<bool>,
use_enterprise_taxonomy: &Option<bool>,
Expand Down
20 changes: 6 additions & 14 deletions rust/property-defs-rs/src/api/v1/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,13 @@ async fn project_property_definitions_handler(
.get("event_names")
.map(|raw| raw.split(",").map(|s| s.trim().to_string()).collect());

let limit: i32 = match params.get("limit") {
Some(s) => match s.parse::<i32>().ok() {
Some(val) => val,
_ => DEFAULT_QUERY_LIMIT,
},
_ => DEFAULT_QUERY_LIMIT,
};
let limit: i32 = params.get("limit").map_or(DEFAULT_QUERY_LIMIT, |s| {
s.parse::<i32>().unwrap_or(DEFAULT_QUERY_LIMIT)
});

let offset: i32 = match params.get("offset") {
Some(s) => match s.parse::<i32>().ok() {
Some(val) => val,
_ => DEFAULT_QUERY_OFFSET,
},
_ => DEFAULT_QUERY_OFFSET,
};
let offset: i32 = params.get("offset").map_or(DEFAULT_QUERY_OFFSET, |s| {
s.parse::<i32>().unwrap_or(DEFAULT_QUERY_OFFSET)
});

let order_by_verified = true; // default behavior

Expand Down

0 comments on commit eab1854

Please sign in to comment.