Refine private search (#39)
This commit is contained in:
parent
1e2f189051
commit
5c7383c6d1
@ -60,14 +60,19 @@ let search (search : ProfileSearchForm) = backgroundTask {
|
||||
"p.data ->> 'continentId' = @continentId", [ "@continentId", Sql.string search.ContinentId ]
|
||||
if search.RemoteWork <> "" then
|
||||
"p.data ->> 'isRemote' = @remote", [ "@remote", jsonBool (search.RemoteWork = "yes") ]
|
||||
if search.Skill <> "" then
|
||||
"EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(p.data['skills']) x(elt)
|
||||
WHERE x ->> 'description' ILIKE @description)",
|
||||
[ "@description", like search.Skill ]
|
||||
if search.BioExperience <> "" then
|
||||
"(p.data ->> 'biography' ILIKE @text OR p.data ->> 'experience' ILIKE @text)",
|
||||
[ "@text", like search.BioExperience ]
|
||||
if search.Text <> "" then
|
||||
" p.data ->> 'region' ILIKE @text
|
||||
OR p.data ->> 'biography' ILIKE @text
|
||||
OR p.data ->> 'experience' ILIKE @text
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(p.data['skills']) x(elt)
|
||||
WHERE x ->> 'description' ILIKE @text)
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(p.data['history']) x(elt)
|
||||
WHERE x ->> 'employer' ILIKE @text
|
||||
OR x ->> 'position' ILIKE @text
|
||||
OR x ->> 'description' ILIKE @text)",
|
||||
[ "@text", like search.Text ]
|
||||
]
|
||||
let! results =
|
||||
dataSource ()
|
||||
@ -75,7 +80,8 @@ let search (search : ProfileSearchForm) = backgroundTask {
|
||||
SELECT p.*, c.data AS cit_data
|
||||
FROM {Table.Profile} p
|
||||
INNER JOIN {Table.Citizen} c ON c.id = p.id
|
||||
WHERE p.data ->> 'isLegacy' = 'false'
|
||||
WHERE p.data ->> 'isLegacy' = 'false'
|
||||
AND p.data ->> 'visibility' <> '{ProfileVisibility.toString Hidden}'
|
||||
{searchSql searches}"
|
||||
|> Sql.parameters (searches |> List.collect snd)
|
||||
|> Sql.executeAsync (fun row ->
|
||||
|
@ -107,14 +107,11 @@ type ProfileSearchForm =
|
||||
{ /// Retrieve citizens from this continent
|
||||
ContinentId : string
|
||||
|
||||
/// Text for a search within a citizen's skills
|
||||
Skill : string
|
||||
|
||||
/// Text for a search with a citizen's professional biography and experience fields
|
||||
BioExperience : string
|
||||
|
||||
/// Whether to retrieve citizens who do or do not want remote work
|
||||
RemoteWork : string
|
||||
|
||||
/// Text for a search within a citizen's region, professional bio, skills, experience, and employment history
|
||||
Text : string
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ let search : HttpHandler = requireUser >=> fun next ctx -> task {
|
||||
let form =
|
||||
match ctx.TryBindQueryString<ProfileSearchForm> () with
|
||||
| Ok f -> f
|
||||
| Error _ -> { ContinentId = ""; RemoteWork = ""; Skill = ""; BioExperience = "" }
|
||||
| Error _ -> { ContinentId = ""; RemoteWork = ""; Text = "" }
|
||||
let! results = task {
|
||||
if string ctx.Request.Query["searched"] = "true" then
|
||||
let! it = Data.search form
|
||||
|
@ -438,8 +438,7 @@ let publicSearch (m : PublicSearchForm) continents (results : PublicSearchResult
|
||||
|
||||
/// Logged-on search page
|
||||
let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult list option) =
|
||||
pageWithTitle "Search Profiles" [
|
||||
if Option.isNone results then
|
||||
[ if Option.isNone results then
|
||||
p [] [
|
||||
txt "Enter one or more criteria to filter results, or just click “Search” to list all "
|
||||
txt "profiles."
|
||||
@ -448,10 +447,10 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
|
||||
form [ _class "container"; _method "GET"; _action "/profile/search" ] [
|
||||
input [ _type "hidden"; _name "searched"; _value "true" ]
|
||||
div [ _class "row" ] [
|
||||
div [ _class "col-12 col-sm-6 col-md-4 col-lg-3" ] [
|
||||
div [ _class "col-12 col-sm-6 col-md-4 col-lg-3 mb-3" ] [
|
||||
continentList [] "ContinentId" continents (Some "Any") m.ContinentId false
|
||||
]
|
||||
div [ _class "col-12 col-sm-6 col-offset-md-2 col-lg-3 col-offset-lg-0" ] [
|
||||
div [ _class "col-12 col-sm-6 col-offset-md-2 col-lg-3 col-offset-lg-0 mb-3" ] [
|
||||
label [ _class "jjj-label" ] [ txt "Seeking Remote Work?" ]; br []
|
||||
div [ _class "form-check form-check-inline" ] [
|
||||
input [ _type "radio"; _id "remoteNull"; _name (nameof m.RemoteWork); _value ""
|
||||
@ -469,13 +468,11 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
|
||||
label [ _class "form-check-label"; _for "remoteNo" ] [ txt "No" ]
|
||||
]
|
||||
]
|
||||
div [ _class "col-12 col-sm-6 col-lg-3" ] [
|
||||
textBox [ _maxlength "1000" ] (nameof m.Skill) m.Skill "Skill" false
|
||||
div [ _class "form-text" ] [ txt "(free-form text)" ]
|
||||
]
|
||||
div [ _class "col-12 col-sm-6 col-lg-3" ] [
|
||||
textBox [ _maxlength "1000" ] (nameof m.BioExperience) m.BioExperience "Bio / Experience" false
|
||||
div [ _class "form-text" ] [ txt "(free-form text)" ]
|
||||
div [ _class "col-12 col-sm-12 col-lg-6 mb-3" ] [
|
||||
textBox [ _maxlength "1000" ] (nameof m.Text) m.Text "Text Search" false
|
||||
div [ _class "form-text" ] [
|
||||
txt "searches Region, Professional Biography, Skills, Employment History, and Experience"
|
||||
]
|
||||
]
|
||||
]
|
||||
div [ _class "row" ] [
|
||||
@ -515,6 +512,8 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
|
||||
]
|
||||
| None -> ()
|
||||
]
|
||||
|> pageWithTitle "Search Profiles"
|
||||
|
||||
|
||||
/// Display a profile
|
||||
let private displayProfile (it : ProfileForView) isPublic isPrint =
|
||||
|
Loading…
Reference in New Issue
Block a user