Class ActivityIndex
- java.lang.Object
-
- com.djrapitops.plan.delivery.domain.mutators.ActivityIndex
-
public class ActivityIndex extends java.lang.Object
Represents Activity index of a player at a certain date.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 weekt1, t2, t3
- Time played that weekActivity 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 https://www.wolframalpha.com/input/?i=1+%2F+(x%2B1)+from+-1+to+2To 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 https://www.wolframalpha.com/input/?i=plot+y+%3D+5+-+5+*+(1+%2F+(pi%2F2+*+x%2B1))+and+y+%3D1+and+y+%3D+2+and+y+%3D+3+and+y+%3D+3.75+from+-0.5+to+3
New Limits for A would thus be
< 1: Inactive
> 1: Irregular
> 2: Regular
> 3: Active
> 3.75: Very Active
-
-
Field Summary
Fields Modifier and Type Field Description static double
ACTIVE
static double
IRREGULAR
static double
REGULAR
static double
VERY_ACTIVE
-
Constructor Summary
Constructors Constructor Description ActivityIndex(double value, long date)
ActivityIndex(DataContainer container, long date, long playtimeMsThreshold)
ActivityIndex(java.util.List<FinishedSession> sessions, long date, long playtimeMsThreshold)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(ActivityIndex other)
long
getDate()
static java.lang.String[]
getDefaultGroups()
java.lang.String
getFormattedValue(Formatter<java.lang.Double> formatter)
java.lang.String
getGroup()
static java.lang.String
getGroup(double value)
java.lang.String
getGroup(Locale locale)
static java.lang.String[]
getGroups(Locale locale)
double
getValue()
-
-
-
Field Detail
-
VERY_ACTIVE
public static final double VERY_ACTIVE
- See Also:
- Constant Field Values
-
ACTIVE
public static final double ACTIVE
- See Also:
- Constant Field Values
-
REGULAR
public static final double REGULAR
- See Also:
- Constant Field Values
-
IRREGULAR
public static final double IRREGULAR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActivityIndex
public ActivityIndex(DataContainer container, long date, long playtimeMsThreshold)
-
ActivityIndex
public ActivityIndex(java.util.List<FinishedSession> sessions, long date, long playtimeMsThreshold)
-
ActivityIndex
public ActivityIndex(double value, long date)
-
-
Method Detail
-
getDefaultGroups
public static java.lang.String[] getDefaultGroups()
-
getGroups
public static java.lang.String[] getGroups(Locale locale)
-
getValue
public double getValue()
-
getDate
public long getDate()
-
getFormattedValue
public java.lang.String getFormattedValue(Formatter<java.lang.Double> formatter)
-
distance
public double distance(ActivityIndex other)
-
getGroup
public static java.lang.String getGroup(double value)
-
getGroup
public java.lang.String getGroup()
-
getGroup
public java.lang.String getGroup(Locale locale)
-
-