From 0bbe10373cbe1aad6c43a996dc5ecc0dfb3c85d4 Mon Sep 17 00:00:00 2001
From: Ramesh Kumar <ramesh.p@matriotsolutions.com>
Date: Wed, 10 Nov 2021 18:14:30 +0530
Subject: [PATCH] TMSS-986: Scaling report image to page size and fetching
 multiple cycle report added.

---
 .../src/routes/Report/cycle/report.intro.js   |    2 +-
 .../src/routes/Report/cycle/report.main.js    |    7 +-
 .../src/services/report.service.js            | 1255 +----------------
 3 files changed, 9 insertions(+), 1255 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.intro.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.intro.js
index 80f2519c4e9..7a2205409a1 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.intro.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.intro.js
@@ -57,7 +57,7 @@ class CycleReportIntro extends Component {
         return(
             <React.Fragment>
                 <>
-                <div className="report-div" id={`intro-report-div`}>
+                <div className="report-div1" id={`intro-report-div`}>
                     <div id={`intro-cycle-details`}>
                         <h2 style={{textAlign: "center", marginBottom:"25px"}}>Report statistics for Cycles </h2>
                         <div className="p-grid">
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.main.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.main.js
index 5d571b367d3..2777bb9e043 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.main.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Report/cycle/report.main.js
@@ -145,17 +145,16 @@ class CycleReportMain extends Component {
         // Get the div heights of each page of the report
         let divHeights = _.map(reportDivs, 'clientHeight');
         // Create a PDF document with landscape orientation, 1st report div width and the max height of all report divs in pixels
-        const pdf = new jsPDF('l', 'px',  [ (reportDivs[0].clientWidth+50), (reportDivs[0].clientHeight+50)]);
+        const pdf = new jsPDF('l', 'px',  [ (reportDivs[0].clientWidth+100), (reportDivs[0].clientHeight+100)]);
         let pageIndex = 0;
         // Draw each report in canvas and create image of the canvas before saving the pdf
         for (const reportName of _.keys(REPORT_VARIABLE_MAP)) {
             // Create page for each project
             if (pageIndex > 0) {
-                const reportDiv = reportDivs[pageIndex+1];
-                pdf.addPage([reportDiv.clientWidth+50, reportDiv.clientHeight+50], pageIndex===5?'p':'l');     
+                pdf.addPage([reportDivs[0].clientWidth+100, reportDivs[pageIndex].clientHeight+100], pageIndex===5?'p':'l');
             }
             const projectCanvas = await html2canvas(document.getElementById(`${reportName}`));
-            pdf.addImage(projectCanvas.toDataURL('image/jpeg'), 'JPEG', 50, 50);
+            pdf.addImage(projectCanvas.toDataURL('image/jpeg'), 'JPEG', 50, 50, reportDivs[pageIndex].clientWidth, reportDivs[pageIndex].clientHeight);
             pageIndex++;
         }
         // To open the generated PDF in new window
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/report.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/report.service.js
index abc6e16bd7b..7722e7bbe7a 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/services/report.service.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/services/report.service.js
@@ -91,1257 +91,12 @@ const ReportService = {
     },
     getCyclesReport: async(cycleList) => {
       try {
-        //const response = await axios.get(`/api/util/cycles_report/?cycles=${cycleList.join(',')}`);
-        // TODO: loop over cycleList, one request per id, combine results.
-        // for now, I pragmatically just picked the first cycle id (usually, we only query one id anyway)
-        const response = await axios.get(`/api/cycle/${cycleList[0]}/report`);
-        let cycle = cycleList[0];
-
-        const testData = {
-          "Cycle 12": {
-            "cycle": "Cycle 12",
-            "telescope_time_distribution": {
-              "UNASSIGNED": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 200,
-                  "failed": 50,
-                  "idle": 50
-                }
-              },
-              "FILLER": {
-                "durations": {
-                  "total": 200,
-                  "succeeded": 150,
-                  "failed": 30,
-                  "idle": 20
-                }
-              },
-              "REGULAR": {
-                "durations": {
-                  "total": 1500,
-                  "succeeded": 1320,
-                  "failed": 80,
-                  "idle":100
-                }
-              },
-              "USER_SHARED_SUPPORT": {
-                "durations": {
-                  "total": 700,
-                  "succeeded": 650,
-                  "failed": 20,
-                  "idle": 30
-                }
-              },
-              "COMMISSIONING": {
-                "durations": {
-                  "total": 1300,
-                  "succeeded": 1120,
-                  "failed": 120,
-                  "idle": 60
-                }
-              },
-              "DDT": {
-                "durations": {
-                  "total": 200,
-                  "succeeded": 190,
-                  "failed": 5,
-                  "idle": 5
-                }
-              },
-              "TEST": {
-                "durations": {
-                  "total": 600,
-                  "succeeded": 550,
-                  "failed": 20,
-                  "idle": 30
-                }
-              }
-            },
-            "average_efficiency": {
-              "target": "0.85",
-              "efficiency": 0.9
-            },
-            "completion_level": {
-              "target": "0.95",
-              "total": 1000,
-              "succeeded": 850,
-              "prognosis": 960
-            },
-            "observation_hours_per_category": {
-              "DDT Com rep": 80,
-              "System unavailability":null,
-              "total_duration_failed": 100,
-              "total_duration_idle": 200,
-              "total_duration_successful_A": 500,
-              "total_duration_successful_B": 300
-            },
-            "weekly_efficiency": {
-              "weeks": [
-                {
-                  "week": "2019-12-01",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2019-12-08",
-                  "efficiency": 0.85
-                },
-                {
-                  "week": "2019-12-15",
-                  "efficiency": 0.8
-                },
-                {
-                  "week": "2019-12-22",
-                  "efficiency": 0.92
-                },
-                {
-                  "week": "2019-12-29",
-                  "efficiency": 0.93
-                },
-                {
-                  "week": "2020-01-05",
-                  "efficiency": 0.95
-                },
-                {
-                  "week": "2020-01-12",
-                  "efficiency": 0.89
-                },
-                {
-                  "week": "2020-01-19",
-                  "efficiency": 0.79
-                },
-                {
-                  "week": "2020-01-26",
-                  "efficiency": 0.69
-                },
-                {
-                  "week": "2020-02-02",
-                  "efficiency": 0.75
-                },
-                {
-                  "week": "2020-02-09",
-                  "efficiency": 0.7
-                },
-                {
-                  "week": "2020-02-16",
-                  "efficiency": 0.8
-                },
-                {
-                  "week": "2020-02-23",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-01",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-08",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-15",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-22",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-29",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-05",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-12",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-19",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-26",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-03",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-10",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-17",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-24",
-                  "efficiency": 0.9
-                }
-              ]
-            },
-            "data_ingested_per_site_and_category": {
-              "Interferometric Observation": {
-                "size__sum": 140
-              },
-              "Beamformed Observation": {
-                "size__sum": 150
-              },
-              "Preprocessing Pipeline": {
-                "size__sum": 160
-              },
-              "Pulsar Pipeline": {
-                "size__sum": 170
-              }
-            },
-            "projects_summary": [
-              {
-                "project": "high",
-                "quota": [
-                  {
-                    "id": 1,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 12720,
-                  "total_observevd": 200,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 12520,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "normal",
-                "quota": [
-                  {
-                    "id": 2,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "low",
-                "quota": [
-                  {
-                    "id": 3,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              }
-            ],
-            "usage_mode": {
-              "all modes": {
-                "total": null,
-                "observing": null,
-                "idle/test": null
-              },
-              "stand-alone mode": {
-                "total": 887,
-                "no project": null,
-                "project": null,
-                "mixed/no project": null
-              },
-              "ILT mode": {
-                "total": 2570,
-                "observing": 2420,
-                "idle/test": 150
-              }
-            },
-            "failures": {months: [{month: "2020-03-01", total_failed: 1200}, {month: "2020-04-01", total_failed: 1300}]}
-          },
-          "Cycle 13": {
-            "cycle": "Cycle 13",
-            "telescope_time_distribution": {
-              "UNASSIGNED": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 400,
-                  "failed": 50,
-                  "idle": 50
-                }
-              },
-              "FILLER": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 280,
-                  "failed": 0,
-                  "idle": 20
-                }
-              },
-              "REGULAR": {
-                "durations": {
-                  "total": 1000,
-                  "succeeded": 920,
-                  "failed": 20,
-                  "idle": 60
-                }
-              },
-              "USER_SHARED_SUPPORT": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 450,
-                  "failed": 0,
-                  "idle": 50
-                }
-              },
-              "COMMISSIONING": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 220,
-                  "failed": 70,
-                  "idle": 10
-                }
-              },
-              "DDT": {
-                "durations": {
-                  "total": 200,
-                  "succeeded": 190,
-                  "failed": 5,
-                  "idle": 5
-                }
-              },
-              "TEST": {
-                "durations": {
-                  "total": 600,
-                  "succeeded": 550,
-                  "failed": 20,
-                  "idle": 30
-                }
-              }
-            },
-            "average_efficiency": {
-              "target": "0.65",
-              "efficiency": 0.7
-            },
-            "completion_level": {
-              "target": "0.9",
-              "total": 100,
-              "succeeded": 80,
-              "prognosis": 95
-            },
-            "observation_hours_per_category": {
-              "DDT Com rep": 40,
-              "System unavailability":null,
-              "total_duration_failed": 10,
-              "total_duration_idle": 20,
-              "total_duration_successful_A": 100,
-              "total_duration_successful_B": 50
-            },
-            "weekly_efficiency": {
-              "weeks": [
-                {
-                  "week": "2019-12-01",
-                  "efficiency": 0.8
-                },
-                {
-                  "week": "2019-12-08",
-                  "efficiency": 0.75
-                },
-                {
-                  "week": "2019-12-15",
-                  "efficiency": 0.85
-                },
-                {
-                  "week": "2019-12-22",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2019-12-29",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-01-05",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-01-12",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-01-19",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-01-26",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-02-02",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-02-09",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-02-16",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-02-23",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-01",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-08",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-15",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-22",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-03-29",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-05",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-12",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-19",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-04-26",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-03",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-10",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-17",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-05-24",
-                  "efficiency": 0.9
-                }
-              ]
-            },
-            "data_ingested_per_site_and_category": {
-              "Interferometric Observation": {
-                "size__sum": 140
-              },
-              "Beamformed Observation": {
-                "size__sum": 150
-              },
-              "Preprocessing Pipeline": {
-                "size__sum": 160
-              },
-              "Pulsar Pipeline": {
-                "size__sum": 170
-              }
-            },
-            "projects_summary": [
-              {
-                "project": "high",
-                "quota": [
-                  {
-                    "id": 1,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 12720,
-                  "total_observed": 700,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 12020,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "normal",
-                "quota": [
-                  {
-                    "id": 2,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "low",
-                "quota": [
-                  {
-                    "id": 3,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              }
-            ],
-            "usage_mode": {
-              "all modes": {
-                "total": null,
-                "observing": null,
-                "idle/test": null
-              },
-              "stand-alone mode": {
-                "total": 983,
-                "no project": null,
-                "project": null,
-                "mixed/no project": null
-              },
-              "ILT mode": {
-                "total": 2573,
-                "observing": 2430,
-                "idle/test": 143
-              }
-            },
-            "failures": {months: []}
-          },
-          "Cycle 14": {
-            "cycle": "Cycle 14",
-            "telescope_time_distribution": {
-              "UNASSIGNED": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 400,
-                  "failed": 50,
-                  "idle": 50
-                }
-              },
-              "FILLER": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 280,
-                  "failed": 0,
-                  "idle": 20
-                }
-              },
-              "REGULAR": {
-                "durations": {
-                  "total": 1000,
-                  "succeeded": 920,
-                  "failed": 20,
-                  "idle": 60
-                }
-              },
-              "USER_SHARED_SUPPORT": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 450,
-                  "failed": 0,
-                  "idle": 50
-                }
-              },
-              "COMMISSIONING": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 220,
-                  "failed": 70,
-                  "idle": 10
-                }
-              },
-              "DDT": {
-                "durations": {
-                  "total": 200,
-                  "succeeded": 190,
-                  "failed": 5,
-                  "idle": 5
-                }
-              },
-              "TEST": {
-                "durations": {
-                  "total": 600,
-                  "succeeded": 550,
-                  "failed": 20,
-                  "idle": 30
-                }
-              }
-            },
-            "average_efficiency": {
-              "target": "0.65",
-              "efficiency": 0.7
-            },
-            "completion_level": {
-              "target": "0.9",
-              "total": 100,
-              "succeeded": 80,
-              "prognosis": 95
-            },
-            "observation_hours_per_category": {
-              "DDT Com rep": 60,
-              "System unavailability":null,
-              "total_duration_failed": 10,
-              "total_duration_idle": 20,
-              "total_duration_successful_A": 100,
-              "total_duration_successful_B": 50
-            },
-          "weekly_efficiency": {
-              "weeks": [
-                {
-                  "week": "2020-06-01",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-06-08",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-06-15",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-06-22",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-06-29",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-07-06",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-07-13",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-07-20",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-07-27",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-08-03",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-08-10",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-08-17",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-08-24",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-08-31",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-09-07",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-09-14",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-09-21",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-09-28",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-10-05",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-10-12",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-10-19",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-10-26",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-11-02",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-11-09",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-11-16",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-11-23",
-                  "efficiency": 0.9
-                }
-              ]
-            },
-            "data_ingested_per_site_and_category": {
-              "Interferometric Observation": {
-                "size__sum": 140
-              },
-              "Beamformed Observation": {
-                "size__sum": 150
-              },
-              "Preprocessing Pipeline": {
-                "size__sum": 160
-              },
-              "Pulsar Pipeline": {
-                "size__sum": 170
-              }
-            },
-            "projects_summary": [
-              {
-                "project": "high",
-                "quota": [
-                  {
-                    "id": 1,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 12720,
-                  "total_observed": 10000,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 2720,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "normal",
-                "quota": [
-                  {
-                    "id": 2,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "low",
-                "quota": [
-                  {
-                    "id": 3,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              }
-            ],
-            "usage_mode": {
-              "all modes": {
-                "total": null,
-                "observing": null,
-                "idle/test": null
-              },
-              "stand-alone mode": {
-                "total": 798,
-                "no project": null,
-                "project": null,
-                "mixed/no project": null
-              },
-              "ILT mode": {
-                "total": 3594,
-                "observing": 2258,
-                "idle/test": 955
-              }
-            },
-            "failures": {months:[{month: "2020-03-01", total_failed: 1200}, {month: "2020-04-01", total_failed: 1300}]}
-          },
-          "Cycle 15": {
-            "cycle": "Cycle 15",
-            "telescope_time_distribution": {
-              "UNASSIGNED": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 400,
-                  "failed": 50,
-                  "idle": 50
-                }
-              },
-              "FILLER": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 280,
-                  "failed": 0,
-                  "idle": 20
-                }
-              },
-              "REGULAR": {
-                "durations": {
-                  "total": 1000,
-                  "succeeded": 920,
-                  "failed": 20,
-                  "idle": 60
-                }
-              },
-              "USER_SHARED_SUPPORT": {
-                "durations": {
-                  "total": 500,
-                  "succeeded": 450,
-                  "failed": 0,
-                  "idle": 50
-                }
-              },
-              "COMMISSIONING": {
-                "durations": {
-                  "total": 300,
-                  "succeeded": 220,
-                  "failed": 70,
-                  "idle": 10
-                }
-              },
-              "DDT": {
-                "durations": {
-                  "total": 200,
-                  "succeeded": 190,
-                  "failed": 5,
-                  "idle": 5
-                }
-              },
-              "TEST": {
-                "durations": {
-                  "total": 600,
-                  "succeeded": 550,
-                  "failed": 20,
-                  "idle": 30
-                }
-              }
-            },
-            "average_efficiency": {
-              "target": "0.65",
-              "efficiency": 0.7
-            },
-            "completion_level": {
-              "target": "0.9",
-              "total": 100,
-              "succeeded": 80,
-              "prognosis": 95
-            },
-            "observation_hours_per_category": {
-              "DDT Com rep": 60,
-              "System unavailability":null,
-              "total_duration_failed": 10,
-              "total_duration_idle": 20,
-              "total_duration_successful_A": 100,
-              "total_duration_successful_B": 50
-            },
-            "weekly_efficiency": {
-              "weeks": [
-                {
-                  "week": "2020-12-01",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-12-08",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-12-15",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-12-22",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2020-12-29",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-01-05",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-01-12",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-01-19",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-01-26",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-02-02",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-02-09",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-02-16",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-02-23",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-03-02",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-03-09",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-03-16",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-03-23",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-03-30",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-04-06",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-04-13",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-04-20",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-04-27",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-05-04",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-05-11",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-05-18",
-                  "efficiency": 0.9
-                },
-                {
-                  "week": "2021-05-25",
-                  "efficiency": 0.9
-                }
-              ]
-            },
-            "data_ingested_per_site_and_category": {
-              "Interferometric Observation": {
-                "size__sum": 140
-              },
-              "Beamformed Observation": {
-                "size__sum": 150
-              },
-              "Preprocessing Pipeline": {
-                "size__sum": 160
-              },
-              "Pulsar Pipeline": {
-                "size__sum": 170
-              }
-            },
-            "projects_summary": [
-              {
-                "project": "high",
-                "quota": [
-                  {
-                    "id": 1,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 12720,
-                  "total_observed": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 12720,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "normal",
-                "quota": [
-                  {
-                    "id": 2,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              },
-              {
-                "project": "low",
-                "quota": [
-                  {
-                    "id": 3,
-                    "resource_type_id": "LTA Storage",
-                    "value": 1000000000000
-                  }
-                ],
-                "SUBs": {
-                  "finished": [],
-                  "failed": []
-                },
-                "durations": {
-                  "total": 0,
-                  "total_succeeded": 0,
-                  "total_not_cancelled": 0,
-                  "total_failed": 0
-                },
-                "LTA dataproducts": {
-                  "size__sum": null
-                },
-                "SAPs": [
-                  {
-                    "sap_name": "placeholder",
-                    "total_exposure": 0
-                  }
-                ]
-              }
-            ],
-            "usage_mode": {
-              "all modes": {
-                "total": null,
-                "observing": null,
-                "idle/test": null
-              },
-              "stand-alone mode": {
-                "total": 908,
-                "no project": null,
-                "project": null,
-                "mixed/no project": null
-              },
-              "ILT mode": {
-                "total": 3436,
-                "observing": 1881,
-                "idle/test": 980
-              }
-            },
-            "failures": {months: [{month: "2020-06-01", total_failed: 1200}, {month: "2020-07-01", total_failed: 1300}]}
-          },
-          "Cycle 16": {"cycle": "Cycle 16", "telescope_time_distribution": {"UNASSIGNED": {"durations": {"total": 720.0, "succeeded": 720.0, "succeeded_perc": 1.0, "failed": 0, "failed_perc": 0.0, "idle": 0.0, "idle_perc": 0.0}}, "FILLER": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}, "REGULAR": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}, "USER_SHARED_SUPPORT": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}, "COMMISSIONING": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}, "DDT": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}, "TEST": {"durations": {"total": 0, "succeeded": 0, "succeeded_perc": null, "failed": 0, "failed_perc": null, "idle": 0, "idle_perc": null}}}, "average_efficiency": {"target": 0.65, "efficiency": 0.01}, "completion_level": {"target": 0.0, "total": 720.0, "succeeded": 720.0, "succeeded_perc": 1.0, "prognosis": 0.0}, "observation_hours_per_category": {"total_duration": 720.0, "total_duration_successful": 720.0, "total_duration_failed": 0, "total_duration_idle": 0.0, "DDT Com Rep": 0, "System Unavailability": null, "total_duration_successful_A": 720.0, "successful_A_perc": 1.0, "total_duration_successful_B": 0, "successful_B_perc": 0.0, "successful_perc": 1.0, "idle_perc": 0.0, "failed_perc": 0.0, "ddt_com_rep_perc": 0.0, "system_unavailability_perc": null}, "weekly_efficiency": {"weeks": [{"week": "2021-06-01", "efficiency": null}, {"week": "2021-06-08", "efficiency": null}, {"week": "2021-06-15", "efficiency": null}, {"week": "2021-06-22", "efficiency": null}, {"week": "2021-06-29", "efficiency": null}, {"week": "2021-07-06", "efficiency": null}, {"week": "2021-07-13", "efficiency": null}, {"week": "2021-07-20", "efficiency": null}, {"week": "2021-07-27", "efficiency": null}, {"week": "2021-08-03", "efficiency": null}, {"week": "2021-08-10", "efficiency": null}, {"week": "2021-08-17", "efficiency": 1.0}, {"week": "2021-08-24", "efficiency": null}, {"week": "2021-08-31", "efficiency": null}, {"week": "2021-09-07", "efficiency": null}, {"week": "2021-09-14", "efficiency": null}, {"week": "2021-09-21", "efficiency": null}, {"week": "2021-09-28", "efficiency": null}, {"week": "2021-10-05", "efficiency": null}, {"week": "2021-10-12", "efficiency": null}, {"week": "2021-10-19", "efficiency": null}, {"week": "2021-10-26", "efficiency": null}, {"week": "2021-11-02", "efficiency": null}, {"week": "2021-11-09", "efficiency": null}, {"week": "2021-11-16", "efficiency": null}, {"week": "2021-11-23", "efficiency": null}]}, "data_ingested_per_site_and_category": {"Interferometric Observation": {"size__sum": 0}, "Beamformed Observation": {"size__sum": null}, "Preprocessing Pipeline": {"size__sum": null}, "Pulsar Pipeline": {"size__sum": null}}, "projects_summary": [{"project": "normal", "quota": [{"id": 2, "resource_type_id": "LTA Storage", "value": 1000000000000.0}], "SUBs": {"successful": [], "failed": []}, "durations": {"total": 2160.0, "total_not_cancelled": 2160.0, "total_succeeded": 0, "total_failed": 0, "total_observed": 0, "total_observed_succeeded": 0, "total_observed_failed": 0, "total_succeeded_A": 0, "total_observed_succeeded_A": 0, "total_succeeded_B": 0, "total_observed_succeeded_B": 0, "not_cancelled_perc": 1.0, "succeeded_perc": 0.0, "failed_perc": 0.0, "observed_perc": 0.0, "observed_succeeded_perc": 0.0, "observed_failed_perc": 0.0}, "LTA dataproducts": {"size__sum": null}, "SAPs exposure": {"Polaris": 120.0}}, {"project": "low", "quota": [{"id": 3, "resource_type_id": "LTA Storage", "value": 1000000000000.0}], "SUBs": {"successful": [], "failed": []}, "durations": {"total": 87720.0, "total_not_cancelled": 87720.0, "total_succeeded": 0, "total_failed": 0, "total_observed": 0, "total_observed_succeeded": 0, "total_observed_failed": 0, "total_succeeded_A": 0, "total_observed_succeeded_A": 0, "total_succeeded_B": 0, "total_observed_succeeded_B": 0, "not_cancelled_perc": 1.0, "succeeded_perc": 0.0, "failed_perc": 0.0, "observed_perc": 0.0, "observed_succeeded_perc": 0.0, "observed_failed_perc": 0.0}, "LTA dataproducts": {"size__sum": null}, "SAPs exposure": {"target1": 28800.0, "target2": 28800.0}}, {"project": "high", "quota": [{"id": 1, "resource_type_id": "LTA Storage", "value": 1099511627776.0}, {"id": 4, "resource_type_id": "LOFAR Observing Time", "value": 72000.0}, {"id": 5, "resource_type_id": "CEP Processing Time", "value": 72000.0}], "SUBs": {"successful": [{"id": 1, "name": "Obs high 1", "status": "finished", "start": "2021-08-18T21:35:22", "stop": "2021-08-18T21:47:22", "duration": 720.0, "observed_duration": 720.0, "target": "Observation", "SAS ID": {"observation control": [2000000], "preprocessing pipeline": [2000003], "pulsar pipeline": []}, "ingested_date": null, "ingested_data_size": null}], "failed": []}, "durations": {"total": 12720.0, "total_not_cancelled": 12720.0, "total_succeeded": 720.0, "total_failed": 0, "total_observed": 720.0, "total_observed_succeeded": 720.0, "total_observed_failed": 0, "total_succeeded_A": 720.0, "total_observed_succeeded_A": 720.0, "total_succeeded_B": 0, "total_observed_succeeded_B": 0, "not_cancelled_perc": 1.0, "succeeded_perc": 0.06, "failed_perc": 0.0, "observed_perc": 0.06, "observed_succeeded_perc": 0.06, "observed_failed_perc": 0.0}, "LTA dataproducts": {"size__sum": null}, "SAPs exposure": {"target1": 7200.0, "target2": 7200.0, "B0329+54": 120.0, "Polaris": 120.0}}], "usage_mode": {"all modes": {"total": null, "observing": null, "idle/test": null}, "stand-alone mode": {"total": null, "no project": null, "project": null, "mixed/no project": null}, "ILT mode": {"total": null, "observing": null, "idle/test": null}}, "failures": {"months": [{"month": "2021-06-01", "total": 0, "total_failed": 0, "failed_perc": null}, {"month": "2021-07-01", "total": 0, "total_failed": 0, "failed_perc": null}, {"month": "2021-08-01", "total": 720.0, "total_failed": 0, "failed_perc": 0.0}, {"month": "2021-09-01", "total": 0, "total_failed": 0, "failed_perc": null}, {"month": "2021-10-01", "total": 0, "total_failed": 0, "failed_perc": null}, {"month": "2021-11-01", "total": 0, "total_failed": 0, "failed_perc": null}]}}
+        let cycleReportData = [];
+        for(const cycle of cycleList) {
+          const response = await axios.get(`/api/cycle/${cycle}/report`);
+          cycleReportData.push(response.data)
         }
-        return {cycle: response.data};
-        // return _.filter(testData, data => { return cycleList.indexOf(data.cycle)>=0 }) ;
+        return cycleReportData;
       } catch(error) {
         console.error(error);
         return null;
-- 
GitLab