mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
[Debt] ActivityIndex thresholds in RetentionData
This commit is contained in:
parent
23f96f96aa
commit
ef16f8ece1
|
@ -214,7 +214,9 @@ public class AnalysisContainer extends DataContainer {
|
|||
// compareAndFindThoseLikelyToBeRetained can throw exception.
|
||||
putSupplier(retentionDay, () -> getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).compareAndFindThoseLikelyToBeRetained(
|
||||
getUnsafe(newDay).all(), getUnsafe(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO),
|
||||
getUnsafe(AnalysisKeys.PLAYERS_ONLINE_RESOLVER)
|
||||
getUnsafe(AnalysisKeys.PLAYERS_ONLINE_RESOLVER),
|
||||
config.getNumber(Settings.ACTIVE_PLAY_THRESHOLD),
|
||||
config.getNumber(Settings.ACTIVE_LOGIN_THRESHOLD)
|
||||
).count()
|
||||
);
|
||||
putSupplier(AnalysisKeys.PLAYERS_RETAINED_DAY, () -> {
|
||||
|
|
|
@ -175,9 +175,13 @@ public class PlayersMutator {
|
|||
* @return Mutator containing the players that are considered to be retained.
|
||||
* @throws IllegalStateException If all players are rejected due to dateLimit.
|
||||
*/
|
||||
public PlayersMutator compareAndFindThoseLikelyToBeRetained(Iterable<PlayerContainer> compareTo,
|
||||
long dateLimit,
|
||||
PlayersOnlineResolver onlineResolver) {
|
||||
public PlayersMutator compareAndFindThoseLikelyToBeRetained(
|
||||
Iterable<PlayerContainer> compareTo,
|
||||
long dateLimit,
|
||||
PlayersOnlineResolver onlineResolver,
|
||||
int activityMinuteThreshold,
|
||||
int activityLoginThreshold
|
||||
) {
|
||||
Collection<PlayerContainer> retainedAfterMonth = new ArrayList<>();
|
||||
Collection<PlayerContainer> notRetainedAfterMonth = new ArrayList<>();
|
||||
|
||||
|
@ -203,10 +207,10 @@ public class PlayersMutator {
|
|||
}
|
||||
|
||||
List<RetentionData> retained = retainedAfterMonth.stream()
|
||||
.map(player -> new RetentionData(player, onlineResolver))
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold))
|
||||
.collect(Collectors.toList());
|
||||
List<RetentionData> notRetained = notRetainedAfterMonth.stream()
|
||||
.map(player -> new RetentionData(player, onlineResolver))
|
||||
.map(player -> new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
RetentionData avgRetained = RetentionData.average(retained);
|
||||
|
@ -214,7 +218,7 @@ public class PlayersMutator {
|
|||
|
||||
List<PlayerContainer> toBeRetained = new ArrayList<>();
|
||||
for (PlayerContainer player : compareTo) {
|
||||
RetentionData retentionData = new RetentionData(player, onlineResolver);
|
||||
RetentionData retentionData = new RetentionData(player, onlineResolver, activityMinuteThreshold, activityLoginThreshold);
|
||||
if (retentionData.distance(avgRetained) < retentionData.distance(avgNotRetained)) {
|
||||
toBeRetained.add(player);
|
||||
}
|
||||
|
|
|
@ -45,11 +45,20 @@ public class RetentionData {
|
|||
this.onlineOnJoin = onlineOnJoin;
|
||||
}
|
||||
|
||||
public RetentionData(PlayerContainer player, PlayersOnlineResolver onlineOnJoin) {
|
||||
public RetentionData(
|
||||
PlayerContainer player,
|
||||
PlayersOnlineResolver onlineOnJoin,
|
||||
int activityMinuteThreshold,
|
||||
int activityLoginThreshold
|
||||
) {
|
||||
Optional<Long> registeredValue = player.getValue(PlayerKeys.REGISTERED);
|
||||
activityIndex = registeredValue
|
||||
// TODO Thresholds from settings
|
||||
.map(registered -> new ActivityIndex(player, registered + TimeUnit.DAYS.toMillis(1L), 1, 1).getValue())
|
||||
.map(registered -> new ActivityIndex(
|
||||
player,
|
||||
registered + TimeUnit.DAYS.toMillis(1L),
|
||||
activityMinuteThreshold,
|
||||
activityLoginThreshold
|
||||
).getValue())
|
||||
.orElse(0.0);
|
||||
this.onlineOnJoin = registeredValue
|
||||
.map(registered -> onlineOnJoin.getOnlineOn(registered).orElse(-1))
|
||||
|
|
Loading…
Reference in New Issue
Block a user