← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17167: Analytics, bettter logging in table generation

 

------------------------------------------------------------
revno: 17167
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-10-19 11:09:02 +0200
message:
  Analytics, bettter logging in table generation
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2014-10-19 09:09:02 +0000
@@ -51,6 +51,8 @@
 import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.timer.SystemTimer;
+import org.hisp.dhis.system.timer.Timer;
 import org.hisp.dhis.system.util.ListUtils;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -356,4 +358,18 @@
             throw new IllegalStateException( "Analytics table dimensions contain duplicates: " + duplicates );
         }
     }
+
+    /**
+     * Executes the given table population SQL statement, log and times the operation.
+     */
+    protected void populateAndLog( String sql, String tableName )
+    {
+        log.info( "Populate SQL for " + tableName + ": " + sql );
+
+        Timer t = new SystemTimer().start();
+        
+        jdbcTemplate.execute( sql );
+        
+        log.info( "Populated " + tableName + ": " + t.stop().toString() );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2014-10-19 09:09:02 +0000
@@ -181,6 +181,7 @@
     {
         final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
         final String end = DateUtils.getMediumDateString( table.getPeriod().getEndDate() );
+        final String tableName = table.getTempTableName();
         
         String sql = "insert into " + table.getTempTableName() + " (";
         
@@ -223,9 +224,7 @@
             sql += "and " + whereClause;
         }
 
-        log.info( "Populate SQL: "+ sql );
-        
-        jdbcTemplate.execute( sql );
+        populateAndLog( sql, tableName + ", " + valueType );
     }
 
     private String getApprovalSubquery( Collection<OrganisationUnitLevel> levels )

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2014-10-19 09:09:02 +0000
@@ -111,6 +111,7 @@
             
             final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
             final String end = DateUtils.getMediumDateString( table.getPeriod().getEndDate() );
+            final String tableName = table.getTempTableName();
         
             String insert = "insert into " + table.getTempTableName() + " (";
             
@@ -144,9 +145,7 @@
     
             final String sql = insert + select;
             
-            log.info( "Populate SQL: "+ sql );
-            
-            jdbcTemplate.execute( sql );
+            populateAndLog( sql, tableName );
         }
         
         return null;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java	2014-10-19 09:09:02 +0000
@@ -109,6 +109,8 @@
             {
                 break taskLoop;
             }
+
+            final String tableName = table.getTempTableName();
             
             String sql = "insert into " + table.getTempTableName() + " (";
     
@@ -131,9 +133,7 @@
                 "left join _orgunitstructure ous on dss.sourceid=ous.organisationunitid " +
                 "left join _organisationunitgroupsetstructure ougs on dss.sourceid=ougs.organisationunitid";            
     
-            log.info( "Populate SQL: "+ sql );
-            
-            jdbcTemplate.execute( sql );
+            populateAndLog( sql, tableName );
         }
         
         return null;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2014-10-19 09:09:02 +0000
@@ -158,6 +158,7 @@
 
             final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
             final String end = DateUtils.getMediumDateString( table.getPeriod().getEndDate() );
+            final String tableName = table.getTempTableName();
 
             String sql = "insert into " + table.getTempTableName() + " (";
 
@@ -190,9 +191,7 @@
                 "and psi.organisationunitid is not null " +
                 "and psi.executiondate is not null";
 
-            log.info( "Populate SQL: " + sql );
-
-            jdbcTemplate.execute( sql );
+            populateAndLog( sql, tableName );
         }
 
         return null;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java	2014-10-16 14:51:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java	2014-10-19 09:09:02 +0000
@@ -108,6 +108,8 @@
             {
                 break taskLoop;
             }
+
+            final String tableName = table.getTempTableName();
             
             String sql = "insert into " + table.getTempTableName() + " (";
     
@@ -130,9 +132,7 @@
                 "left join _orgunitstructure ous on ougm.organisationunitid=ous.organisationunitid " +
                 "left join _organisationunitgroupsetstructure ougs on ougm.organisationunitid=ougs.organisationunitid";            
 
-            log.info( "Populate SQL: "+ sql );
-            
-            jdbcTemplate.execute( sql );
+            populateAndLog( sql, tableName );
         }
         
         return null;