Skip to content

Commit

Permalink
[service] fix device id null reference in geopackage and csv exports
Browse files Browse the repository at this point in the history
  • Loading branch information
restjohn committed Feb 19, 2024
1 parent 5ef8375 commit 7635e9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions service/src/export/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export class Csv extends Exporter {
if (!cache.user || cache.user._id.toString() !== location.userId.toString()) {
cache.user = await User.getUserById(location.userId)
}
if (!cache.device || cache.device._id.toString() !== flat.deviceId.toString()) {
cache.device = await Device.getDeviceById(flat.deviceId)
if (!cache.device || cache.device._id.toString() !== flat.deviceId?.toString()) {
cache.device = flat.deviceId ? await Device.getDeviceById(flat.deviceId) : undefined
}
if (cache.user) {
flat.user = cache.user.username
Expand Down
9 changes: 5 additions & 4 deletions service/src/export/geopackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ export class GeoPackage extends Exporter {
zoomToEnvelope = calculateBounds(location.geometry, zoomToEnvelope);
userLastLocation = location;

const properties = location.properties || {}
const feature: geojson.Feature<geojson.Point, any> = {
type: 'Feature',
geometry: location.geometry,
properties: location.properties
properties
};
feature.properties.mageId = location._id.toString();
feature.properties.userId = location.userId.toString();
feature.properties.deviceId = location.properties.deviceId.toString();
feature.properties.mageId = location._id.toString()
feature.properties.userId = location.userId?.toString()
feature.properties.deviceId = properties.deviceId ? properties.deviceId.toString() : undefined

if (feature.properties.id) {
delete feature.properties.id;
Expand Down

0 comments on commit 7635e9d

Please sign in to comment.