← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19013: Added event statistics to data admin statistics panel

 

Merge authors:
  Halvdan Hoem Grelland (halvdanhg)
------------------------------------------------------------
revno: 19013 [merge]
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-04-24 13:25:27 +0200
message:
  Added event statistics to data admin statistics panel
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/statistics.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseStatistics.vm


--
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-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2015-04-23 17:00:11 +0000
@@ -116,6 +116,14 @@
     List<ProgramStageInstance> getProgramStageInstances( TrackedEntityInstance entityInstance, EventStatus status );
 
     /**
+     * Gets the number of ProgramStageInstances added since the given number of days.
+     *
+     * @param days number of days.
+     * @return the number of ProgramStageInstances.
+     */
+    long getProgramStageInstanceCount( int days );
+
+    /**
      * Retrieve scheduled list of entityInstances registered
      *
      * @return A SchedulingProgramObject list

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2015-04-24 11:16:03 +0000
@@ -132,4 +132,11 @@
      * @return Grid
      */
     Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate, I18n i18n );
+
+    /**
+     * Get the number of ProgramStageInstances updates since the given Date.
+     * @param time the time.
+     * @return the number of ProgramStageInstances.
+     */
+    long getProgramStageInstanceCountLastUpdatedAfter( Date time );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2015-04-23 17:00:11 +0000
@@ -165,6 +165,15 @@
     }
 
     @Override
+    public long getProgramStageInstanceCount( int days )
+    {
+        Calendar cal = PeriodType.createCalendarInstance();
+        cal.add( Calendar.DAY_OF_YEAR, ( days * -1 ) );
+
+        return programStageInstanceStore.getProgramStageInstanceCountLastUpdatedAfter( cal.getTime() );
+    }
+
+    @Override
     public Collection<SchedulingProgramObject> getSendMesssageEvents()
     {
         return programStageInstanceStore.getSendMesssageEvents();

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2015-04-23 17:00:11 +0000
@@ -252,7 +252,18 @@
 
         return grid;
     }
-    
+
+    @Override
+    public long getProgramStageInstanceCountLastUpdatedAfter( Date time )
+    {
+        Number rs = (Number) getCriteria()
+            .add( Restrictions.ge( "lastUpdated", time ) )
+            .setProjection( Projections.rowCount() )
+            .uniqueResult();
+
+        return rs != null ? rs.longValue() : 0;
+    }
+
     @Override
     public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before,
         int status )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java	2015-03-23 13:31:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/statistics/GetStatisticsAction.java	2015-04-23 17:00:11 +0000
@@ -34,6 +34,7 @@
 
 import org.hisp.dhis.common.Objects;
 import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.statistics.StatisticsProvider;
 import org.hisp.dhis.system.util.EnumMapWrapper;
 import org.hisp.dhis.user.UserInvitationStatus;
@@ -74,6 +75,13 @@
         this.dataValueService = dataValueService;
     }
 
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -105,6 +113,13 @@
     {
         return dataValueCount;
     }
+
+    private Map<Integer, Long> eventCount = new HashMap<>();
+
+    public Map<Integer, Long> getEventCount()
+    {
+        return eventCount;
+    }
     
     // -------------------------------------------------------------------------
     // Action implementation
@@ -142,7 +157,12 @@
         dataValueCount.put( 1, dataValueService.getDataValueCount( 1 ) );
         dataValueCount.put( 7, dataValueService.getDataValueCount( 7 ) );
         dataValueCount.put( 30, dataValueService.getDataValueCount( 30 ) );
-        
+
+        eventCount.put( 0, programStageInstanceService.getProgramStageInstanceCount( 0 ) );
+        eventCount.put( 1, programStageInstanceService.getProgramStageInstanceCount( 1 ) );
+        eventCount.put( 7, programStageInstanceService.getProgramStageInstanceCount( 7 ) );
+        eventCount.put( 30, programStageInstanceService.getProgramStageInstanceCount( 30 ) );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2015-03-20 07:08:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2015-04-23 17:00:11 +0000
@@ -38,6 +38,7 @@
     <property name="statisticsProvider" ref="org.hisp.dhis.statistics.StatisticsProvider" />
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
     <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+    <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
   </bean>
 
   <!-- Databrowser Grid -->

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2015-03-23 13:31:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2015-04-24 09:45:25 +0000
@@ -257,6 +257,7 @@
 users_logged_in=Users logged in
 today=Today
 yesterday=Yesterday
+last_2_days=Last 2 days
 last_7_days=Last 7 days
 last_30_days=Last 30 days
 dynamic_attributes=Dynamic Attributes

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/statistics.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/statistics.js	2012-04-26 18:32:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/statistics.js	2015-04-24 11:16:03 +0000
@@ -1,10 +1,9 @@
-
 $( document ).ready( function()
 {
-	showLoader();
-	
-	$( '#contentDiv' ).load( 'getStatistics.action?' + getDC(), function()
-	{
-		hideLoader();
-	} );
+    showLoader();
+
+    $( '#contentDiv' ).load( 'getStatistics.action?' + getDC(), function()
+    {
+        hideLoader();
+    } );
 } );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseStatistics.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseStatistics.vm	2015-04-20 09:40:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/responseStatistics.vm	2015-04-24 11:25:27 +0000
@@ -1,13 +1,13 @@
 
 <table>
-	<tr>
-		<th style="width:200px">$i18n.getString( "object_type" )</th>
-		<th style="width:200px">$i18n.getString( "number" )</th>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "data_elements" )</td>
-		<td>$objects.getValue( "DATAELEMENT" )</td>
-	</tr>
+    <tr>
+        <th style="width:200px">$i18n.getString( "object_type" )</th>
+        <th style="width:200px">$i18n.getString( "number" )</th>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "data_elements" )</td>
+        <td>$objects.getValue( "DATAELEMENT" )</td>
+    </tr>
     <tr>
         <td>$i18n.getString( "data_element_groups" )</td>
         <td>$objects.getValue( "DATAELEMENTGROUP" )</td>
@@ -86,40 +86,40 @@
 </table>
 
 <table>
-	<tr>
-		<th style="width:200px">$i18n.getString( "users_logged_in" )</th>
-		<th style="width:200px">$i18n.getString( "number" )</th>
-	</tr>
+    <tr>
+        <th style="width:200px">$i18n.getString( "users_logged_in" )</th>
+        <th style="width:200px">$i18n.getString( "number" )</th>
+    </tr>
     <tr>
         <td>$i18n.getString( "last_hour" )</td>
         <td>$activeUsers.get( 0 )</td>
     </tr>
-	<tr>
-		<td>$i18n.getString( "today" )</td>
-		<td>$activeUsers.get( 1 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "yesterday" )</td>
-		<td>$activeUsers.get( 2 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "last_7_days" )</td>
-		<td>$activeUsers.get( 7 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "last_30_days" )</td>
-		<td>$activeUsers.get( 30 )</td>
-	</tr>
-    <tr>
-    	<td colspan="2" style="height:15px"></td>
+    <tr>
+        <td>$i18n.getString( "today" )</td>
+        <td>$activeUsers.get( 1 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_2_days" )</td>
+        <td>$activeUsers.get( 2 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_7_days" )</td>
+        <td>$activeUsers.get( 7 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_30_days" )</td>
+        <td>$activeUsers.get( 30 )</td>
+    </tr>
+    <tr>
+        <td colspan="2" style="height:15px"></td>
     </tr>
 </table>
 
 <table>
-	<tr>
-		<th style="width:200px">$i18n.getString( "user_account_invitations" )</th>
-		<th style="width:200px">$i18n.getString( "number" )</th>
-	</tr>
+    <tr>
+        <th style="width:200px">$i18n.getString( "user_account_invitations" )</th>
+        <th style="width:200px">$i18n.getString( "number" )</th>
+    </tr>
     <tr>
         <td>$i18n.getString( "pending_invitations" )</td>
         <td>$userInvitations.getValue( "ALL" )</td>
@@ -129,32 +129,58 @@
         <td>$userInvitations.getValue( "EXPIRED" )</td>
     </tr>
     <tr>
-    	<td colspan="2" style="height:15px"></td>
-    </tr>
-</table>
-
-<table>
-	<tr>
-		<th style="width:200px">$i18n.getString( "data_values" )</th>
-		<th style="width:200px">$i18n.getString( "number" )</th>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "today" )</td>
-		<td>$dataValueCount.get( 0 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "yesterday" )</td>
-		<td>$dataValueCount.get( 1 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "last_7_days" )</td>
-		<td>$dataValueCount.get( 7 )</td>
-	</tr>
-	<tr>
-		<td>$i18n.getString( "last_30_days" )</td>
-		<td>$dataValueCount.get( 30 )</td>
-	</tr>
-    <tr>
-    	<td colspan="2" style="height:15px"></td>
+        <td colspan="2" style="height:15px"></td>
+    </tr>
+</table>
+
+<table>
+    <tr>
+        <th style="width:200px">$i18n.getString( "data_values" )</th>
+        <th style="width:200px">$i18n.getString( "number" )</th>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "today" )</td>
+        <td>$dataValueCount.get( 0 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_2_days" )</td>
+        <td>$dataValueCount.get( 1 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_7_days" )</td>
+        <td>$dataValueCount.get( 7 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_30_days" )</td>
+        <td>$dataValueCount.get( 30 )</td>
+    </tr>
+    <tr>
+        <td colspan="2" style="height:15px"></td>
+    </tr>
+</table>
+
+<table>
+    <tr>
+        <th style="width:200px">$i18n.getString( "events" )</th>
+        <th style="width:200px">$i18n.getString( "number" )</th>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "today" )</td>
+        <td>$eventCount.get( 0 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_2_days" )</td>
+        <td>$eventCount.get( 1 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_7_days" )</td>
+        <td>$eventCount.get( 7 )</td>
+    </tr>
+    <tr>
+        <td>$i18n.getString( "last_30_days" )</td>
+        <td>$eventCount.get( 30 )</td>
+    </tr>
+    <tr>
+        <td colspan="2" style="height:15px"></td>
     </tr>
 </table>