From 5f4396147f1c390ae3d37b517741cb53efc63309 Mon Sep 17 00:00:00 2001
From: Ramesh Kumar <ramesh.p@matriotsolutions.com>
Date: Thu, 25 Mar 2021 01:03:41 +0530
Subject: [PATCH] TMSS-630: Removed new extended API functions and formatted
 source.

---
 .../tmss_webapp/src/routes/Task/list.js       | 42 ++++++++-----------
 .../src/services/schedule.service.js          | 24 -----------
 2 files changed, 17 insertions(+), 49 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js
index 39b70716ef9..5bdef19b882 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js
@@ -218,10 +218,6 @@ export class TaskList extends Component {
             task.size = 0;
             task.dataSizeOnDisk = 0;
             task.noOfOutputProducts = 0;
-            // task.stop_time = moment(task.stop_time).format(UIConstants.CALENDAR_DATETIME_FORMAT);
-            // task.start_time = moment(task.start_time).format(UIConstants.CALENDAR_DATETIME_FORMAT);
-            // task.created_at =  moment(task.created_at).format(UIConstants.CALENDAR_DATETIME_FORMAT);
-            // task.updated_at =  moment(task.updated_at).format(UIConstants.CALENDAR_DATETIME_FORMAT);
             task.canSelect = task.tasktype.toLowerCase() === 'blueprint' ? true:(task.tasktype.toLowerCase() === 'draft' && task.blueprint_draft.length === 0)?true:false;
             if (dataProducts.length && dataProducts[0].length) {
                 task.dataProducts = dataProducts[0];
@@ -241,30 +237,26 @@ export class TaskList extends Component {
     async componentDidMount() {
         this.subtaskTemplates = await TaskService.getSubtaskTemplates()
         const promises = [
-           // TaskService.getTaskDraftList(),
-            // TaskService.getTaskBlueprintList(),
-            ScheduleService.getScheduleUnitDraftExtended(),
-            ScheduleService.getScheduleUnitBlueprintExtended()
+            ScheduleService.getSchedulingUnitsExtended('draft'), 
+            ScheduleService.getSchedulingUnitsExtended('blueprint')
         ];
         Promise.all(promises).then(async (responses) => {
             let allTasks = [];
-           // this.subTaskTemplates = responses[2];
-           // this.setState({ tasks: [...this.getFormattedTaskDrafts(responses[0]), ...this.getFormattedTaskBlueprints(responses[1])], isLoading: false});
-           for (const schedulingUnit of responses[0]) {
-            let tasks = schedulingUnit.task_drafts?(await this.getFormattedTaskDrafts(schedulingUnit)):this.getFormattedTaskBlueprints(schedulingUnit);
-            let ingestGroup = tasks.map(task => ({name: task.name, canIngest: task.canIngest, type_value: task.type_value, id: task.id }));
-            ingestGroup = _.groupBy(_.filter(ingestGroup, 'type_value'), 'type_value');
-            tasks = await this.formatDataProduct(tasks);
-            allTasks = [...allTasks, ...tasks];
-        }
-        for (const schedulingUnit of responses[1]) {
-            let tasks = schedulingUnit.task_drafts?(await this.getFormattedTaskDrafts(schedulingUnit)):this.getFormattedTaskBlueprints(schedulingUnit);
-            let ingestGroup = tasks.map(task => ({name: task.name, canIngest: task.canIngest, type_value: task.type_value, id: task.id }));
-            ingestGroup = _.groupBy(_.filter(ingestGroup, 'type_value'), 'type_value');
-            tasks = await this.formatDataProduct(tasks);
-            allTasks = [...allTasks, ...tasks];
-        }
-        this.setState({ tasks: allTasks,  isLoading: false });
+            for (const schedulingUnit of responses[0]) {
+                let tasks = schedulingUnit.task_drafts?(await this.getFormattedTaskDrafts(schedulingUnit)):this.getFormattedTaskBlueprints(schedulingUnit);
+                let ingestGroup = tasks.map(task => ({name: task.name, canIngest: task.canIngest, type_value: task.type_value, id: task.id }));
+                ingestGroup = _.groupBy(_.filter(ingestGroup, 'type_value'), 'type_value');
+                tasks = await this.formatDataProduct(tasks);
+                allTasks = [...allTasks, ...tasks];
+            }
+            for (const schedulingUnit of responses[1]) {
+                let tasks = schedulingUnit.task_drafts?(await this.getFormattedTaskDrafts(schedulingUnit)):this.getFormattedTaskBlueprints(schedulingUnit);
+                let ingestGroup = tasks.map(task => ({name: task.name, canIngest: task.canIngest, type_value: task.type_value, id: task.id }));
+                ingestGroup = _.groupBy(_.filter(ingestGroup, 'type_value'), 'type_value');
+                tasks = await this.formatDataProduct(tasks);
+                allTasks = [...allTasks, ...tasks];
+            }
+            this.setState({ tasks: allTasks,  isLoading: false });
         });
     }
 
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 164e2f4a603..eb1d3364f5d 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js
@@ -71,30 +71,6 @@ const ScheduleService = {
         }
         return schedulingUnit;
     },
-    getScheduleUnitDraftExtended: async function() {
-        const { data } = await axios.get(`/api/scheduling_unit_draft_extended/`);
-        for (const schedulingUnit of data.results) {
-            schedulingUnit.blueprintList = (await this.getBlueprintsByschedulingUnitId(schedulingUnit.id)).data.results;
-            const schedulingSet = (await axios.get(`/api/scheduling_set/${schedulingUnit.scheduling_set_id}`)).data;
-            schedulingUnit.scheduling_set_object = schedulingSet;
-            schedulingUnit.scheduling_set = schedulingSet.url;
-        }
-        return data.results;
-    },
-    getScheduleUnitBlueprintExtended: async function() {
-        const { data } = await axios.get(`/api/scheduling_unit_blueprint_extended/`);
-        for (const schedulingUnit of data.results) {
-            const schedulingUnitDraft = (await axios.get(`/api/scheduling_unit_draft/${schedulingUnit.draft_id}/`)).data;
-            schedulingUnit.draft_object = schedulingUnitDraft;
-            schedulingUnit.scheduling_set_id = schedulingUnitDraft.scheduling_set_id;
-            schedulingUnit.scheduling_constraints_template_id = schedulingUnitDraft.scheduling_constraints_template_id;
-            schedulingUnit.scheduling_constraints_doc = schedulingUnitDraft.scheduling_constraints_doc?schedulingUnitDraft.scheduling_constraints_doc:{};
-            const schedulingSet = (await axios.get(`/api/scheduling_set/${schedulingUnit.scheduling_set_id}`)).data;
-            schedulingUnit.scheduling_set_object = schedulingSet;
-            schedulingUnit.scheduling_set = schedulingSet.url;
-        }
-        return data.results;
-    },
     //>>>>>> TODO: Remove this method by using/modifying other functions with additional parameters
     getTaskBPWithSubtaskTemplate: async function(id) {
         let result;
-- 
GitLab