Version 3 #40

Merged
danieljsummers merged 67 commits from version-2-3 into main 2023-02-02 23:47:28 +00:00
4 changed files with 29 additions and 27 deletions
Showing only changes of commit 5c7383c6d1 - Show all commits

View File

@ -60,14 +60,19 @@ let search (search : ProfileSearchForm) = backgroundTask {
"p.data ->> 'continentId' = @continentId", [ "@continentId", Sql.string search.ContinentId ] "p.data ->> 'continentId' = @continentId", [ "@continentId", Sql.string search.ContinentId ]
if search.RemoteWork <> "" then if search.RemoteWork <> "" then
"p.data ->> 'isRemote' = @remote", [ "@remote", jsonBool (search.RemoteWork = "yes") ] "p.data ->> 'isRemote' = @remote", [ "@remote", jsonBool (search.RemoteWork = "yes") ]
if search.Skill <> "" then if search.Text <> "" then
"EXISTS ( " p.data ->> 'region' ILIKE @text
SELECT 1 FROM jsonb_array_elements(p.data['skills']) x(elt) OR p.data ->> 'biography' ILIKE @text
WHERE x ->> 'description' ILIKE @description)", OR p.data ->> 'experience' ILIKE @text
[ "@description", like search.Skill ] OR EXISTS (
if search.BioExperience <> "" then SELECT 1 FROM jsonb_array_elements(p.data['skills']) x(elt)
"(p.data ->> 'biography' ILIKE @text OR p.data ->> 'experience' ILIKE @text)", WHERE x ->> 'description' ILIKE @text)
[ "@text", like search.BioExperience ] 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 = let! results =
dataSource () dataSource ()
@ -75,7 +80,8 @@ let search (search : ProfileSearchForm) = backgroundTask {
SELECT p.*, c.data AS cit_data SELECT p.*, c.data AS cit_data
FROM {Table.Profile} p FROM {Table.Profile} p
INNER JOIN {Table.Citizen} c ON c.id = p.id 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}" {searchSql searches}"
|> Sql.parameters (searches |> List.collect snd) |> Sql.parameters (searches |> List.collect snd)
|> Sql.executeAsync (fun row -> |> Sql.executeAsync (fun row ->

View File

@ -107,14 +107,11 @@ type ProfileSearchForm =
{ /// Retrieve citizens from this continent { /// Retrieve citizens from this continent
ContinentId : string 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 /// Whether to retrieve citizens who do or do not want remote work
RemoteWork : string RemoteWork : string
/// Text for a search within a citizen's region, professional bio, skills, experience, and employment history
Text : string
} }

View File

@ -76,7 +76,7 @@ let search : HttpHandler = requireUser >=> fun next ctx -> task {
let form = let form =
match ctx.TryBindQueryString<ProfileSearchForm> () with match ctx.TryBindQueryString<ProfileSearchForm> () with
| Ok f -> f | Ok f -> f
| Error _ -> { ContinentId = ""; RemoteWork = ""; Skill = ""; BioExperience = "" } | Error _ -> { ContinentId = ""; RemoteWork = ""; Text = "" }
let! results = task { let! results = task {
if string ctx.Request.Query["searched"] = "true" then if string ctx.Request.Query["searched"] = "true" then
let! it = Data.search form let! it = Data.search form

View File

@ -438,8 +438,7 @@ let publicSearch (m : PublicSearchForm) continents (results : PublicSearchResult
/// Logged-on search page /// Logged-on search page
let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult list option) = let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult list option) =
pageWithTitle "Search Profiles" [ [ if Option.isNone results then
if Option.isNone results then
p [] [ p [] [
txt "Enter one or more criteria to filter results, or just click &ldquo;Search&rdquo; to list all " txt "Enter one or more criteria to filter results, or just click &ldquo;Search&rdquo; to list all "
txt "profiles." txt "profiles."
@ -448,10 +447,10 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
form [ _class "container"; _method "GET"; _action "/profile/search" ] [ form [ _class "container"; _method "GET"; _action "/profile/search" ] [
input [ _type "hidden"; _name "searched"; _value "true" ] input [ _type "hidden"; _name "searched"; _value "true" ]
div [ _class "row" ] [ 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 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 [] label [ _class "jjj-label" ] [ txt "Seeking Remote Work?" ]; br []
div [ _class "form-check form-check-inline" ] [ div [ _class "form-check form-check-inline" ] [
input [ _type "radio"; _id "remoteNull"; _name (nameof m.RemoteWork); _value "" 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" ] label [ _class "form-check-label"; _for "remoteNo" ] [ txt "No" ]
] ]
] ]
div [ _class "col-12 col-sm-6 col-lg-3" ] [ div [ _class "col-12 col-sm-12 col-lg-6 mb-3" ] [
textBox [ _maxlength "1000" ] (nameof m.Skill) m.Skill "Skill" false textBox [ _maxlength "1000" ] (nameof m.Text) m.Text "Text Search" false
div [ _class "form-text" ] [ txt "(free-form text)" ] div [ _class "form-text" ] [
] txt "searches Region, Professional Biography, Skills, Employment History, and Experience"
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 "row" ] [ div [ _class "row" ] [
@ -515,6 +512,8 @@ let search (m : ProfileSearchForm) continents tz (results : ProfileSearchResult
] ]
| None -> () | None -> ()
] ]
|> pageWithTitle "Search Profiles"
/// Display a profile /// Display a profile
let private displayProfile (it : ProfileForView) isPublic isPrint = let private displayProfile (it : ProfileForView) isPublic isPrint =