schema: prepared geocoding

TODO: replace mock_geocoding by real geocoding on import + serving from db
This commit is contained in:
Johannes Lötzsch 2022-03-14 12:27:09 +01:00
parent 4fd80a04d4
commit 31bf7a263f
3 changed files with 29 additions and 10 deletions

View File

@ -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))

View File

@ -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<Scalars['Boolean']>;
value_string?: InputMaybe<Scalars['String']>;
};
/** The type that query operations will be rooted at. */
@ -109,6 +109,8 @@ export type Get_Offers = {
note?: Maybe<Scalars['String']>;
place_city?: Maybe<Scalars['String']>;
place_country?: Maybe<Scalars['String']>;
place_lat?: Maybe<Scalars['Float']>;
place_lon?: Maybe<Scalars['Float']>;
place_street?: Maybe<Scalars['String']>;
place_street_number?: Maybe<Scalars['String']>;
place_zip?: Maybe<Scalars['String']>;
@ -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<string> | 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<string> | 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

View File

@ -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