You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eliminate redundant project DB fetches across route handlers (#478)
* Initial plan
* initial plan: eliminate redundant project data queries
Co-authored-by: thehabes <3287006+thehabes@users.noreply.github.com>
* eliminate redundant project data queries across route handlers
- Add optional `project` param to `findPageById()` and `findLayerById()` in shared.js
so callers with a pre-loaded project can skip the redundant DB fetch
- Pass pre-loaded `project` to `findLayerById()` and `findPageById()` in layer/index.js
- Pass pre-loaded `project` to `findPageById()` in page/index.js PUT /:pageId
- Pass pre-loaded `project` to `findPageById()` in line/index.js (POST, PUT, PATCH×2)
- Use `project.data` directly in customMetadataRouter.js GET/POST/PUT /:id/custom
instead of calling `database.findOne()` again after `checkUserAccess()` already loaded it
- Restructure projectReadRouter.js GET /:id to call `loadAsUser()` once and derive the
access check from its result via new `userHasAccess()` helper (saves project+group load)
- Remove redundant `loadAsUser()` call in projectReadRouter.js GET /:id/manifest;
use `project.data` from `checkUserAccess()` for the existence check instead
- Add optional `preloadedProjectData` param to `ProjectFactory.exportManifest()` so
callers with already-loaded data skip the internal `loadAsUser()` fetch
Co-authored-by: thehabes <3287006+thehabes@users.noreply.github.com>
* address code review: add Array.isArray guard in userHasAccess, add comment on loadAsUser error pattern
Co-authored-by: thehabes <3287006+thehabes@users.noreply.github.com>
* no package lock changes
* changes during review
* changes during review
* Changes during review
* Changes during review
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thehabes <3287006+thehabes@users.noreply.github.com>
Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
0 commit comments