Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOROKA-80: Фиксит ошибку в импорте #24

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions src/routes/v1/cards/CsvImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ class Controller {
}

const geoPropertyData = {
propertyId: geoPointProp?.id
}

const geoJsonData = {
name: card.place,
location: {
type: "Point",
coordinates: card.coords.split(',').map(
(coord: string) => parseFloat(coord)
)
},
filledPropertyId: null
propertyId: geoPointProp?.id,
data: [{
name: card.place,
location: {
type: "Point",
coordinates: card.coords.split(',').map(
(coord: string) => parseFloat(coord)
)
}
}]
}

const julianDate = new JulianDate(
Expand Down Expand Up @@ -103,19 +101,12 @@ class Controller {
propertyId: annotationProp?.id
}

// создадим гео-свойство
const createdGeoProperty = await FilledProperty.create(geoPropertyData)

geoJsonData.filledPropertyId = createdGeoProperty.id

await GeoProperty.create(geoJsonData)

// создадим одним запросом все остальные свойства
const createdFilledProps = await FilledProperty.bulkCreate(
[
datePropertyData, cytePropertyData,
sourcePropertyData, tagsPropertyData,
annotationPropertyData
annotationPropertyData, geoPropertyData
]
)

Expand All @@ -127,10 +118,6 @@ class Controller {
(prop) => { return { filledPropertyId: prop.id, cardId: createdCard.id } }
)

filledProps.push(
{ filledPropertyId: createdGeoProperty.id, cardId: createdCard.id }
)

await FilledPropertyCard.bulkCreate(filledProps)
}

Expand Down