mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
feature(backend): save location address
This commit is contained in:
parent
8c0a833d0b
commit
ffd98f23a6
@ -22,7 +22,7 @@ const locales = ['en', 'de', 'fr', 'nl', 'it', 'es', 'pt', 'pl', 'ru']
|
|||||||
|
|
||||||
const createLocation = async (session, mapboxData) => {
|
const createLocation = async (session, mapboxData) => {
|
||||||
const data = {
|
const data = {
|
||||||
id: mapboxData.id,
|
id: mapboxData.id + (mapboxData.address ? `-${mapboxData.address}` : ''),
|
||||||
nameEN: mapboxData.text_en,
|
nameEN: mapboxData.text_en,
|
||||||
nameDE: mapboxData.text_de,
|
nameDE: mapboxData.text_de,
|
||||||
nameFR: mapboxData.text_fr,
|
nameFR: mapboxData.text_fr,
|
||||||
@ -33,6 +33,7 @@ const createLocation = async (session, mapboxData) => {
|
|||||||
namePL: mapboxData.text_pl,
|
namePL: mapboxData.text_pl,
|
||||||
nameRU: mapboxData.text_ru,
|
nameRU: mapboxData.text_ru,
|
||||||
type: mapboxData.id.split('.')[0].toLowerCase(),
|
type: mapboxData.id.split('.')[0].toLowerCase(),
|
||||||
|
address: mapboxData.address,
|
||||||
lng: mapboxData.center && mapboxData.center.length ? mapboxData.center[0] : null,
|
lng: mapboxData.center && mapboxData.center.length ? mapboxData.center[0] : null,
|
||||||
lat: mapboxData.center && mapboxData.center.length ? mapboxData.center[1] : null,
|
lat: mapboxData.center && mapboxData.center.length ? mapboxData.center[1] : null,
|
||||||
}
|
}
|
||||||
@ -54,6 +55,10 @@ const createLocation = async (session, mapboxData) => {
|
|||||||
if (data.lat && data.lng) {
|
if (data.lat && data.lng) {
|
||||||
mutation += ', l.lat = $lat, l.lng = $lng'
|
mutation += ', l.lat = $lat, l.lng = $lng'
|
||||||
}
|
}
|
||||||
|
if (data.address) {
|
||||||
|
mutation += ', l.address = $address'
|
||||||
|
}
|
||||||
|
|
||||||
mutation += ' RETURN l.id'
|
mutation += ' RETURN l.id'
|
||||||
|
|
||||||
await session.writeTransaction((transaction) => {
|
await session.writeTransaction((transaction) => {
|
||||||
@ -72,7 +77,7 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
|
|||||||
locationName,
|
locationName,
|
||||||
)}.json?access_token=${
|
)}.json?access_token=${
|
||||||
CONFIG.MAPBOX_TOKEN
|
CONFIG.MAPBOX_TOKEN
|
||||||
}&types=region,place,country&language=${locales.join(',')}`,
|
}&types=region,place,country,address&language=${locales.join(',')}`,
|
||||||
)
|
)
|
||||||
|
|
||||||
debug(res)
|
debug(res)
|
||||||
@ -103,6 +108,10 @@ export const createOrUpdateLocations = async (nodeLabel, nodeId, locationName, s
|
|||||||
|
|
||||||
let parent = data
|
let parent = data
|
||||||
|
|
||||||
|
if (parent.address) {
|
||||||
|
parent.id += `-${parent.address}`
|
||||||
|
}
|
||||||
|
|
||||||
if (data.context) {
|
if (data.context) {
|
||||||
await asyncForEach(data.context, async (ctx) => {
|
await asyncForEach(data.context, async (ctx) => {
|
||||||
await createLocation(session, ctx)
|
await createLocation(session, ctx)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user