From 31bf7a263ff216136bb0e1fbd4e5a91c13ba6290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=B6tzsch?= Date: Mon, 14 Mar 2022 12:27:09 +0100 Subject: [PATCH] schema: prepared geocoding TODO: replace mock_geocoding by real geocoding on import + serving from db --- .../resolver/root/ngo/get_offers.clj | 23 +++++++++++++++---- frontend/search/codegen/generates.ts | 14 +++++++---- frontend/search/codegen/queries.ts | 2 ++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/backend/src/beherbergung/resolver/root/ngo/get_offers.clj b/backend/src/beherbergung/resolver/root/ngo/get_offers.clj index 37a3c40..7841f04 100644 --- a/backend/src/beherbergung/resolver/root/ngo/get_offers.clj +++ b/backend/src/beherbergung/resolver/root/ngo/get_offers.clj @@ -70,6 +70,7 @@ (s/def ::t_boolean t/boolean #_ (s/with-gen t/boolean #(s/gen boolean?))) (s/def ::t_string t/string #_ (s/with-gen t/string #(s/gen string?))) (s/def ::t_int_string int_string #_ (s/with-gen t/int #(s/gen int?))) +(s/def ::t_float t/float) (s/def :xtdb.api/id (s/nilable ::t_string)) ;; TODO: in future not nilable (s/def ::time_from_str (s/nilable ::t_string)) @@ -81,6 +82,8 @@ (s/def ::place_zip (s/nilable ::t_string)) (s/def ::place_street (s/nilable ::t_string)) (s/def ::place_street_number (s/nilable ::t_string)) +(s/def ::place_lon (s/nilable ::t_float)) +(s/def ::place_lat (s/nilable ::t_float)) (s/def ::accessible (s/nilable ::t_boolean)) (s/def ::animals_allowed (s/nilable ::t_boolean)) (s/def ::animals_present (s/nilable ::t_boolean)) @@ -91,6 +94,7 @@ (s/def ::offer (s/keys :req-un [:xtdb.api/id ::time_from_str ::time_duration_str ::beds ::languages ::place_country ::place_city ::place_zip ::place_street ::place_street_number + ::place_lon ::place_lat ::accessible ::animals_allowed ::animals_present ::contact_name_full ::contact_phone ::contact_email ::note])) @@ -99,6 +103,14 @@ (write-edn "./data/sample-data/example.edn" (gen/sample (s/gen ::offer)))) +(defn mock_geocoding + "just to provide sample data while developing the frontend" + [table] + (map #(-> % + (assoc :place_lon 12.34 + :place_lat 51.34)) + table)) + (s/fdef get_offers :args (s/tuple map? (s/keys :req-un [::auth/auth]) map? map?) :ret (s/nilable (s/* ::offer))) @@ -112,10 +124,11 @@ (when ngo:id ;; TODO: take it from the db and filter it by visibility to the ngo ;; When importing, we want define to which ngo the imported dataset is visible - (if (:import-file env) - (unify (clojure.edn/read-string (slurp (:import-file env))) - mapping_lifeline_wpforms) - (clojure.edn/read-string (slurp "./data/sample-data/example.edn")) ;; till conflict between `specialist-server.type` and `with-gen` is fixed - #_(gen/sample (s/gen ::offer)))))) + (mock_geocoding ;; TODO + (if (:import-file env) + (unify (clojure.edn/read-string (slurp (:import-file env))) + mapping_lifeline_wpforms) + (clojure.edn/read-string (slurp "./data/sample-data/example.edn")) ;; till conflict between `specialist-server.type` and `with-gen` is fixed + #_(gen/sample (s/gen ::offer))))))) (s/def ::get_offers (t/resolver #'get_offers)) diff --git a/frontend/search/codegen/generates.ts b/frontend/search/codegen/generates.ts index 6ac82b0..27ac794 100644 --- a/frontend/search/codegen/generates.ts +++ b/frontend/search/codegen/generates.ts @@ -36,17 +36,17 @@ export type MutationType = { /** If this server supports mutation, the type that mutation operations will be rooted at. */ export type MutationTypeWrite_RwArgs = { auth: Auth; - onEditComplete: OnEditComplete; + onEditCompleteByType: OnEditCompleteByType; }; /** https://reactdatagrid.io/docs/api-reference#props-onEditComplete */ -export type OnEditComplete = { +export type OnEditCompleteByType = { /** Self descriptive. */ columnId: Scalars['String']; /** Self descriptive. */ rowId: Scalars['String']; - /** Self descriptive. */ - value: Scalars['String']; + value_boolean?: InputMaybe; + value_string?: InputMaybe; }; /** The type that query operations will be rooted at. */ @@ -109,6 +109,8 @@ export type Get_Offers = { note?: Maybe; place_city?: Maybe; place_country?: Maybe; + place_lat?: Maybe; + place_lon?: Maybe; place_street?: Maybe; place_street_number?: Maybe; place_zip?: Maybe; @@ -144,7 +146,7 @@ export type GetOffersQueryVariables = Exact<{ }>; -export type GetOffersQuery = { __typename?: 'QueryType', get_offers?: Array<{ __typename?: 'get_offers', id?: string | null, time_from_str?: string | null, time_duration_str?: string | null, beds?: number | null, languages?: Array | null, place_country?: string | null, place_city?: string | null, place_zip?: string | null, place_street?: string | null, place_street_number?: string | null, accessible?: boolean | null, animals_allowed?: boolean | null, animals_present?: boolean | null, contact_name_full?: string | null, contact_phone?: string | null, contact_email?: string | null, note?: string | null }> | null }; +export type GetOffersQuery = { __typename?: 'QueryType', get_offers?: Array<{ __typename?: 'get_offers', id?: string | null, time_from_str?: string | null, time_duration_str?: string | null, beds?: number | null, languages?: Array | null, place_country?: string | null, place_city?: string | null, place_zip?: string | null, place_street?: string | null, place_street_number?: string | null, place_lon?: number | null, place_lat?: number | null, accessible?: boolean | null, animals_allowed?: boolean | null, animals_present?: boolean | null, contact_name_full?: string | null, contact_phone?: string | null, contact_email?: string | null, note?: string | null }> | null }; export type GetRwQueryVariables = Exact<{ auth: Auth; @@ -186,6 +188,8 @@ export const GetOffersDocument = ` place_zip place_street place_street_number + place_lon + place_lat accessible animals_allowed animals_present diff --git a/frontend/search/codegen/queries.ts b/frontend/search/codegen/queries.ts index 2810519..11c3f8a 100644 --- a/frontend/search/codegen/queries.ts +++ b/frontend/search/codegen/queries.ts @@ -18,6 +18,8 @@ export const get_offers = gql` place_zip place_street place_street_number + place_lon + place_lat accessible animals_allowed animals_present