Fixed owner searching.

This commit is contained in:
Patrick Fic
2020-02-19 14:39:49 -08:00
parent f49f460a66
commit 2efbd48275
12 changed files with 46 additions and 13 deletions

View File

@@ -20,12 +20,7 @@ export default function OwnerFindModalContainer({
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
variables: {
search: owner
? `${owner.ownr_fn || ""} ${owner.ownr_ln || ""} ${owner.ownr_addr1 ||
""} ${owner.ownr_city || ""} ${owner.ownr_zip ||
""} ${owner.ownr_ea || ""} ${owner.ownr_ph1 ||
""} ${owner.ownr_ph2 || ""}`
: null
search: owner ? `${owner.ownr_fn || ""} ${owner.ownr_ln || ""}` : null
},
skip: !owner,
fetchPolicy: "network-only"
@@ -35,18 +30,17 @@ export default function OwnerFindModalContainer({
<Modal
title={t("owners.labels.existing_owners")}
width={"80%"}
{...modalProps}
>
{...modalProps}>
{loading ? <LoadingSpinner /> : null}
{error ? <AlertComponent message={error.message} type="error" /> : null}
{error ? <AlertComponent message={error.message} type='error' /> : null}
{owner ? (
<OwnerFindModalComponent
selectedOwner={selectedOwner}
setSelectedOwner={setSelectedOwner}
ownersListLoading={ownersList.loading}
ownersList={
ownersList.data && ownersList.data.search_owners
? ownersList.data.search_owners
ownersList.data && ownersList.data.search_owner
? ownersList.data.search_owner
: null
}
/>

View File

@@ -0,0 +1 @@
@import 'react-big-calendar/lib/sass/styles';

View File

@@ -1,7 +1,8 @@
import moment from "moment";
import React from "react";
import { Calendar, momentLocalizer } from "react-big-calendar";
import "react-big-calendar/lib/css/react-big-calendar.css";
//import "react-big-calendar/lib/css/react-big-calendar.css";
import "./schedule-calendar.styles.scss";
import DateCellWrapper from "../schedule-datecellwrapper/schedule-datecellwrapper.component";
import Event from "../schedule-event/schedule-event.container";
const localizer = momentLocalizer(moment);

View File

@@ -2,7 +2,7 @@ import { gql } from "apollo-boost";
export const QUERY_SEARCH_OWNER_BY_IDX = gql`
query QUERY_SEARCH_OWNER_BY_IDX($search: String!) {
search_owners(args: { search: $search }) {
search_owner(args: { search: $search }) {
ownr_fn
ownr_ln
ownr_ph1

View File

@@ -0,0 +1,10 @@
- args:
sql: "CREATE OR REPLACE FUNCTION public.search_owners(search text)\n RETURNS SETOF
owners\n LANGUAGE sql\n STABLE\nAS $function$\r\n SELECT *\r\n FROM owners\r\n
\ WHERE\r\n search <% (ownr_fn || ' ' || ownr_ln || ' ' || ownr_addr1
\ || ' ' || ownr_city || ' ' || ownr_zip || ' ' || ownr_ea || ' ' || ownr_ph1
|| ' ' || ownr_ph2)\r\n ORDER BY\r\n similarity(search, (ownr_fn ||
' ' || ownr_ln || ' ' || ownr_addr1 || ' ' || ownr_city || ' ' || ownr_zip
\ || ' ' || ownr_ea || ' ' || ownr_ph1 || ' ' || ownr_ph2)) DESC\r\n LIMIT
20;\r\n$function$\n"
type: run_sql

View File

@@ -0,0 +1,3 @@
- args:
sql: DROP FUNCTION "public"."search_owners"("pg_catalog"."text")
type: run_sql

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,5 @@
- args:
cascade: true
sql: |
drop index owner_gin_idx
type: run_sql

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,5 @@
- args:
cascade: true
sql: "CREATE INDEX idx_owner_name ON owners\r\nUSING GIN ((ownr_fn || ' ' || ownr_ln)
gin_trgm_ops);"
type: run_sql

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,11 @@
- args:
cascade: true
sql: "CREATE FUNCTION search_owner(search text)\r\nRETURNS SETOF owners AS $$\r\n
\ SELECT *\r\n FROM owners\r\n WHERE\r\n search <% (ownr_fn ||
' ' || ownr_ln)\r\n ORDER BY\r\n similarity(search, (ownr_fn || ' '
|| ownr_ln)) DESC\r\n LIMIT 5;\r\n$$ LANGUAGE sql STABLE;"
type: run_sql
- args:
name: search_owner
schema: public
type: track_function