Class StatsService


  • public class StatsService
    extends Api
    Statistics api. The Statistics module needs to be activated (xwiki.stats=1 in xwiki.cfg).
    Version:
    $Id: a4ab447cf37d0e66a0b35eaa0f2c3626ebda4afc $
    • Constructor Detail

      • StatsService

        public StatsService​(XWikiContext context)
        Create new StatsService instance.
        Parameters:
        context - the XWiki context.
    • Method Detail

      • isEnabledGlobally

        public boolean isEnabledGlobally()
        Indicate if statistics service is globally enabled. Note that it is possible for statistics to be enabled at the global level, yet disabled in most or even all wikis. When statistics are globally enabled, session statistics are available. To check if document statistics are enabled for the current wiki, use isEnabledForCurrentWiki().

        To be true the xwiki.stats setting in xwiki.cfg has to be 1.

        Returns:
        true if the statistics module is enabled
      • isEnabledForCurrentWiki

        public boolean isEnabledForCurrentWiki()
        Indicate if statistics service is enabled for the current wiki.

        To be true the xwiki.stats in xwiki.cfg has to be 1 and xwiki.stats.default too.

        xwiki.stats.default can be overwritten by statistics in XWikiPreferences.

        Returns:
        true if statistics are enabled for the context's wiki.
      • isEnabled

        @Deprecated
        public boolean isEnabled()
        Deprecated.
        Indicate if statistics service is enabled for the current wiki.

        To be true the xwiki.stats in xwiki.cfg has to be 1 and xwiki.stats.default too.

        xwiki.stats.default can be overwritten by statistics in XWikiPreferences.

        Returns:
        true if statistics are enabled for the context's wiki.
      • getDocumentStatistics

        public List<?> getDocumentStatistics​(String action,
                                             Scope scope,
                                             Period period,
                                             Range range)
        Retrieves document statistics.
        Parameters:
        action - The action the results should be ordered by. It can be one of: "view", "save" or "download". If the action is "view" then the documents are ordered by the number of times they have been viewed so far.
        scope - The set of documents for which to retrieve statistics
        period - The period of time
        range - The sub-range to return from the entire result set. Use this parameter for pagination
        Returns:
        A list of DocumentStats objects
      • getVisitStatistics

        public List<?> getVisitStatistics​(String action,
                                          Period period,
                                          Range range)
        Retrieves visit statistics.
        Parameters:
        action - The action the results should be ordered by. It can be one of: "view", "save" or "download". If the action is "view" then the visitors are ordered by the number of pages they have viewed so far.
        period - The period of time
        range - The sub-range to return from the entire result set. Use this parameter for pagination
        Returns:
        A list of VisitStats objects
      • getRefererStatistics

        public List<?> getRefererStatistics​(String domain,
                                            Scope scope,
                                            Period period,
                                            Range range)
        Retrieves referrer statistics.
        Parameters:
        domain - The domain for which to retrieve statistics. To retrieve statistics for all domains use the empty string.
        scope - The scope of referred documents to use for filtering the results.
        period - The period of time
        range - The sub-range to return from the entire result set. Use this parameter for pagination
        Returns:
        A list of RefererStats objects
      • getBackLinkStatistics

        public List<?> getBackLinkStatistics​(String domain,
                                             Scope scope,
                                             Period period,
                                             Range range)
        Retrieves back-link statistics.
        Parameters:
        domain - the domain used for filtering the results
        scope - the scope of referred documents for which to retrieve statistics.
        period - the period of time
        range - the sub-range to return from the entire result set. Use this parameter for pagination
        Returns:
        a list of DocumentStats objects
      • getActionStatistics

        public Map<?,​?> getActionStatistics​(String action,
                                                  Scope scope,
                                                  Period period,
                                                  Duration step)
        Shows how the statistics for the specified action have evolved over the specified period of time.
        Parameters:
        action - the action for which to retrieve statistics.
        scope - the set of documents to consider.
        period - the period of time.
        step - the step used for sampling the period.
        Returns:
        a map of (date, actionCount) pairs.
      • getRecentActions

        public Collection<?> getRecentActions​(String action,
                                              int size)
        Returns the recently visited pages for a specific action.
        Parameters:
        action - ("view" or "edit").
        size - how many recent actions to retrieve.
        Returns:
        a ArrayList of document names.