From 7e7b51775903ba8f0f9937558376d3d2761c73a2 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 12 Sep 2023 15:51:14 -0400 Subject: [PATCH 1/3] feat: default pagination --- src/controllers/project.controller.js | 16 ++++++++++++++++ src/controllers/units.controller.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/controllers/project.controller.js b/src/controllers/project.controller.js index 28f577b2..3db3872a 100644 --- a/src/controllers/project.controller.js +++ b/src/controllers/project.controller.js @@ -127,6 +127,22 @@ export const findAll = async (req, res) => { order, } = req.query; + if (!page) { + let redirectUrl = `${req.baseUrl}?page=1&limit=10`; + + if (Object.keys(req.query).length > 0) { + redirectUrl = redirectUrl.concat( + '&', + Object.keys(req.query) + .map((key) => `${key}=${req.query[key]}`) + .join('&'), + ); + } + + // Redirect to the modified URL + return res.redirect(301, redirectUrl); + } + let where = orgUid != null && orgUid !== 'all' ? { orgUid } : undefined; if (filter) { diff --git a/src/controllers/units.controller.js b/src/controllers/units.controller.js index 3d103ba0..133dda0c 100644 --- a/src/controllers/units.controller.js +++ b/src/controllers/units.controller.js @@ -133,6 +133,22 @@ export const findAll = async (req, res) => { filter, } = req.query; + if (!page) { + let redirectUrl = `${req.baseUrl}?page=1&limit=10`; + + if (Object.keys(req.query).length > 0) { + redirectUrl = redirectUrl.concat( + '&', + Object.keys(req.query) + .map((key) => `${key}=${req.query[key]}`) + .join('&'), + ); + } + + // Redirect to the modified URL + return res.redirect(301, redirectUrl); + } + let where = orgUid != null && orgUid !== 'all' ? { orgUid } : undefined; if (filter) { From 5da7af79ff579728c51ccafd9631c1bb41548f48 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 14 Sep 2023 14:27:20 -0400 Subject: [PATCH 2/3] chore: bump to 1.6.10 --- package.json | 2 +- src/controllers/project.controller.js | 16 ---------------- src/controllers/units.controller.js | 16 ---------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/package.json b/package.json index b3b3bc22..4162ebc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cadt", - "version": "1.6.8", + "version": "1.6.10", "_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2", "private": true, "bin": "build/server.js", diff --git a/src/controllers/project.controller.js b/src/controllers/project.controller.js index 3db3872a..28f577b2 100644 --- a/src/controllers/project.controller.js +++ b/src/controllers/project.controller.js @@ -127,22 +127,6 @@ export const findAll = async (req, res) => { order, } = req.query; - if (!page) { - let redirectUrl = `${req.baseUrl}?page=1&limit=10`; - - if (Object.keys(req.query).length > 0) { - redirectUrl = redirectUrl.concat( - '&', - Object.keys(req.query) - .map((key) => `${key}=${req.query[key]}`) - .join('&'), - ); - } - - // Redirect to the modified URL - return res.redirect(301, redirectUrl); - } - let where = orgUid != null && orgUid !== 'all' ? { orgUid } : undefined; if (filter) { diff --git a/src/controllers/units.controller.js b/src/controllers/units.controller.js index 133dda0c..3d103ba0 100644 --- a/src/controllers/units.controller.js +++ b/src/controllers/units.controller.js @@ -133,22 +133,6 @@ export const findAll = async (req, res) => { filter, } = req.query; - if (!page) { - let redirectUrl = `${req.baseUrl}?page=1&limit=10`; - - if (Object.keys(req.query).length > 0) { - redirectUrl = redirectUrl.concat( - '&', - Object.keys(req.query) - .map((key) => `${key}=${req.query[key]}`) - .join('&'), - ); - } - - // Redirect to the modified URL - return res.redirect(301, redirectUrl); - } - let where = orgUid != null && orgUid !== 'all' ? { orgUid } : undefined; if (filter) { From 79d33843faaeb20399cb7b2ea4dbdfbf154a1e20 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Fri, 15 Sep 2023 10:55:49 -0400 Subject: [PATCH 3/3] fix: typo in add filestore model function --- package.json | 2 +- src/models/file-store/file-store.model.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4162ebc0..4c07c9d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cadt", - "version": "1.6.10", + "version": "1.6.11", "_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2", "private": true, "bin": "build/server.js", diff --git a/src/models/file-store/file-store.model.js b/src/models/file-store/file-store.model.js index 353cda7d..721ad1bd 100644 --- a/src/models/file-store/file-store.model.js +++ b/src/models/file-store/file-store.model.js @@ -48,7 +48,7 @@ class FileStore extends Model { static async addFileToFileStore(SHA256, fileName, base64File) { const myOrganization = await Organization.getHomeOrg(); - if (myOrganization) { + if (!myOrganization) { throw new Error('No homeorg detected'); }