fix(server): fix aggregation of retention
This commit is contained in:
parent
7cb13cf839
commit
d37a734379
|
@ -57,8 +57,15 @@ export class AggregateRetentionProcessorService {
|
||||||
usersCount: targetUserIds.length,
|
usersCount: targetUserIds.length,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 今日活動したユーザーを全て取得
|
||||||
|
const activeUsers = await this.usersRepository.findBy({
|
||||||
|
host: IsNull(),
|
||||||
|
lastActiveDate: MoreThan(new Date(Date.now() - (1000 * 60 * 60 * 24))),
|
||||||
|
});
|
||||||
|
const activeUsersIds = activeUsers.map(u => u.id);
|
||||||
|
|
||||||
for (const record of pastRecords) {
|
for (const record of pastRecords) {
|
||||||
const retention = record.userIds.filter(id => targetUserIds.includes(id)).length;
|
const retention = record.userIds.filter(id => activeUsersIds.includes(id)).length;
|
||||||
|
|
||||||
const data = deepClone(record.data);
|
const data = deepClone(record.data);
|
||||||
data[dateKey] = retention;
|
data[dateKey] = retention;
|
||||||
|
|
Loading…
Reference in New Issue