Shirly Radco has uploaded a new change for review.

Change subject: reports: br4b report - added comments to queries
......................................................................

reports: br4b report - added comments to queries

Changed the code structure so it will be more readable
and added commets.

Change-Id: I95c0f2dc843f2c2fefe1c7f193293751b31a5a6b
Signed-off-by: Shirly Radco <[email protected]>
---
M 
packaging/ovirt-reports/resources/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml.data
1 file changed, 398 insertions(+), 267 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/40/27840/1

diff --git 
a/packaging/ovirt-reports/resources/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml.data
 
b/packaging/ovirt-reports/resources/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml.data
index c5af141..58be6d4 100644
--- 
a/packaging/ovirt-reports/resources/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml.data
+++ 
b/packaging/ovirt-reports/resources/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml.data
@@ -1,270 +1,401 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports 
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"; name="BR4B" 
language="groovy" pageWidth="832" pageHeight="585" orientation="Landscape" 
whenNoDataType="AllSectionsNoDetail" columnWidth="832" leftMargin="0" 
rightMargin="0" topMargin="0" bottomMargin="0" 
resourceBundle="ovirt_reports_bundle" whenResourceMissingType="Error">
-    <property name="ireport.jasperserver.reportUnit" 
value="/reports_resources/embedded_reports/Five_most_utilized_hosts_over_time"/>
-    <property name="ireport.jasperserver.url" 
value="http://localhost:8080/jasperserver/services/repository"/>
-    <property name="ireport.zoom" value="1.0"/>
-    <property name="ireport.x" value="0"/>
-    <property name="ireport.y" value="0"/>
-    <parameter name="is_deleted" class="java.lang.String">
-        <defaultValueExpression><![CDATA["AND delete_date IS 
NULL"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="P_Start_Date" class="java.util.Date">
-        
<defaultValueExpression><![CDATA["2000-01-01"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="P_Period" class="java.lang.Short">
-        <parameterDescription><![CDATA[Period]]></parameterDescription>
-        <defaultValueExpression><![CDATA[0]]></defaultValueExpression>
-    </parameter>
-    <parameter name="P_DataCenter_ID" class="java.lang.String">
-        <parameterDescription><![CDATA[Select a 
DataCenter]]></parameterDescription>
-        
<defaultValueExpression><![CDATA["11111111-1111-1111-1111-111111111111"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="P_Cluster_ID" class="java.lang.String">
-        <parameterDescription><![CDATA[Select a 
Cluster]]></parameterDescription>
-        
<defaultValueExpression><![CDATA["11111111-1111-1111-1111-111111111111"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="P_Host_Type" class="java.lang.Integer">
-        <parameterDescription><![CDATA[Select Host 
Type]]></parameterDescription>
-        <defaultValueExpression><![CDATA[-1]]></defaultValueExpression>
-    </parameter>
-    <parameter name="REPORT_NAME" class="java.lang.String" 
isForPrompting="false"/>
-    <parameter name="SUBREPORT_DIR" class="java.lang.String" 
isForPrompting="false">
-        <defaultValueExpression><![CDATA["C:\\Program 
Files\\jasperserver-pro-3.7\\"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="table_name" class="java.lang.String">
-        <defaultValueExpression><![CDATA[$P{P_Period} == 0 ? "hourly" : 
"daily"]]></defaultValueExpression>
-    </parameter>
-    <parameter name="calendar_column" class="java.lang.String">
-        <defaultValueExpression><![CDATA[$P{P_Period} == 0 ? "the_datetime" : 
"the_date"]]></defaultValueExpression>
-    </parameter>
-    <queryString>
-        <![CDATA[select distinct $P!{calendar_column} as the_date, 
coalesce(host_name,max(host_name) over (partition by 1),'') as host_name, 
CPU_Usage, MEM_Usage
-from (SELECT v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id,
-            CASE
-                WHEN delete_date IS NULL THEN host_name
-                ELSE host_name || ' (Removed on ' || cast(cast(delete_date as 
date) as varchar) || ')'
-            END as host_name,
-            
v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime AS time,
-            
SUM(coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.max_cpu_usage,
 
0)*coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,0))/SUM(coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,0))
 AS CPU_Usage,
-            
SUM(coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.max_memory_usage,0)*coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,0))/SUM(coalesce(v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,0))
 AS MEM_Usage
+<!-- Created with Jaspersoft Studio version 5.5.0-->
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports 
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"; name="BR4B" 
language="groovy" pageWidth="832" pageHeight="585" orientation="Landscape" 
whenNoDataType="AllSectionsNoDetail" columnWidth="832" leftMargin="0" 
rightMargin="0" topMargin="0" bottomMargin="0" 
resourceBundle="ovirt_reports_bundle" whenResourceMissingType="Error" 
uuid="2630d0ea-ea1c-44d5-b3cb-2c7fd0698a78">
+       <property name="ireport.jasperserver.reportUnit" 
value="/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time"/>
+       <property name="ireport.jasperserver.url" 
value="http://localhost:8080/jasperserver-pro/"/>
+       <property name="ireport.zoom" value="1.0"/>
+       <property name="ireport.x" value="0"/>
+       <property name="ireport.y" value="0"/>
+       <property name="ireport.jasperserver.report.resource" 
value="/reports_resources/embedded_reports/Trends_Dashboard/Five_most_utilized_hosts_over_time_files/Five_most_utilized_hosts_over_time_jrxml"/>
+       <parameter name="is_deleted" class="java.lang.String">
+               <defaultValueExpression><![CDATA["AND delete_date IS 
NULL"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="P_Start_Date" class="java.util.Date">
+               
<defaultValueExpression><![CDATA["2000-01-01"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="P_Period" class="java.lang.Short">
+               <parameterDescription><![CDATA[Period]]></parameterDescription>
+               <defaultValueExpression><![CDATA[0]]></defaultValueExpression>
+       </parameter>
+       <parameter name="P_DataCenter_ID" class="java.lang.String">
+               <parameterDescription><![CDATA[Select a 
DataCenter]]></parameterDescription>
+               
<defaultValueExpression><![CDATA["11111111-1111-1111-1111-111111111111"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="P_Cluster_ID" class="java.lang.String">
+               <parameterDescription><![CDATA[Select a 
Cluster]]></parameterDescription>
+               
<defaultValueExpression><![CDATA["11111111-1111-1111-1111-111111111111"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="P_Host_Type" class="java.lang.Integer">
+               <parameterDescription><![CDATA[Select Host 
Type]]></parameterDescription>
+               <defaultValueExpression><![CDATA[-1]]></defaultValueExpression>
+       </parameter>
+       <parameter name="REPORT_NAME" class="java.lang.String" 
isForPrompting="false"/>
+       <parameter name="SUBREPORT_DIR" class="java.lang.String" 
isForPrompting="false">
+               <defaultValueExpression><![CDATA["C:\\Program 
Files\\jasperserver-pro-3.7\\"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="table_name" class="java.lang.String">
+               <defaultValueExpression><![CDATA[$P{P_Period} == 0 ? "hourly" : 
"daily"]]></defaultValueExpression>
+       </parameter>
+       <parameter name="calendar_column" class="java.lang.String">
+               <defaultValueExpression><![CDATA[$P{P_Period} == 0 ? 
"the_datetime" : "the_date"]]></defaultValueExpression>
+       </parameter>
+       <queryString language="SQL">
+               <![CDATA[-- BR4B - This report returns the
+-- cpu and memory usage over time
+-- for the 5 most utilized hosts.
+
+SELECT DISTINCT
+    $P!{calendar_column} AS the_date,
+    COALESCE (
+        host_name,
+        MAX ( host_name ) over ( partition by 1 ),
+        ''
+    ) AS host_name,
+    CPU_Usage,
+    MEM_Usage
+FROM (
+    SELECT
+        v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id,
+        CASE
+            WHEN delete_date IS NULL
+                THEN host_name
+            ELSE
+                host_name
+                ||
+                ' (Removed on '
+                ||
+                CAST (
+                    CAST ( delete_date AS date )
+                    AS varchar
+                )
+                ||
+                ')'
+        END AS host_name,
+        v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime 
AS time,
+        SUM (
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.max_cpu_usage,
+                0
+            ) *
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,
+                0
+            )
+        ) /
+        SUM (
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,
+                0
+            )
+        ) AS CPU_Usage,
+        SUM (
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.max_memory_usage,
+                0
+            ) *
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,
+                0
+            )
+        ) /
+        SUM (
+            COALESCE (
+                
v3_5_statistics_hosts_resources_usage_$P!{table_name}.minutes_in_status,
+                0
+            )
+        ) AS MEM_Usage
+    -- If "Period" equals to "Daily" then "table_name" parameter equals to 
"hourly" else "daily"
     FROM v3_5_statistics_hosts_resources_usage_$P!{table_name}
-            INNER JOIN v3_5_configuration_history_hosts
-                ON (v3_5_configuration_history_hosts.host_id = 
v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id)
-    WHERE    
v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime >= 
cast($P{P_Start_Date} as timestamp)
-            AND 
v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime <= CASE
-                                                                    WHEN 
$P{P_Period} = 0 THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 day'
-                                                                    WHEN 
$P{P_Period} = 1 THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 month'
-                                                                    WHEN 
$P{P_Period} = 2 THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '3 month'
-                                                                    WHEN 
$P{P_Period} = 3 THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 year'
-                                                                END
-            AND v3_5_configuration_history_hosts.history_id in (SELECT 
max(a.history_id)
-                                    FROM v3_5_configuration_history_hosts as a
-                                    GROUP BY a.host_id)
-            AND v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id 
IN
-                ( -- Calculation of Top 5 Hosts
-                 SELECT a.host_id
-                 FROM v3_5_statistics_hosts_resources_usage_$P!{table_name} a
-                        INNER JOIN v3_5_configuration_history_hosts b
-                            ON (a.host_id = b.host_id)
-                 WHERE    b.cluster_id in (SELECT 
v3_5_configuration_history_clusters.cluster_id
-                                         FROM 
v3_5_configuration_history_clusters
-                                         WHERE 
v3_5_configuration_history_clusters.datacenter_id = cast($P{P_DataCenter_ID} as 
uuid))
-                        AND b.cluster_id = CASE $P{P_Cluster_ID}
-                                             WHEN 
'11111111-1111-1111-1111-111111111111' then b.cluster_id
-                                             ELSE cast($P{P_Cluster_ID} as 
uuid)
-                                           END
-                        AND b.host_type = CASE $P{P_Host_Type}
-                                                WHEN -1 THEN b.host_type
-                                                 WHEN NULL THEN b.host_type
-                                          ELSE $P{P_Host_Type}
-                                          END
-                        AND a.history_datetime >= cast($P{P_Start_Date} as 
timestamp)
-                        AND a.history_datetime <= CASE
-                                                     WHEN $P{P_Period} = 0 
THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 day'
-                                                     WHEN $P{P_Period} = 1 
THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 month'
-                                                     WHEN $P{P_Period} = 2 
THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '3 month'
-                                                     WHEN $P{P_Period} = 3 
THEN CAST($P{P_Start_Date} as TIMESTAMP) + interval '1 year'
-                                                 END
-                        AND b.history_id in (SELECT max(g.history_id)
-                                     FROM v3_5_configuration_history_hosts g
-                                     GROUP BY g.host_id)
-                        $P!{is_deleted}
-                GROUP BY a.host_id
-                ORDER BY 
SUM(coalesce(a.max_memory_usage*a.minutes_in_status,0))/SUM(coalesce(a.minutes_in_status,0))
 +
-                          
SUM(coalesce(a.max_cpu_usage*a.minutes_in_status,0))/SUM(coalesce(a.minutes_in_status,0))
 DESC
-                LIMIT 5)
-    GROUP BY v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id, 
host_name, delete_date, history_datetime) a right outer join calendar b on 
(a.time = b.$P!{calendar_column})
-where $P!{calendar_column} >= cast($P{P_Start_Date} as date)
-      AND $P!{calendar_column} <= CASE
-                         WHEN $P{P_Period} = 0 THEN CAST($P{P_Start_Date} as 
TIMESTAMP) + interval '1 day'
-                         WHEN $P{P_Period} = 1 THEN CAST($P{P_Start_Date} as 
TIMESTAMP) + interval '1 month'
-                         WHEN $P{P_Period} = 2 THEN CAST($P{P_Start_Date} as 
TIMESTAMP) + interval '3 month'
-                         WHEN $P{P_Period} = 3 THEN CAST($P{P_Start_Date} as 
TIMESTAMP) + interval '1 year'
-                     END
-order by $P!{calendar_column}]]>
-    </queryString>
-    <field name="the_date" class="java.sql.Timestamp"/>
-    <field name="host_name" class="java.lang.String"/>
-    <field name="cpu_usage" class="java.math.BigDecimal"/>
-    <field name="mem_usage" class="java.math.BigDecimal"/>
-    <group name="Cluster">
-        <groupExpression><![CDATA[$P{P_Cluster_ID}]]></groupExpression>
-        <groupFooter>
-            <band height="204">
-                <timeSeriesChart>
-                    <chart evaluationTime="Report" 
hyperlinkType="ReportExecution" hyperlinkTarget="Blank" 
customizerClass="com.ovirt.reports.jasper.PercentTimelineChartCustomizer" 
theme="ReportsLineBarChartTheme">
-                        <reportElement mode="Opaque" x="1" y="1" width="410" 
height="200"/>
-                        <box>
-                            <pen lineWidth="1.0" lineColor="#3C617F"/>
-                            <topPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <leftPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <bottomPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <rightPen lineWidth="1.0" lineColor="#3C617F"/>
-                        </box>
-                        <chartTitle>
-                            <font fontName="SansSerif"/>
-                            
<titleExpression><![CDATA[$R{br4b.chart.hosts.cpu.usage}]]></titleExpression>
-                        </chartTitle>
-                        <chartSubtitle/>
-                        <chartLegend/>
-                        <hyperlinkParameter name="_report">
-                            
<hyperlinkParameterExpression><![CDATA["/Reports/Trend/Hosts/Five_most_utilized_hosts_over_time"]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="is_deleted">
-                            
<hyperlinkParameterExpression><![CDATA[$P{is_deleted}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_DataCenter_ID">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_DataCenter_ID}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Cluster_ID">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Cluster_ID}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Host_Type">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Host_Type}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Period">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Period}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Start_Date">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Start_Date}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                    </chart>
-                    <timeSeriesDataset timePeriod="Hour">
-                        <timeSeries>
-                            
<seriesExpression><![CDATA[$F{host_name}]]></seriesExpression>
-                            
<timePeriodExpression><![CDATA[$F{the_date}]]></timePeriodExpression>
-                            
<valueExpression><![CDATA[$F{cpu_usage}]]></valueExpression>
-                            <itemHyperlink>
-                                
<hyperlinkTooltipExpression><![CDATA[$F{host_name} + ", " + 
$F{cpu_usage}.setScale(2, 
RoundingMode.HALF_UP).toString()]]></hyperlinkTooltipExpression>
-                            </itemHyperlink>
-                        </timeSeries>
-                    </timeSeriesDataset>
-                    <timeSeriesPlot isShowShapes="false">
-                        <plot labelRotation="-45.0"/>
-                        
<timeAxisLabelExpression><![CDATA[$R{axis.date}]]></timeAxisLabelExpression>
-                        <timeAxisFormat>
-                            <axisFormat labelColor="#666666">
-                                <labelFont>
-                                    <font isBold="true"/>
-                                </labelFont>
-                            </axisFormat>
-                        </timeAxisFormat>
-                        
<valueAxisLabelExpression><![CDATA[$R{axis.cpu.usage.percent}]]></valueAxisLabelExpression>
-                        <valueAxisFormat>
-                            <axisFormat labelColor="#666666">
-                                <labelFont>
-                                    <font fontName="SansSerif"/>
-                                </labelFont>
-                                <tickLabelFont>
-                                    <font fontName="SansSerif"/>
-                                </tickLabelFont>
-                            </axisFormat>
-                        </valueAxisFormat>
-                    </timeSeriesPlot>
-                </timeSeriesChart>
-                <timeSeriesChart>
-                    <chart evaluationTime="Report" 
hyperlinkType="ReportExecution" hyperlinkTarget="Blank" 
customizerClass="com.ovirt.reports.jasper.PercentTimelineChartCustomizer" 
theme="ReportsLineBarChartTheme">
-                        <reportElement mode="Opaque" x="421" y="1" width="410" 
height="200"/>
-                        <box>
-                            <pen lineWidth="1.0" lineColor="#3C617F"/>
-                            <topPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <leftPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <bottomPen lineWidth="1.0" lineColor="#3C617F"/>
-                            <rightPen lineWidth="1.0" lineColor="#3C617F"/>
-                        </box>
-                        <chartTitle>
-                            <font fontName="SansSerif"/>
-                            
<titleExpression><![CDATA[$R{br4b.chart.hosts.memory.usage}]]></titleExpression>
-                        </chartTitle>
-                        <chartSubtitle/>
-                        <chartLegend/>
-                        <hyperlinkParameter name="_report">
-                            
<hyperlinkParameterExpression><![CDATA["/Reports/Trend/Hosts/Five_most_utilized_hosts_over_time"]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="is_deleted">
-                            
<hyperlinkParameterExpression><![CDATA[$P{is_deleted}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_DataCenter_ID">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_DataCenter_ID}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Cluster_ID">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Cluster_ID}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Host_Type">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Host_Type}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Period">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Period}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                        <hyperlinkParameter name="P_Start_Date">
-                            
<hyperlinkParameterExpression><![CDATA[$P{P_Start_Date}]]></hyperlinkParameterExpression>
-                        </hyperlinkParameter>
-                    </chart>
-                    <timeSeriesDataset timePeriod="Hour">
-                        <timeSeries>
-                            
<seriesExpression><![CDATA[$F{host_name}]]></seriesExpression>
-                            
<timePeriodExpression><![CDATA[$F{the_date}]]></timePeriodExpression>
-                            
<valueExpression><![CDATA[$F{mem_usage}]]></valueExpression>
-                            <itemHyperlink>
-                                
<hyperlinkTooltipExpression><![CDATA[$F{host_name} + ", " + 
$F{mem_usage}.setScale(2, 
RoundingMode.HALF_UP).toString()]]></hyperlinkTooltipExpression>
-                            </itemHyperlink>
-                        </timeSeries>
-                    </timeSeriesDataset>
-                    <timeSeriesPlot isShowShapes="false">
-                        <plot labelRotation="-45.0"/>
-                        
<timeAxisLabelExpression><![CDATA[$R{axis.date}]]></timeAxisLabelExpression>
-                        <timeAxisFormat>
-                            <axisFormat labelColor="#666666">
-                                <labelFont>
-                                    <font isBold="true"/>
-                                </labelFont>
-                            </axisFormat>
-                        </timeAxisFormat>
-                        
<valueAxisLabelExpression><![CDATA[$R{axis.memory.usage.percent}]]></valueAxisLabelExpression>
-                        <valueAxisFormat>
-                            <axisFormat labelColor="#666666">
-                                <labelFont>
-                                    <font fontName="SansSerif"/>
-                                </labelFont>
-                                <tickLabelFont>
-                                    <font fontName="SansSerif"/>
-                                </tickLabelFont>
-                            </axisFormat>
-                        </valueAxisFormat>
-                    </timeSeriesPlot>
-                </timeSeriesChart>
-            </band>
-        </groupFooter>
-    </group>
-    <title>
-        <band height="21">
-            <textField>
-                <reportElement x="0" y="0" width="831" height="20" 
forecolor="#3A5E75"/>
-                <textElement textAlignment="Center" verticalAlignment="Middle" 
markup="none">
-                    <font fontName="SansSerif" size="16" isBold="true"/>
-                </textElement>
-                
<textFieldExpression><![CDATA[$R{br4b.title}]]></textFieldExpression>
-            </textField>
-        </band>
-    </title>
+        INNER JOIN v3_5_configuration_history_hosts
+            ON (
+                v3_5_configuration_history_hosts.host_id =
+                v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id
+            )
+    WHERE
+        v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime 
>=
+        CAST ( $P{P_Start_Date} AS TIMESTAMP )
+        AND 
v3_5_statistics_hosts_resources_usage_$P!{table_name}.history_datetime <
+            CASE
+                WHEN $P{P_Period} = 0
+                    THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 
day'
+                WHEN $P{P_Period} = 1
+                    THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 
month'
+                WHEN $P{P_Period} = 2
+                    THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '3 
month'
+                WHEN $P{P_Period} = 3
+                    THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 
year'
+            END
+        -- Here we get the latest hosts configuration
+        AND v3_5_configuration_history_hosts.history_id IN (
+            SELECT MAX ( a.history_id )
+            FROM v3_5_configuration_history_hosts AS a
+            GROUP BY a.host_id
+        )
+        AND v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id IN (
+            SELECT a.host_id
+            FROM v3_5_statistics_hosts_resources_usage_$P!{table_name} AS a
+                INNER JOIN v3_5_configuration_history_hosts b
+                    ON ( a.host_id = b.host_id )
+            WHERE
+                -- Here we filter by the datacenter chosen by the user
+                b.cluster_id IN (
+                    SELECT v3_5_configuration_history_clusters.cluster_id
+                    FROM v3_5_configuration_history_clusters
+                    WHERE
+                        v3_5_configuration_history_clusters.datacenter_id =
+                        CAST ( $P{P_DataCenter_ID} AS uuid )
+                )
+                -- Here we filter by the cluster chosen by the user
+                AND b.cluster_id =
+                    CASE $P{P_Cluster_ID}
+                        WHEN '11111111-1111-1111-1111-111111111111'
+                            THEN b.cluster_id
+                        ELSE CAST ( $P{P_Cluster_ID} AS uuid )
+                    END
+                -- Here we filter by the hosts type chosen by the user
+                AND b.host_type =
+                    CASE $P{P_Host_Type}
+                        WHEN -1
+                            THEN b.host_type
+                        WHEN NULL
+                            THEN b.host_type
+                        ELSE $P{P_Host_Type}
+                    END
+                AND a.history_datetime >= CAST ( $P{P_Start_Date} AS TIMESTAMP 
)
+                AND a.history_datetime <
+                    CASE
+                        WHEN $P{P_Period} = 0
+                            THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + 
interval '1 day'
+                        WHEN $P{P_Period} = 1
+                            THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + 
interval '1 month'
+                        WHEN $P{P_Period} = 2
+                            THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + 
interval '3 month'
+                        WHEN $P{P_Period} = 3
+                            THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + 
interval '1 year'
+                    END
+                -- Here we get the latest hosts configuration
+                AND b.history_id IN (
+                    SELECT MAX ( g.history_id )
+                    FROM v3_5_configuration_history_hosts g
+                    GROUP BY g.host_id
+                )
+                -- This will determine if deleted hosts will be included in 
the report,
+                -- according to the user selection for "is_deleted" parameter
+                $P!{is_deleted}
+            GROUP BY a.host_id
+            ORDER BY
+                SUM (
+                    COALESCE (
+                        a.max_memory_usage * a.minutes_in_status,
+                        0
+                    )
+                ) /
+                SUM (
+                    COALESCE (
+                        a.minutes_in_status,
+                        0
+                    )
+                ) +
+                SUM (
+                    COALESCE (
+                        a.max_cpu_usage * a.minutes_in_status,
+                        0
+                    )
+                ) /
+                SUM (
+                    COALESCE (
+                        a.minutes_in_status,
+                        0
+                    )
+                ) DESC
+            LIMIT 5
+        )
+    GROUP BY
+        v3_5_statistics_hosts_resources_usage_$P!{table_name}.host_id,
+        host_name,
+        delete_date,
+        history_datetime
+) AS a
+    RIGHT OUTER JOIN calendar b
+        ON (
+            a.time = b.$P!{calendar_column}
+        )
+WHERE $P!{calendar_column} >= CAST ( $P{P_Start_Date} AS date )
+    AND $P!{calendar_column} <
+        CASE
+            WHEN $P{P_Period} = 0
+                THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 day'
+            WHEN $P{P_Period} = 1
+                THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 
month'
+            WHEN $P{P_Period} = 2
+                THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '3 
month'
+            WHEN $P{P_Period} = 3
+                THEN CAST ( $P{P_Start_Date} AS TIMESTAMP ) + interval '1 year'
+        END
+ORDER BY $P!{calendar_column}]]>
+       </queryString>
+       <field name="the_date" class="java.sql.Timestamp"/>
+       <field name="host_name" class="java.lang.String"/>
+       <field name="cpu_usage" class="java.math.BigDecimal"/>
+       <field name="mem_usage" class="java.math.BigDecimal"/>
+       <group name="Cluster">
+               <groupExpression><![CDATA[$P{P_Cluster_ID}]]></groupExpression>
+               <groupFooter>
+                       <band height="204">
+                               <timeSeriesChart>
+                                       <chart evaluationTime="Report" 
hyperlinkType="ReportExecution" hyperlinkTarget="Blank" 
customizerClass="com.ovirt.reports.jasper.PercentTimelineChartCustomizer" 
theme="ReportsLineBarChartTheme">
+                                               <reportElement mode="Opaque" 
x="1" y="1" width="410" height="200" 
uuid="f6237006-3e99-4ce9-b86d-198c3a8ee2d7"/>
+                                               <box>
+                                                       <pen lineWidth="1.0" 
lineColor="#3C617F"/>
+                                                       <topPen lineWidth="1.0" 
lineColor="#3C617F"/>
+                                                       <leftPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                                       <bottomPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                                       <rightPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                               </box>
+                                               <chartTitle>
+                                                       <font 
fontName="SansSerif"/>
+                                                       
<titleExpression><![CDATA[$R{br4b.chart.hosts.cpu.usage}]]></titleExpression>
+                                               </chartTitle>
+                                               <chartSubtitle/>
+                                               <chartLegend/>
+                                               <hyperlinkParameter 
name="_report">
+                                                       
<hyperlinkParameterExpression><![CDATA["/Reports/Trend/Hosts/Five_most_utilized_hosts_over_time"]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="is_deleted">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{is_deleted}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_DataCenter_ID">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_DataCenter_ID}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Cluster_ID">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Cluster_ID}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Host_Type">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Host_Type}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Period">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Period}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Start_Date">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Start_Date}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                       </chart>
+                                       <timeSeriesDataset timePeriod="Hour">
+                                               <timeSeries>
+                                                       
<seriesExpression><![CDATA[$F{host_name}]]></seriesExpression>
+                                                       
<timePeriodExpression><![CDATA[$F{the_date}]]></timePeriodExpression>
+                                                       
<valueExpression><![CDATA[$F{cpu_usage}]]></valueExpression>
+                                                       <itemHyperlink>
+                                                               
<hyperlinkTooltipExpression><![CDATA[$F{host_name} + ", " + 
$F{cpu_usage}.setScale(2, 
RoundingMode.HALF_UP).toString()]]></hyperlinkTooltipExpression>
+                                                       </itemHyperlink>
+                                               </timeSeries>
+                                       </timeSeriesDataset>
+                                       <timeSeriesPlot isShowShapes="false">
+                                               <plot labelRotation="-45.0"/>
+                                               
<timeAxisLabelExpression><![CDATA[$R{axis.date}]]></timeAxisLabelExpression>
+                                               <timeAxisFormat>
+                                                       <axisFormat 
labelColor="#666666">
+                                                               <labelFont>
+                                                                       <font 
isBold="true"/>
+                                                               </labelFont>
+                                                       </axisFormat>
+                                               </timeAxisFormat>
+                                               
<valueAxisLabelExpression><![CDATA[$R{axis.cpu.usage.percent}]]></valueAxisLabelExpression>
+                                               <valueAxisFormat>
+                                                       <axisFormat 
labelColor="#666666">
+                                                               <labelFont>
+                                                                       <font 
fontName="SansSerif"/>
+                                                               </labelFont>
+                                                               <tickLabelFont>
+                                                                       <font 
fontName="SansSerif"/>
+                                                               </tickLabelFont>
+                                                       </axisFormat>
+                                               </valueAxisFormat>
+                                       </timeSeriesPlot>
+                               </timeSeriesChart>
+                               <timeSeriesChart>
+                                       <chart evaluationTime="Report" 
hyperlinkType="ReportExecution" hyperlinkTarget="Blank" 
customizerClass="com.ovirt.reports.jasper.PercentTimelineChartCustomizer" 
theme="ReportsLineBarChartTheme">
+                                               <reportElement mode="Opaque" 
x="421" y="1" width="410" height="200" 
uuid="a03366c9-2983-4a01-ac5e-baffc32cd844"/>
+                                               <box>
+                                                       <pen lineWidth="1.0" 
lineColor="#3C617F"/>
+                                                       <topPen lineWidth="1.0" 
lineColor="#3C617F"/>
+                                                       <leftPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                                       <bottomPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                                       <rightPen 
lineWidth="1.0" lineColor="#3C617F"/>
+                                               </box>
+                                               <chartTitle>
+                                                       <font 
fontName="SansSerif"/>
+                                                       
<titleExpression><![CDATA[$R{br4b.chart.hosts.memory.usage}]]></titleExpression>
+                                               </chartTitle>
+                                               <chartSubtitle/>
+                                               <chartLegend/>
+                                               <hyperlinkParameter 
name="_report">
+                                                       
<hyperlinkParameterExpression><![CDATA["/Reports/Trend/Hosts/Five_most_utilized_hosts_over_time"]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="is_deleted">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{is_deleted}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_DataCenter_ID">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_DataCenter_ID}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Cluster_ID">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Cluster_ID}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Host_Type">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Host_Type}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Period">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Period}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                               <hyperlinkParameter 
name="P_Start_Date">
+                                                       
<hyperlinkParameterExpression><![CDATA[$P{P_Start_Date}]]></hyperlinkParameterExpression>
+                                               </hyperlinkParameter>
+                                       </chart>
+                                       <timeSeriesDataset timePeriod="Hour">
+                                               <timeSeries>
+                                                       
<seriesExpression><![CDATA[$F{host_name}]]></seriesExpression>
+                                                       
<timePeriodExpression><![CDATA[$F{the_date}]]></timePeriodExpression>
+                                                       
<valueExpression><![CDATA[$F{mem_usage}]]></valueExpression>
+                                                       <itemHyperlink>
+                                                               
<hyperlinkTooltipExpression><![CDATA[$F{host_name} + ", " + 
$F{mem_usage}.setScale(2, 
RoundingMode.HALF_UP).toString()]]></hyperlinkTooltipExpression>
+                                                       </itemHyperlink>
+                                               </timeSeries>
+                                       </timeSeriesDataset>
+                                       <timeSeriesPlot isShowShapes="false">
+                                               <plot labelRotation="-45.0"/>
+                                               
<timeAxisLabelExpression><![CDATA[$R{axis.date}]]></timeAxisLabelExpression>
+                                               <timeAxisFormat>
+                                                       <axisFormat 
labelColor="#666666">
+                                                               <labelFont>
+                                                                       <font 
isBold="true"/>
+                                                               </labelFont>
+                                                       </axisFormat>
+                                               </timeAxisFormat>
+                                               
<valueAxisLabelExpression><![CDATA[$R{axis.memory.usage.percent}]]></valueAxisLabelExpression>
+                                               <valueAxisFormat>
+                                                       <axisFormat 
labelColor="#666666">
+                                                               <labelFont>
+                                                                       <font 
fontName="SansSerif"/>
+                                                               </labelFont>
+                                                               <tickLabelFont>
+                                                                       <font 
fontName="SansSerif"/>
+                                                               </tickLabelFont>
+                                                       </axisFormat>
+                                               </valueAxisFormat>
+                                       </timeSeriesPlot>
+                               </timeSeriesChart>
+                       </band>
+               </groupFooter>
+       </group>
+       <title>
+               <band height="21">
+                       <textField>
+                               <reportElement x="0" y="0" width="831" 
height="20" forecolor="#3A5E75" uuid="5f239d28-2031-4a1a-9831-ab58a56cd4a5"/>
+                               <textElement textAlignment="Center" 
verticalAlignment="Middle" markup="none">
+                                       <font fontName="SansSerif" size="16" 
isBold="true"/>
+                               </textElement>
+                               
<textFieldExpression><![CDATA[$R{br4b.title}]]></textFieldExpression>
+                       </textField>
+               </band>
+       </title>
 </jasperReport>


-- 
To view, visit http://gerrit.ovirt.org/27840
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I95c0f2dc843f2c2fefe1c7f193293751b31a5a6b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-reports
Gerrit-Branch: master
Gerrit-Owner: Shirly Radco <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to