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