From 5dc70e51526cdcb73fe7ad2eba9b174f413e906c Mon Sep 17 00:00:00 2001
From: Ramesh Kumar <r.kumar@redkarma.eu>
Date: Thu, 26 Nov 2020 07:23:44 +0530
Subject: [PATCH] TMSS-473: Added limit to fetch all records from SU drafts and
 blueprints.

---
 .../src/services/schedule.service.js          | 24 +++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
index ba98af2f10d..3fc174325d2 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
@@ -8,22 +8,26 @@ axios.defaults.headers.common['Authorization'] = 'Basic dGVzdDp0ZXN0';
 const ScheduleService = { 
     getSchedulingUnitDraft: async function (){
         let res = [];
-        await axios.get('/api/scheduling_unit_draft/?ordering=id')
-        .then(response => {
-            res= response; 
-        }).catch(function(error) {
+        try {
+            res = await axios.get('/api/scheduling_unit_draft/?limit=1');
+            if (res.data.count > res.data.results.length) {
+                res = await axios.get(`/api/scheduling_unit_draft/?ordering=id&limit=${res.data.count}&offset=0`);
+            }
+        }   catch(error) {
             console.error('[schedule.services.getSchedulingUnitDraft]',error);
-        });
+        }
         return res;
     },
     getSchedulingUnitBlueprint: async function (){
         let res = [];
-        await axios.get('/api/scheduling_unit_blueprint/?ordering=id')
-        .then(response => {
-            res= response; 
-        }).catch(function(error) {
+        try {
+            res = await axios.get('/api/scheduling_unit_blueprint/?limit=1');
+            if (res.data.count > res.data.results.length) {
+                res = await axios.get(`/api/scheduling_unit_blueprint/?ordering=id&limit=${res.data.count}&offset=0`);
+            }
+        }   catch(error) {
             console.error('[schedule.services.getSchedulingUnitBlueprint]',error);
-        });
+        }
         return res;
     },
     getSchedulingUnitBlueprintById: async function (id){
-- 
GitLab