Skip to content

Commit

Permalink
Merge pull request #3023 from FlowFuse/3021-avoid-needless-settings-q…
Browse files Browse the repository at this point in the history
…uery

Avoid needless settings lookup on instance list endpoint
  • Loading branch information
knolleary authored Oct 27, 2023
2 parents 8a690a6 + c1019c4 commit 1a159ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions forge/db/views/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ module.exports = function (app) {
return result
}

// This view is only used by the 'deprecated' /team/:teamId/projects end point.
// However it is still used in a few places from the frontend. None of them
// require the full details of the instances - so the settings object can be omitted
async function instancesList (instancesArray) {
return Promise.all(instancesArray.map(async (instance) => {
// Full settings are not
const result = await app.db.views.Project.project(instance, { includeSettings: true })
// Full settings are not required for the instance summary list
const result = await app.db.views.Project.project(instance, { includeSettings: false })

if (!result.url) {
delete result.url
Expand Down
6 changes: 5 additions & 1 deletion forge/routes/api/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ module.exports = async function (app) {

/**
* @deprecated Use /:teamId/applications, or /:applicationId/instances
* This end-point is still used by the project nodes and nr-tools plugin.
* This end-point is still used by:
* - the project nodes and nr-tools plugin.
* - the Team Instances view
* - team/Devices/dialogs/CreateProvisionTokenDialog.vue
* - team/Settings/Devices.vue
*/
app.get('/:teamId/projects', {
preHandler: app.needsPermission('team:projects:list')
Expand Down

0 comments on commit 1a159ba

Please sign in to comment.