Selaa lähdekoodia

Fix limit when getting list of links

poeti8 6 vuotta sitten
vanhempi
säilyke
9c4829c9e8
2 muutettua tiedostoa jossa 1 lisäystä ja 2 poistoa
  1. 0 1
      server/controllers/linkController.ts
  2. 1 1
      server/db/link.ts

+ 0 - 1
server/controllers/linkController.ts

@@ -218,7 +218,6 @@ export const goToLink: Handler = async (req, res, next) => {
 };
 
 export const getUserLinks: Handler = async (req, res) => {
-  // TODO: Use aggregation
   const [countAll, list] = await Promise.all([
     getUserLinksCount({ user_id: req.user.id }),
     getLinks(req.user.id, req.query)

+ 1 - 1
server/db/link.ts

@@ -175,7 +175,7 @@ export const getLinks = async (
   options: IGetLinksOptions = {}
 ) => {
   const { count = "5", page = "1", search = "" } = options;
-  const limit = parseInt(count) > 50 ? parseInt(count) : 50;
+  const limit = parseInt(count) < 50 ? parseInt(count) : 50;
   const offset = (parseInt(page) - 1) * limit;
 
   const model = knex<LinkJoinedDomain>("links")