Open lin-d-hop opened 6 months ago
@lin-d-hop the specified user's maps are now available.
Thank you @rogup for pairing with me and formulating the below query searching for map_memberships
that persist after deletion, while the items (markers, polygons or lines) relating to the specified map_membership
have been successfully removed.
User Specific Query
SELECT *
FROM map_memberships
LEFT JOIN user_map
ON user_map.map_id = map_memberships.map_id
WHERE user_id = ####
AND item_type_id = 1
AND item_id NOT IN (SELECT idpolygons FROM polygons);
Check On All Users
SELECT *
FROM map_memberships
LEFT JOIN user_map
ON user_map.map_id = map_memberships.map_id
WHERE item_type_id = 1
AND item_id NOT IN (SELECT idpolygons FROM polygons);
While the exact cause is not clear, @rogup theorised that this scenario is due to a crash during the updateMap
process in which any objects which have changed are removed from the DB and then re-added, or just removed, with the destruction of MapMembership
taking place after the other objects.
By way of preventing this MapMembership.destroy
has been moved above operations that remove markers, polygons etc. within this process. Code refactor implemented in PR https://github.com/DigitalCommons/land-explorer-back-end/pull/59
From queries\maps.ts
if (markerIds.length) {
console.log(
`Removing ${markerIds.length} markers from DB for map ${mapId}`
);
await Marker.destroy({
where: { idmarkers: markerIds },
});
}
if (polygonIds.length) {
console.log(
`Removing ${polygonIds.length} polygons from DB for map ${mapId}`
);
await Polygon.destroy({
where: { idpolygons: polygonIds },
});
}
if (lineIds.length) {
console.log(`Removing ${lineIds.length} lines from DB for map ${mapId}`);
await Line.destroy({
where: { idlinestrings: lineIds },
});
}
\\ MapMemberships removed here
await MapMembership.destroy({
where: { map_id: mapId },
});
Awesome, thanks team! I'll confirm with the user. Sounds like a good solution to prevent this from happening again :)
Confirmed all working for the user :)
Description
A user is unable to open any maps.
BE gives a 500 error preventing the listing of any maps.
@rogup did some detective work:
How to replicate
DM Lynne to get the log in details for the person experiencing the issue.
Acceptance Criteria