Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-1117

Rest-API: counting active users would be more significant

    XMLWordPrintable

    Details

      Description

      When calling /restapi/system/monitoring/openolat/users the totalUserCount includes all users on the system, wven all deleted users. This count is not very relevant for statistics. It should be better to count all the active users, too.

      This patch extends the result by the active users count:

      diff -r 7b363235e42b src/main/java/org/olat/basesecurity/Constants.java
      --- a/src/main/java/org/olat/basesecurity/Constants.java	Wed Jun 18 12:36:58 2014 +0200
      +++ b/src/main/java/org/olat/basesecurity/Constants.java	Wed Jun 25 13:48:52 2014 +0200
      @@ -211,4 +211,27 @@
       	 */
       	public static final OLATResourceable ORESOURCE_GUESTONLY = OresHelper.lookupType(BaseSecurityModule.class, "RGuestOnly");
       
      +	/**
      +	 * status of a user
      +	 * <code>USERSTATUS_ACTIVE</code> is an active user
      +	 */
      +	public static final Integer USERSTATUS_ACTIVE = 2;
      +
      +	/**
      +	 * status of a user
      +	 * <code>USERSTATUS_NOT_DELETEABLE</code> is a not deleteable user
      +	 */
      +	public static final Integer USERSTATUS_NOT_DELETEABLE = 1;
      +
      +	/**
      +	 * status of a user
      +	 * <code>USERSTATUS_LOGIN_DENIED</code> is a user, whose login is denied
      +	 */
      +	public static final Integer USERSTATUS_LOGIN_DENIED = 101;
      +
      +	/**
      +	 * status of a user
      +	 * <code>USERSTATUS_DELETED</code> is a deleted user
      +	 */
      +	public static final Integer USERSTATUS_DELETED = 199;
       }
      \ No newline at end of file
      diff -r 7b363235e42b src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java
      --- a/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java	Wed Jun 18 12:36:58 2014 +0200
      +++ b/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java	Wed Jun 25 13:48:52 2014 +0200
      @@ -33,6 +33,7 @@
       import org.olat.admin.sysinfo.manager.SessionStatsManager;
       import org.olat.admin.sysinfo.model.SessionsStats;
       import org.olat.basesecurity.BaseSecurity;
      +import org.olat.basesecurity.Constants;
       import org.olat.core.CoreSpringFactory;
       import org.olat.core.util.SessionInfo;
       import org.olat.core.util.UserSession;
      @@ -170,6 +171,8 @@
       		BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
       		long countUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, null);
       		stats.setTotalUserCount(countUsers);
      +		long countActiveUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE);
      +		stats.setActiveUserCount(countActiveUsers);
       		
       		BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
       		long countGroups = bgs.countBusinessGroups(null, null);
      diff -r 7b363235e42b src/main/java/org/olat/restapi/system/vo/UserStatisticsVO.java
      --- a/src/main/java/org/olat/restapi/system/vo/UserStatisticsVO.java	Wed Jun 18 12:36:58 2014 +0200
      +++ b/src/main/java/org/olat/restapi/system/vo/UserStatisticsVO.java	Wed Jun 25 13:48:52 2014 +0200
      @@ -34,6 +34,8 @@
       
       	@XmlAttribute(name="totalUserCount", required=true)
       	private long totalUserCount;
      +	@XmlAttribute(name="activeUserCount", required=true)
      +	private long activeUserCount;
       	@XmlAttribute(name="totalGroupCount", required=true)
       	private long totalGroupCount;
       	
      @@ -46,6 +48,14 @@
       		this.totalUserCount = totalUserCount;
       	}
       	
      +	public long getActiveUserCount() {
      +		return activeUserCount;
      +	}
      +	
      +	public void setActiveUserCount(long activeUserCount) {
      +		this.activeUserCount = activeUserCount;
      +	}
      +	
       	public long getTotalGroupCount() {
       		return totalGroupCount;
       	}
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 15 minutes
                15m