From 4a10f5413da9797af18e8675d1e0257a15bac843 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 8 Aug 2021 21:25:00 -0400 Subject: [PATCH] Both searches done --- src/JobsJobsJobs/Api/Data.fs | 21 +++++++++------ src/JobsJobsJobs/App/src/api/index.ts | 2 +- .../App/src/components/CollapsePanel.vue | 16 +++++------ .../App/src/views/profile/ProfileSearch.vue | 27 +++++++++++-------- .../App/src/views/profile/Seeking.vue | 27 ++++++++++--------- 5 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/JobsJobsJobs/Api/Data.fs b/src/JobsJobsJobs/Api/Data.fs index 1f719b5..9cc7e86 100644 --- a/src/JobsJobsJobs/Api/Data.fs +++ b/src/JobsJobsJobs/Api/Data.fs @@ -188,6 +188,11 @@ let withReconn (conn : IConnection) = (conn :?> Connection).Reconnect() | false -> ())) +/// Sanitize user input, and create a "contains" pattern for use with RethinkDB queries +let regexContains (it : string) = + System.Text.RegularExpressions.Regex.Escape it + |> sprintf "(?i).*%s.*" + open JobsJobsJobs.Domain.SharedTypes open RethinkDb.Driver.Ast @@ -251,14 +256,14 @@ module Profile = match srch.skill with | Some skl -> yield (fun q -> q.Filter(ReqlFunction1(fun it -> - upcast it.G("skills.description").Downcase().Match(skl.ToLowerInvariant ()))) :> ReqlExpr) + upcast it.G("skills").Contains(ReqlFunction1(fun s -> + upcast s.G("description").Match(regexContains skl))))) :> ReqlExpr) | None -> () match srch.bioExperience with | Some text -> - let txt = text.ToLowerInvariant () + let txt = regexContains text yield (fun q -> q.Filter(ReqlFunction1(fun it -> - upcast it.G("biography" ).Downcase().Match(txt) - .Or(it.G("experience").Downcase().Match(txt)))) :> ReqlExpr) + upcast it.G("biography").Match(txt).Or(it.G("experience").Match(txt)))) :> ReqlExpr) | None -> () } |> Seq.toList @@ -290,8 +295,7 @@ module Profile = match srch.region with | Some reg -> yield (fun q -> - q.Filter(ReqlFunction1(fun it -> - upcast it.G("region").Downcase().Match(reg.ToLowerInvariant ()))) :> ReqlExpr) + q.Filter(ReqlFunction1(fun it -> upcast it.G("region").Match(regexContains reg))) :> ReqlExpr) | None -> () match srch.remoteWork with | "" -> () @@ -299,7 +303,8 @@ module Profile = match srch.skill with | Some skl -> yield (fun q -> q.Filter(ReqlFunction1(fun it -> - upcast it.G("skills.description").Downcase().Match(skl.ToLowerInvariant ()))) :> ReqlExpr) + upcast it.G("skills").Contains(ReqlFunction1(fun s -> + upcast s.G("description").Match(regexContains skl))))) :> ReqlExpr) | None -> () } |> Seq.toList @@ -315,7 +320,7 @@ module Profile = .HashMap("skills", it.G("skills").Map(ReqlFunction1(fun skill -> upcast r.Branch(skill.G("notes").Default_("").Eq(""), skill.G("description"), - sprintf "%O (%O)" (skill.G("description")) (skill.G("notes")))))) + skill.G("description").Add(" (").Add(skill.G("notes")).Add(")"))))) .With("continent", it.G("name")))) .Pluck("continent", "region", "skills", "remoteWork") .RunResultAsync conn) diff --git a/src/JobsJobsJobs/App/src/api/index.ts b/src/JobsJobsJobs/App/src/api/index.ts index a012f14..155308e 100644 --- a/src/JobsJobsJobs/App/src/api/index.ts +++ b/src/JobsJobsJobs/App/src/api/index.ts @@ -146,7 +146,7 @@ export default { publicSearch: async (query : PublicSearch) : Promise => { const params = new URLSearchParams() if (query.continentId) params.append('continentId', query.continentId) - if (query.region) params.append('bioExperience', query.region) + if (query.region) params.append('region', query.region) if (query.skill) params.append('skill', query.skill) params.append('remoteWork', query.remoteWork) return apiResult( diff --git a/src/JobsJobsJobs/App/src/components/CollapsePanel.vue b/src/JobsJobsJobs/App/src/components/CollapsePanel.vue index d9eef97..234e7b1 100644 --- a/src/JobsJobsJobs/App/src/components/CollapsePanel.vue +++ b/src/JobsJobsJobs/App/src/components/CollapsePanel.vue @@ -2,17 +2,19 @@