Skip to content

Commit

Permalink
Merge pull request #2020 from bcgov/feature/search-by-name
Browse files Browse the repository at this point in the history
TCVP-3116 search surname and ticket number as starts with
  • Loading branch information
pbolduc authored Dec 10, 2024
2 parents 7b18fe9 + 44f3326 commit 586f457
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ private void AddWhere(Dictionary<string, string> parameters, Request request)

AddDateRangeFilter(parameters, "appr_tm", request.appearance_dt_from, request.appearance_dt_thru);

if (request.ticket_number is not null) parameters.Add("ticket_number_txt_eq", request.ticket_number);
if (request.surname is not null) parameters.Add("prof_surname_nm_eq", request.surname);
// Search where starts with the spuplied value. We could also use "_regexp_like" and use a regex pattern
// ticket number is always uppercase
AddLikeFilter(parameters, "ticket_number_txt", request.ticket_number);
AddLikeFilter(parameters, "prof_surname_nm", request.surname);

if (request.jj_assigned_to is not null) parameters.Add("jj_assigned_to_eq", request.jj_assigned_to);

if (request.dispute_status_codes is not null) parameters.Add("dispute_status_type_cd_in", request.dispute_status_codes);
Expand All @@ -155,6 +158,22 @@ private void AddWhere(Dictionary<string, string> parameters, Request request)
}
}

private void AddLikeFilter(Dictionary<string, string> parameters, string field, string? value, bool toUpper = true)
{
if (value is null)
{
return;
}

if (toUpper)
{
value = value.ToUpper();
}

value = value.TrimEnd(); // remove trailing spaces
parameters.Add($"{field}_like", $"{value}%");
}

private void AddDateRangeFilter(Dictionary<string, string> parameters, string field, string? from, string? thru)
{
if (from is null && thru is null)
Expand Down

0 comments on commit 586f457

Please sign in to comment.