Class ActivityIndexQueries

java.lang.Object
com.djrapitops.plan.storage.database.queries.analysis.ActivityIndexQueries

public class ActivityIndexQueries extends Object
Queries for Activity Index that attempts to gain insight into player activity levels.

Old formula for activity index was not linear and difficult to turn into a query due to conditional multipliers. Thus a new formula was written.

T - Time played after someone is considered active on a particular week t1, t2, t3 - Time played that week

Activity index takes into account last 3 weeks.

Activity for a single week is calculated using A(t) = (1 / (pi/2 * (t/T) + 1)). A(t) is based on function f(x) = 1 / (x + 1), which has property f(0) = 1, decreasing from there, but not in a straight line. You can see the function plotted here

To fine tune the curve pi/2 is used since it felt like a good curve.

Activity index A is calculated by using the formula: A = 5 - 5 * [A(t1) + A(t2) + A(t3)] / 3

Plot for A and limits

New Limits for A would thus be < 1: Inactive > 1: Irregular > 2: Regular > 3: Active > 3.75: Very Active

  • Method Details Link icon

    • fetchRegularPlayerCount Link icon

      public static Query<Integer> fetchRegularPlayerCount(long date, ServerUUID serverUUID, long playtimeThreshold)
    • selectActivityIndexSQL Link icon

      public static String selectActivityIndexSQL()
    • setSelectActivityIndexSQLParameters Link icon

      public static void setSelectActivityIndexSQLParameters(PreparedStatement statement, int index, long playtimeThreshold, ServerUUID serverUUID, long date) throws SQLException
      Throws:
      SQLException
    • fetchActivityGroupCount Link icon

      public static Query<Integer> fetchActivityGroupCount(long date, ServerUUID serverUUID, long playtimeThreshold, double above, double below)
    • fetchActivityIndexGroupingsOn Link icon

      public static Query<Map<String,Integer>> fetchActivityIndexGroupingsOn(long date, ServerUUID serverUUID, long threshold)
    • countNewPlayersTurnedRegular Link icon

      public static Query<Integer> countNewPlayersTurnedRegular(long after, long before, ServerUUID serverUUID, Long threshold)
    • countRegularPlayersTurnedInactive Link icon

      public static Query<Integer> countRegularPlayersTurnedInactive(long start, long end, ServerUUID serverUUID, Long threshold)
      Parameters:
      start - Start of the tracking, those regular will be counted here.
      end - End of the tracking, those inactive will be count here.
      serverUUID - UUID of the server.
      threshold - Playtime threshold
      Returns:
      Query how many players went from regular to inactive in a span of time.
    • averagePlaytimePerRegularPlayer Link icon

      public static Query<Long> averagePlaytimePerRegularPlayer(long after, long before, ServerUUID serverUUID, Long threshold)
    • averageSessionLengthPerRegularPlayer Link icon

      public static Query<Long> averageSessionLengthPerRegularPlayer(long after, long before, ServerUUID serverUUID, Long threshold)
    • averageAFKPerRegularPlayer Link icon

      public static Query<Long> averageAFKPerRegularPlayer(long after, long before, ServerUUID serverUUID, Long threshold)
    • activityIndexForNewPlayers Link icon

      public static Query<Collection<ActivityIndex>> activityIndexForNewPlayers(long after, long before, ServerUUID serverUUID, Long threshold)
    • averageActivityIndexForRetainedPlayers Link icon

      public static Query<ActivityIndex> averageActivityIndexForRetainedPlayers(long after, long before, ServerUUID serverUUID, Long threshold)
    • averageActivityIndexForNonRetainedPlayers Link icon

      public static Query<ActivityIndex> averageActivityIndexForNonRetainedPlayers(long after, long before, ServerUUID serverUUID, Long threshold)