diff --git a/src/classes/CorporateDashboardController.cls b/src/classes/CorporateDashboardController.cls index 27cf8439..5fb2530b 100644 --- a/src/classes/CorporateDashboardController.cls +++ b/src/classes/CorporateDashboardController.cls @@ -4,6 +4,7 @@ public without sharing class CorporateDashboardController { public Boolean refreshing { get; set;} + public List performanceData { get; set;} public CorporateDashboardController() { this.refreshing = false; @@ -27,4 +28,67 @@ public without sharing class CorporateDashboardController { public void resetRefreshFlag() { this.refreshing = false; } + + public List getData() { + this.performanceData = new List(); + Boolean error = false; + String message = ''; + try { + Reports.reportResults results = Reports.ReportManager.runReport('00Ob00000047rxW', true); + Reports.Dimension dim = results.getGroupingsDown(); + Map columnsInfo = results.getReportExtendedMetadata().getAggregateColumnInfo(); + Reports.GroupingValue groupingVal = dim.getGroupings()[0]; + + Set labelIdx = new Set(); + for (Reports.AggregateColumn agColumn : columnsInfo.values()) { + labelIdx.add(agColumn.getLabel()); + } + + if (!labelIdx.contains('Avg Page Load') || !labelIdx.contains('Avg # of Submissions') || !labelIdx.contains('Avg Server Apdex')) { + error = true; + message = 'Cannot find Aggregates'; + } + + if (error == false) { + for (Reports.GroupingValue gValue : dim.getGroupings()) { + String monthName = gValue.getLabel(); + String factMapKey = gValue.getKey() + '!T'; + + Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey); + System.debug(monthName + ' ' + (Decimal) factDetails.getAggregates()[0].getValue() + ' ' +(Decimal) factDetails.getAggregates()[1].getValue() + + ' ' + (Decimal) factDetails.getAggregates()[2].getValue()); + this.performanceData.add(new DoubleLineChartData(monthName, (Decimal) factDetails.getAggregates()[0].getValue(), (Decimal) factDetails.getAggregates()[1].getValue(), + (Decimal) factDetails.getAggregates()[2].getValue())); + } + } + } catch(Exception e) { + message = e.getMessage(); + error = true; + } + + if (error == true) { + System.debug('Cannot load performance data'); + if (!Test.isRunningTest()) { + EmailHelper.sendEmail(BatchDefaultSettings__c.getOrgDefaults().Error_Emails__c.split(','), 'Cannot load performance data for Corporate Dashboard', + 'report Id : 00Ob00000047rxW ' + message); + } + } + + return this.performanceData; + } + + public class DoubleLineChartData { + + public String name { get; set; } + public Decimal avgPageLoad { get; set; } + public Decimal avgSubmissions { get; set; } + public Decimal avgServerApdex { get; set; } + + public DoubleLineChartData(String name, Decimal avgPageLoad, Decimal avgSubmissions, Decimal avgServerApdex) { + this.name = name; + this.avgPageLoad = avgPageLoad; + this.avgSubmissions = avgSubmissions / 1000.00; + this.avgServerApdex = avgServerApdex; + } + } } \ No newline at end of file diff --git a/src/pages/CorporateDashboardPage.page b/src/pages/CorporateDashboardPage.page index 9be77477..aec7c1ce 100644 --- a/src/pages/CorporateDashboardPage.page +++ b/src/pages/CorporateDashboardPage.page @@ -12,6 +12,9 @@ body .secondaryPalette.bPageBlock { background-color: white; } + .graph { + height: 270px + }