Skip to content

Commit

Permalink
fix(adminPanel): RN-1396: Entity import wipes attributes if attribute…
Browse files Browse the repository at this point in the history
…s are not specified in import file (#5829)

* attribute updates

* slight update

* Update Entity.js

* exlude blank rows

* merge: dev -> rn-1396 (#5896)

* deps(security): RN-1096: Update version of `decode-uri-component` (#5850)

Update decide-uri-component

* deps(security): RN-1096: Update version of `jsonwebtoken` (#5851)

* Update json-web-token

* Update jsonwebtoken in auth package

* deps(security): RN-1096: Update XLSX version (#5849)

* Update xlsx

* xlsx fixes

* Handle xlsx blank rows and parsing

* tweak(types): RN-1418: Update EntityType type (#5871)

* Update config for entity type

* Types update

* Fix uses of EntityType

* tweak(adminPanel): RN-1393: Minor Admin panel updates (#5867)

* Scroll on profile pages

* Entity hierarchy export wording

* Handle single button action widths

* Bold active tabs

* Move survey questions to the top of add survey modal

* Fix input colours

* Fix sync logs tooltip

* PR fix

* deps(root): RN-1417: Update storybook version (#5878)

* Basic setup

* Add warmup script

* Update main.ts

* deps(uiChartComponents): RN-1417: Update storybook version PART 2 (#5879)

charts storybook

* deps(uiMapComponents): RN-1417: Update storybook version PART 3 (#5880)

* map components

* Fix tests

* deps(uiComponents): RN-1417: Update storybook version PART 4 (#5881)

* ui components storybook

* Fix tests

* deps(tupaiaWeb): RN-1417: Update storybook version PART 5 (#5882)

* tupaia web storybook

* Fix tests

* Fix build

* tweak(centralServer): RN-1351: Handle bad DHIS2 sync requests (#5887)

Throw an error and register bad requests on dhis sync queue

* tweak(datatrakWeb): RN-1438: Upgrade React Query to V4 (#5868)

* Bumping react-query

* Update render.tsx

* fixing Reports.test.tsx

* navigation bug fix

* removed logging

* tweak(adminPanel): RN-1439: Upgrade React Query to V4 (#5875)

* bumping to v4

* Update yarn.lock

* tweak(psss): RN-1442: Upgrade React Query to V4 (#5874)

* upgrade

* Update yarn.lock

* tweak(lesmis): RN-1441: Upgrade React Query to V4 (#5873)

* upgrade

* Update yarn.lock

* tweak(tupaiaWeb): RN-1440: Upgrade React Query to V4 (#5870)

* Bumping react-query

* Bumping react-query to v4

* Update render.tsx

* GitAction fix

* fixing Reports.test.tsx

* navigation bug fix

* review update

* removed logging

* Update yarn.lock

* Update yarn.lock

* Update VerifyEmailPage.tsx

* Update useReportPreview.js

* fix(adminPanel): Miscellaneous Bug fixes (Tiny) (#5891)

* bugfix

* update

* updates

* tweak(tupaiaWeb): RN-1437: Download files visual restyle (#5889)

* Common download files component

* PR fix

---------

Co-authored-by: Salman <114740396+hrazasalman@users.noreply.github.com>

* Update extractEntitiesByCountryName.js

---------

Co-authored-by: alexd-bes <129009580+alexd-bes@users.noreply.github.com>
Co-authored-by: Tom Caiger <caigertom@gmail.com>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 64356c1 commit 91fb98d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const xlsxParser = filePath => {
(entitiesByCountry, [countryName, sheet]) => ({
...entitiesByCountry,
[countryName]: xlsx.utils
.sheet_to_json(sheet, { raw: false })
.sheet_to_json(sheet, { defval: null, raw: false })
.filter(row => Object.values(row).some(value => value !== null))
.map(row => processXlsxRow(row, { countryName })),
}),
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function updateCountryEntities(
screen_bounds: screenBounds,
category_code: categoryCode,
facility_type: facilityType,
attributes = {},
attributes,
} = entityObject;
if (codes.includes(code)) {
throw new ImportValidationError(
Expand Down Expand Up @@ -175,9 +175,12 @@ export async function updateCountryEntities(
country_code: country.code,
image_url: imageUrl,
metadata: entityMetadata,
attributes,
},
);

if (attributes !== undefined) {
await transactingModels.entity.updateEntityAttributes(code, attributes);
}
if (longitude && latitude) {
await transactingModels.entity.updatePointCoordinates(code, { longitude, latitude });
}
Expand Down
12 changes: 12 additions & 0 deletions packages/database/src/modelClasses/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ export class EntityModel extends MaterializedViewLogDatabaseModel {
);
}

async updateEntityAttributes(code, attributes) {
attributes = attributes ?? {};
return this.database.executeSql(
`
UPDATE "entity"
SET "attributes" = ?
WHERE "code" = ?;
`,
[attributes, code],
);
}

async updateRegionCoordinates(code, geojson) {
const shouldSetBounds =
(
Expand Down

0 comments on commit 91fb98d

Please sign in to comment.