From 2efbd48275e6d157cdbada429b6b5d63b4302f48 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 19 Feb 2020 14:39:49 -0800 Subject: [PATCH] Fixed owner searching. --- .../owner-find-modal.container.jsx | 16 +++++----------- .../schedule-calendar.styles.scss | 1 + .../scheduler-calendar-wrapper.component.jsx | 3 ++- client/src/graphql/owners.queries.js | 2 +- .../down.yaml | 10 ++++++++++ .../up.yaml | 3 +++ .../1582151051596_run_sql_migration/down.yaml | 1 + .../1582151051596_run_sql_migration/up.yaml | 5 +++++ .../1582151260638_run_sql_migration/down.yaml | 1 + .../1582151260638_run_sql_migration/up.yaml | 5 +++++ .../1582151340160_run_sql_migration/down.yaml | 1 + .../1582151340160_run_sql_migration/up.yaml | 11 +++++++++++ 12 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss create mode 100644 hasura/migrations/1582151001705_drop_function_public_search_owners/down.yaml create mode 100644 hasura/migrations/1582151001705_drop_function_public_search_owners/up.yaml create mode 100644 hasura/migrations/1582151051596_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1582151051596_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1582151260638_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1582151260638_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1582151340160_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1582151340160_run_sql_migration/up.yaml diff --git a/client/src/components/owner-find-modal/owner-find-modal.container.jsx b/client/src/components/owner-find-modal/owner-find-modal.container.jsx index 26d9fc3be..e733e25bf 100644 --- a/client/src/components/owner-find-modal/owner-find-modal.container.jsx +++ b/client/src/components/owner-find-modal/owner-find-modal.container.jsx @@ -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({ + {...modalProps}> {loading ? : null} - {error ? : null} + {error ? : null} {owner ? ( diff --git a/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss b/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss new file mode 100644 index 000000000..059edf709 --- /dev/null +++ b/client/src/components/schedule-calendar-wrapper/schedule-calendar.styles.scss @@ -0,0 +1 @@ +@import 'react-big-calendar/lib/sass/styles'; diff --git a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx index a1f4f3428..e54dfd7ab 100644 --- a/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx +++ b/client/src/components/schedule-calendar-wrapper/scheduler-calendar-wrapper.component.jsx @@ -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); diff --git a/client/src/graphql/owners.queries.js b/client/src/graphql/owners.queries.js index d229c3cf7..b236ebd44 100644 --- a/client/src/graphql/owners.queries.js +++ b/client/src/graphql/owners.queries.js @@ -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 diff --git a/hasura/migrations/1582151001705_drop_function_public_search_owners/down.yaml b/hasura/migrations/1582151001705_drop_function_public_search_owners/down.yaml new file mode 100644 index 000000000..7db16d05c --- /dev/null +++ b/hasura/migrations/1582151001705_drop_function_public_search_owners/down.yaml @@ -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 diff --git a/hasura/migrations/1582151001705_drop_function_public_search_owners/up.yaml b/hasura/migrations/1582151001705_drop_function_public_search_owners/up.yaml new file mode 100644 index 000000000..8069a913e --- /dev/null +++ b/hasura/migrations/1582151001705_drop_function_public_search_owners/up.yaml @@ -0,0 +1,3 @@ +- args: + sql: DROP FUNCTION "public"."search_owners"("pg_catalog"."text") + type: run_sql diff --git a/hasura/migrations/1582151051596_run_sql_migration/down.yaml b/hasura/migrations/1582151051596_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1582151051596_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1582151051596_run_sql_migration/up.yaml b/hasura/migrations/1582151051596_run_sql_migration/up.yaml new file mode 100644 index 000000000..6660126ad --- /dev/null +++ b/hasura/migrations/1582151051596_run_sql_migration/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: true + sql: | + drop index owner_gin_idx + type: run_sql diff --git a/hasura/migrations/1582151260638_run_sql_migration/down.yaml b/hasura/migrations/1582151260638_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1582151260638_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1582151260638_run_sql_migration/up.yaml b/hasura/migrations/1582151260638_run_sql_migration/up.yaml new file mode 100644 index 000000000..9601b443c --- /dev/null +++ b/hasura/migrations/1582151260638_run_sql_migration/up.yaml @@ -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 diff --git a/hasura/migrations/1582151340160_run_sql_migration/down.yaml b/hasura/migrations/1582151340160_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1582151340160_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1582151340160_run_sql_migration/up.yaml b/hasura/migrations/1582151340160_run_sql_migration/up.yaml new file mode 100644 index 000000000..06bb94faf --- /dev/null +++ b/hasura/migrations/1582151340160_run_sql_migration/up.yaml @@ -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