init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class AuMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private List<String> userGuidList;
|
||||
private int userGuidListCount;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class CuByLangMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private int maxCountUser;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import java.util.List;
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class CuMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private int maxCountUser;
|
||||
private List<String> userGuidList;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class DauMongoLog extends MongoLogSearchBase{
|
||||
|
||||
//private List<String> userAccountIdList;
|
||||
private int accountIdListCount;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class DglcMongoLog extends MongoLogSearchBase{
|
||||
private int totalCount;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class MauMongoLog extends MongoLogSearchBase{
|
||||
private int accountIdListCount;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class McuMongoLog extends MongoLogSearchBase{
|
||||
private int maxCountUser;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
@Getter
|
||||
public abstract class MongoLogSearchBase {
|
||||
@Id
|
||||
private String id;
|
||||
private String logTime;
|
||||
private String logMonth;
|
||||
private String logDay;
|
||||
private String logHour;
|
||||
private String logMinute;
|
||||
private String message;
|
||||
private String languageType;
|
||||
private String userGuid;
|
||||
private String accountId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class NruMongoLog extends MongoLogSearchBase{
|
||||
private int nru;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlayTimeMongoLog extends MongoLogSearchBase{
|
||||
private Long totalPlayTimeCount;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StartEndTime {
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class UgqCreateMongoLog extends MongoLogSearchBase{
|
||||
private int ugqCrateCount;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.caliverse.admin.logs.Indicatordomain;
|
||||
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class WauMongoLog extends MongoLogSearchBase {
|
||||
private int accountIdListCount;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class AuByLangMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private List<String> userGuidList;
|
||||
private int userGuidListCount;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class AuMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private int userGuidListCount;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class CuByLangMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private int maxCountUser;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import java.util.List;
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Document(collection = AdminConstants.MONGO_DB_COLLECTION_LOG)
|
||||
@Getter
|
||||
@Setter
|
||||
public class CuMongoLog extends MongoLogSearchBase{
|
||||
|
||||
private int maxCountUser;
|
||||
private List<String> userGuidList;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
public interface IMongoLogSearch {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.caliverse.admin.logs.businesslogdomain;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
@Getter
|
||||
public abstract class MongoLogSearchBase implements IMongoLogSearch{
|
||||
@Id
|
||||
private String id;
|
||||
private String logTime;
|
||||
private String logDay;
|
||||
private String logHour;
|
||||
private String logMinute;
|
||||
private String message;
|
||||
private String languageType;
|
||||
private String userGuid;
|
||||
private String accountId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.DauLogInfo;
|
||||
|
||||
public interface IndicatorsAuRepository extends MongoRepository<DauLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
|
||||
|
||||
public interface MongoStatRepository{
|
||||
}
|
||||
// public interface MongoStatRepository<T extends LogInfoBase> extends MongoRepository<T, String> {
|
||||
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.AuPerMinLogInfo;
|
||||
|
||||
public interface StatAuPerMinRepository extends MongoRepository<AuPerMinLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.MauLogInfo;
|
||||
|
||||
public interface StatMauRepository extends MongoRepository<MauLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.McuLogInfo;
|
||||
|
||||
public interface StatMcuRepository extends MongoRepository<McuLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.NruLogInfo;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
public interface StatNruRepository extends MongoRepository<NruLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logrepository.indicatorsrepository;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.WauLogInfo;
|
||||
|
||||
public interface StatWauRepository extends MongoRepository<WauLogInfo, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.caliverse.admin.logs.logrepository.mongobusinesslogrepository;
|
||||
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import com.caliverse.admin.logs.businesslogdomain.IMongoLogSearch;
|
||||
|
||||
|
||||
|
||||
|
||||
public interface MongoBusinessLogRepository extends MongoRepository<IMongoLogSearch, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.caliverse.admin.logs.logrepository.mongostatrepository;
|
||||
|
||||
|
||||
|
||||
public interface MongoStatRepository{
|
||||
}
|
||||
// public interface MongoStatRepository<T extends LogInfoBase> extends MongoRepository<T, String> {
|
||||
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.caliverse.admin.logs.logservice;
|
||||
|
||||
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
|
||||
|
||||
public class LogServiceHelper {
|
||||
|
||||
|
||||
public static StartEndTime getCurrentLogSearchEndTime(int minusDay){
|
||||
|
||||
StartEndTime startEndTime = new StartEndTime();
|
||||
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||
|
||||
ZonedDateTime end = now.toLocalDate().atStartOfDay(ZoneId.of("UTC"));
|
||||
String endTimeStr = end.format(DateTimeFormatter.ISO_INSTANT);
|
||||
startEndTime.setEndTime(endTimeStr);
|
||||
|
||||
// 전 날 00시 UTC 시간 설정
|
||||
ZonedDateTime start = end.minusDays(minusDay);
|
||||
String startTimeStr = start.format(DateTimeFormatter.ISO_INSTANT);
|
||||
startEndTime.setStartTime(startTimeStr);
|
||||
//System.out.println("전 날의 00시 UTC: " + startTimeStr);
|
||||
//System.out.println("오늘 날짜의 00시 UTC: " + endTimeStr);
|
||||
|
||||
return startEndTime;
|
||||
}
|
||||
|
||||
public static StartEndTime getCurrentLogSearchEndTime(LocalDate endDate, int minusDay) {
|
||||
StartEndTime startEndTime = new StartEndTime();
|
||||
|
||||
// LocalDate를 UTC ZonedDateTime으로 변환
|
||||
ZonedDateTime end = endDate.atStartOfDay(ZoneId.of("UTC"));
|
||||
startEndTime.setEndTime(end.format(DateTimeFormatter.ISO_INSTANT));
|
||||
|
||||
// startTime 계산
|
||||
ZonedDateTime start = end.minusDays(minusDay);
|
||||
startEndTime.setStartTime(start.format(DateTimeFormatter.ISO_INSTANT));
|
||||
|
||||
return startEndTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class BusinessLogAuByLangService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogAuByLangService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
/*
|
||||
* 집계시 유의 사항
|
||||
* 언어별 카운팅 시 한 유저가 en, ko 동시에 로그가 남을수 있다. (게임에서 언어변경시)
|
||||
* */
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
//CriteriaParamByItemHistory
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
GroupOperation groupByUserGuid = Aggregation.group(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE, AdminConstants.MONGO_DB_KEY_LOGMINUTE)
|
||||
.addToSet(AdminConstants.MONGO_DB_KEY_USER_GUID).as(AdminConstants.MONGO_DB_KEY_USER_GUID_LIST)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE).as(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGTIME).as(AdminConstants.MONGO_DB_KEY_LOGTIME)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGMINUTE).as(AdminConstants.MONGO_DB_KEY_LOGMINUTE)
|
||||
;
|
||||
|
||||
ProjectionOperation projectWithUserGuidListCount = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_USER_GUID_LIST).size().as(AdminConstants.MONGO_DB_KEY_USER_GUID_LIST_COUNT)
|
||||
.and(AdminConstants.MONGO_DB_KEY_USER_GUID_LIST).as(AdminConstants.MONGO_DB_KEY_USER_GUID_LIST)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE).as(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGTIME).as(AdminConstants.MONGO_DB_KEY_LOGTIME)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGMINUTE).as(AdminConstants.MONGO_DB_KEY_LOGMINUTE)
|
||||
;
|
||||
|
||||
operations.add(groupByUserGuid);
|
||||
operations.add(projectWithUserGuidListCount);
|
||||
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_USER_AUTH)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_USER_LOGOUT)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogDauService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogDauService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
GroupOperation groupByUserAccountId = Aggregation.group()
|
||||
.addToSet(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
ProjectionOperation projectWithAccountIdistCount = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).size().as(AdminConstants.MONGO_DB_KEY_ACCOUNT_IDS_COUNT)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
operations.add(groupByUserAccountId);
|
||||
operations.add(projectWithAccountIdistCount);
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData DAU Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogDglcService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogDglcService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
//그룹화
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id", "$logDay")
|
||||
.append("logDay", new Document("$first", "$logDay"))
|
||||
.append("totalCount",
|
||||
new Document("$sum", 1)
|
||||
)
|
||||
));
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData DGLC Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate()
|
||||
.aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogMauService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogMauService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
GroupOperation groupByUserAccountId = Aggregation.group()
|
||||
.addToSet(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
ProjectionOperation projectWithAccountIdistCount = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).size().as(AdminConstants.MONGO_DB_KEY_ACCOUNT_IDS_COUNT)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
operations.add(groupByUserAccountId);
|
||||
operations.add(projectWithAccountIdistCount);
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData MAU Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogMcuService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogMcuService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
GroupOperation groupByLogHour = Aggregation.group(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
.addToSet(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
ProjectionOperation projection1 = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).size().as(AdminConstants.MONGO_DB_KEY_ACCOUNT_IDS_COUNT)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
;
|
||||
|
||||
GroupOperation groupBy = Aggregation.group()
|
||||
.max(AdminConstants.MONGO_DB_KEY_ACCOUNT_IDS_COUNT).as(AdminConstants.MONGO_DB_KEY_MAX_COUNT_USER)
|
||||
.first(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
//.first(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
;
|
||||
|
||||
|
||||
ProjectionOperation projectMcu = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_MAX_COUNT_USER).as(AdminConstants.MONGO_DB_KEY_MAX_COUNT_USER)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
operations.add(groupByLogHour);
|
||||
operations.add(projection1);
|
||||
operations.add(groupBy);
|
||||
operations.add(projectMcu);
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData MCU Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogNruService extends BusinessLogServiceBase {
|
||||
|
||||
|
||||
public BusinessLogNruService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id",
|
||||
new Document("logDay", "$logDay")
|
||||
.append("tranId", "$tranId")
|
||||
)
|
||||
.append("logDay",
|
||||
new Document("$first", "$logDay")
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// logDay별 카운트 집계
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id", "$_id.logDay")
|
||||
.append("nru",
|
||||
new Document("$sum", 1)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// 최종 출력 형식
|
||||
operations.add(context ->
|
||||
new Document("$project",
|
||||
new Document("_id", 0)
|
||||
.append("logDay", "$_id")
|
||||
.append("nru", 1)
|
||||
)
|
||||
);
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData CharacterCreate Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_CHARACTER_CREATE)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogPlayTimeService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogPlayTimeService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
try {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
operations.add(Aggregation.match(Criteria.where(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).ne(null)));
|
||||
|
||||
//3000이라는 값이 들어있는 경우가 있어서 예외처리
|
||||
operations.add(context ->
|
||||
new Document("$match",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME,
|
||||
new Document("$not",
|
||||
new Document("$regex", "^3000")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// 로그인서버는 제외
|
||||
operations.add(context ->
|
||||
new Document("$match",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_SERVER_TYPE,
|
||||
new Document("$ne", "Login")
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// 유저, 시간순으로 정렬
|
||||
operations.add(context ->
|
||||
new Document("$sort",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID, 1)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGTIME, 1)
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$project",
|
||||
new Document("accountId", 1)
|
||||
.append("logTime", 1)
|
||||
.append("loginTime", 1)
|
||||
.append("logoutTime", 1)
|
||||
.append("action", 1)
|
||||
.append("message", 1)
|
||||
.append("logDay", 1)
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID, "$accountId")
|
||||
.append("logDay", "$logDay")
|
||||
)
|
||||
.append("actions",
|
||||
new Document("$push",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_ACTION, "$action")
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGTIME, "$logTime")
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGIN_TIME, "$loginTime")
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME, "$logoutTime")
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
//
|
||||
operations.add(context ->
|
||||
new Document("$project",
|
||||
new Document("_id", 1)
|
||||
.append("sessions",
|
||||
new Document("$map",
|
||||
new Document("input", "$actions")
|
||||
.append("as", "action")
|
||||
.append("in",
|
||||
new Document("$cond", new Document()
|
||||
.append("if", new Document("$eq", Arrays.asList("$$action.action", "UserLogout")))
|
||||
.append("then",
|
||||
new Document("$let", new Document()
|
||||
.append("vars",
|
||||
new Document("prevIndex",
|
||||
new Document("$subtract", Arrays.asList(
|
||||
new Document("$indexOfArray", Arrays.asList("$actions", "$$action")),
|
||||
1
|
||||
))
|
||||
)
|
||||
)
|
||||
.append("in",
|
||||
new Document("$cond", new Document()
|
||||
.append("if",
|
||||
new Document("$and", Arrays.asList(
|
||||
new Document("$gte", Arrays.asList("$$prevIndex", 0)),
|
||||
new Document("$eq", Arrays.asList(
|
||||
new Document("$arrayElemAt", Arrays.asList("$actions.action", "$$prevIndex")),
|
||||
"LoginToGame"
|
||||
))
|
||||
))
|
||||
)
|
||||
.append("then",
|
||||
new Document()
|
||||
.append("type", "paired")
|
||||
.append("login", new Document("$arrayElemAt", Arrays.asList("$actions", "$$prevIndex")))
|
||||
.append("logout", "$$action")
|
||||
)
|
||||
.append("else",
|
||||
new Document()
|
||||
.append("type", "single")
|
||||
.append("logout", "$$action")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append("else", null)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$unwind", "$sessions")
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$match",
|
||||
new Document("$and", Arrays.asList(
|
||||
new Document("sessions", new Document("$ne", null)),
|
||||
new Document("$or", Arrays.asList(
|
||||
new Document("sessions.type", "paired"),
|
||||
new Document("$and", Arrays.asList(
|
||||
new Document("sessions.type", "single"),
|
||||
new Document("sessions.logout.loginTime",
|
||||
new Document("$not",
|
||||
new Document("$regex", "^0001")
|
||||
)
|
||||
)
|
||||
))
|
||||
))
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$project",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID, "$_id")
|
||||
.append("logDay", 1)
|
||||
.append("sessionType", "$sessions.type")
|
||||
.append("loginTime",
|
||||
new Document("$cond",
|
||||
new Document("if", new Document("$eq", Arrays.asList("$sessions.type", "paired")))
|
||||
.append("then", "$sessions.login.loginTime")
|
||||
.append("else", "$sessions.logout.loginTime")
|
||||
)
|
||||
)
|
||||
.append("logoutTime",
|
||||
new Document("$cond",
|
||||
new Document("if", new Document("$eq", Arrays.asList("$sessions.type", "paired")))
|
||||
.append("then", "$sessions.logout.logoutTime")
|
||||
.append("else", "$sessions.logout.logoutTime")
|
||||
)
|
||||
)
|
||||
.append("logTime",
|
||||
new Document("$cond",
|
||||
new Document("if", new Document("$eq", Arrays.asList("$sessions.type", "paired")))
|
||||
.append("then", "$sessions.logout.logTime")
|
||||
.append("else", "$sessions.logout.logTime")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$addFields",
|
||||
new Document("playTimeSeconds",
|
||||
new Document("$divide", Arrays.asList(
|
||||
new Document("$dateDiff",
|
||||
new Document("startDate",
|
||||
new Document("$dateFromString",
|
||||
new Document("dateString",
|
||||
new Document("$substr", Arrays.asList("$loginTime", 0, 19))
|
||||
)
|
||||
.append("format", "%Y-%m-%dT%H:%M:%S")
|
||||
)
|
||||
)
|
||||
.append("endDate",
|
||||
new Document("$dateFromString",
|
||||
new Document("dateString",
|
||||
new Document("$substr", Arrays.asList("$logoutTime", 0, 19))
|
||||
)
|
||||
.append("format", "%Y-%m-%dT%H:%M:%S")
|
||||
)
|
||||
)
|
||||
.append("unit", "millisecond")
|
||||
),
|
||||
1000
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id", "$_id.logDay")
|
||||
.append("logDay",
|
||||
new Document("$first", "$_id.logDay")
|
||||
)
|
||||
.append("totalPlayTimeCount",
|
||||
new Document("$sum", "$playTimeSeconds")
|
||||
)
|
||||
));
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData PlayTime Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate()
|
||||
.aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}catch (Exception e) {
|
||||
log.error("loadBusinessLogData Error Message: {}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
// try {
|
||||
//
|
||||
// Criteria criteria = makeCriteria(startTime, endTime);
|
||||
// List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
//
|
||||
// operations.add(Aggregation.match(Criteria.where(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).ne(null)));
|
||||
//
|
||||
// //3000이라는 값이 들어있는 경우가 있어서 예외처리
|
||||
// operations.add(context ->
|
||||
// new Document("$match",
|
||||
// new Document(AdminConstants.MONGO_DB_KEY_LOGIN_TIME,
|
||||
// new Document("$not",
|
||||
// new Document("$regex", "^3000")
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// //playtime 포맷
|
||||
// operations.add(context ->
|
||||
// new Document("$addFields",
|
||||
// new Document("LoginTimeDate",
|
||||
// new Document("$dateFromString",
|
||||
// new Document("dateString",
|
||||
// new Document("$substr", List.of("$loginTime", 0, 19))
|
||||
// ).append("format", "%Y-%m-%dT%H:%M:%S")
|
||||
// )
|
||||
// )
|
||||
// .append("LogoutTimeDate",
|
||||
// new Document("$dateFromString",
|
||||
// new Document("dateString",
|
||||
// new Document("$substr", List.of("$logoutTime", 0, 19))
|
||||
// ).append("format", "%Y-%m-%dT%H:%M:%S")
|
||||
// )
|
||||
// )
|
||||
// ));
|
||||
//
|
||||
// operations.add(context ->
|
||||
// new Document("$addFields",
|
||||
// new Document("PlayTimeInSeconds",
|
||||
// new Document("$floor", // 소수점 버림
|
||||
// new Document("$divide", List.of(
|
||||
// new Document("$subtract", List.of("$LogoutTimeDate", "$LoginTimeDate")),
|
||||
// 1000
|
||||
// ))
|
||||
// )
|
||||
// )
|
||||
// ));
|
||||
//
|
||||
// //그룹화
|
||||
// operations.add(context ->
|
||||
// new Document("$group",
|
||||
// new Document("_id",
|
||||
// new Document("accountId", "$accountId")
|
||||
// .append("logDay", "$logDay")
|
||||
// )
|
||||
// .append("totalPlayTimeInSeconds",
|
||||
// new Document("$max", "$PlayTimeInSeconds")
|
||||
// )
|
||||
// ));
|
||||
//
|
||||
// operations.add(context ->
|
||||
// new Document("$group",
|
||||
// new Document("_id", "$_id.logDay")
|
||||
// .append("totalPlayTimeAcrossAccountsInSeconds",
|
||||
// new Document("$sum", "$totalPlayTimeInSeconds")
|
||||
// )
|
||||
// ));
|
||||
// operations.add(context ->
|
||||
// new Document("$project",
|
||||
// new Document("_id", 0)
|
||||
// .append(AdminConstants.MONGO_DB_KEY_LOGDAY, "$_id")
|
||||
// .append("totalPlayTimeCount",
|
||||
// new Document("$toString", "$totalPlayTimeAcrossAccountsInSeconds")
|
||||
// )
|
||||
// ));
|
||||
//
|
||||
// Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
// log.info("loadBusinessLogData PlayTime Query: {}", aggregation);
|
||||
// AggregationResults<T> results = getMongoTemplate()
|
||||
// .aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
//
|
||||
// return results.getMappedResults();
|
||||
// }catch (Exception e) {
|
||||
// log.error("loadBusinessLogData Error Message: {}", e.getMessage());
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_PLAY_TIME),
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bson.Document;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
||||
import org.springframework.data.mongodb.core.aggregation.ProjectionOperation;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
|
||||
|
||||
@Getter
|
||||
public abstract class BusinessLogServiceBase implements IBusinessLogService {
|
||||
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
public BusinessLogServiceBase(MongoTemplate mongoTemplate){
|
||||
this.mongoTemplate = mongoTemplate;
|
||||
}
|
||||
|
||||
//protected abstract Criteria makeCriteria(String startTime, String endTime);
|
||||
|
||||
|
||||
protected AggregationOperation getDefaultProjectOperationRegex(){
|
||||
AggregationOperation projectOperation1 = context ->
|
||||
new Document("$project",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"LanguageType\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_MESSAGE, "$message")
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGTIME, "$logTime")
|
||||
.append(AdminConstants.MONGO_DB_KEY_USER_GUID,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"UserGuid\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"AccountId\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGIN_TIME,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"LoginTime\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"LogoutTime\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"TranId\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_ACTION,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"Action\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE,
|
||||
new Document("$regexFind",
|
||||
new Document("input", "$message")
|
||||
.append("regex", "\"ServerType\":\"([^\"]+)\"")
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return projectOperation1;
|
||||
}
|
||||
|
||||
|
||||
protected AggregationOperation getDefaultProjectOperationCapture(){
|
||||
AggregationOperation projectOperation2 = context ->
|
||||
new Document("$project",
|
||||
new Document(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE,
|
||||
new Document("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$languageType.captures", 0))
|
||||
),
|
||||
"Ko"
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_USER_GUID,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$userGuid.captures", 0))
|
||||
),
|
||||
"None"
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$accountId.captures", 0))
|
||||
),
|
||||
"None"
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGIN_TIME,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$loginTime.captures", 0))
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$logoutTime.captures", 0))
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_TRAN_ID,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$tranId.captures", 0))
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_ACTION,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$action.captures", 0))
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_SERVER_TYPE,
|
||||
new Document()
|
||||
.append("$ifNull", List.of(
|
||||
new Document("$toString",
|
||||
new Document("$arrayElemAt", List.of("$serverType.captures", 0))
|
||||
),
|
||||
""
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGTIME, "$logTime")
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGMONTH,
|
||||
new Document("$substr" , List.of("$logTime", 0, 7)) //0000-00
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGDAY,
|
||||
new Document("$substr" , List.of("$logTime", 0, 10)) //0000-00-00
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGHOUR,
|
||||
new Document("$substr" , List.of("$logTime", 0, 13))
|
||||
)
|
||||
.append(AdminConstants.MONGO_DB_KEY_LOGMINUTE,
|
||||
new Document("$substr" , List.of("$logTime", 0, 16))
|
||||
)
|
||||
.append("message", "$message")
|
||||
);
|
||||
|
||||
return projectOperation2;
|
||||
}
|
||||
private AggregationOperation getDefaultProjectOperationName(){
|
||||
ProjectionOperation projectOperation = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGTIME).as(AdminConstants.MONGO_DB_KEY_LOGTIME)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGMONTH).as(AdminConstants.MONGO_DB_KEY_LOGMONTH)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGHOUR).as(AdminConstants.MONGO_DB_KEY_LOGHOUR)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGMINUTE).as(AdminConstants.MONGO_DB_KEY_LOGMINUTE)
|
||||
.and(AdminConstants.MONGO_DB_KEY_MESSAGE).as(AdminConstants.MONGO_DB_KEY_MESSAGE)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE).as(AdminConstants.MONGO_DB_KEY_LANGUAGE_TYPE)
|
||||
.and(AdminConstants.MONGO_DB_KEY_USER_GUID).as(AdminConstants.MONGO_DB_KEY_USER_GUID)
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGIN_TIME).as(AdminConstants.MONGO_DB_KEY_LOGIN_TIME)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME).as(AdminConstants.MONGO_DB_KEY_LOGOUT_TIME)
|
||||
.and(AdminConstants.MONGO_DB_KEY_TRAN_ID).as(AdminConstants.MONGO_DB_KEY_TRAN_ID)
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACTION).as(AdminConstants.MONGO_DB_KEY_ACTION)
|
||||
.and(AdminConstants.MONGO_DB_KEY_SERVER_TYPE).as(AdminConstants.MONGO_DB_KEY_SERVER_TYPE)
|
||||
.and("message").as("message")
|
||||
;
|
||||
return projectOperation;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected List<AggregationOperation> setDefaultOperation(Criteria criteria){
|
||||
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
operations.add(Aggregation.match(criteria));
|
||||
operations.add(getDefaultProjectOperationRegex());
|
||||
operations.add(getDefaultProjectOperationCapture());
|
||||
operations.add(getDefaultProjectOperationName());
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogUgqCreateService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogUgqCreateService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
//그룹화
|
||||
operations.add(context ->
|
||||
new Document("$group",
|
||||
new Document("_id", "$logDay")
|
||||
.append("logDay", new Document("$first", "$logDay"))
|
||||
.append("ugqCrateCount",
|
||||
new Document("$sum", 1)
|
||||
)
|
||||
));
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData UGQ Create Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate()
|
||||
.aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_UGQ_CREATE)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BusinessLogUserItemHistoryService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogUserItemHistoryService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate){
|
||||
super(mongoTemplate);
|
||||
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, String userGuid, Class<T> clazz) {
|
||||
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime, userGuid);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
//여기서 stackCount랑, 로그 타입이랑 같이 가져와야 된다... 나중에 준비되명 하자.....
|
||||
|
||||
|
||||
|
||||
ProjectionOperation pjt = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_USER_GUID).as(AdminConstants.MONGO_DB_KEY_USER_GUID)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGTIME).as(AdminConstants.MONGO_DB_KEY_LOGTIME)
|
||||
;
|
||||
operations.add(pjt);
|
||||
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, clazz);
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime, String userGuid) {
|
||||
String regex = "\"UserGuid\":\"" + userGuid + "\"";
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(regex)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import com.caliverse.admin.global.common.constants.AdminConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessLogWauService extends BusinessLogServiceBase {
|
||||
|
||||
public BusinessLogWauService(@Qualifier("mongoBusinessLogTemplate") MongoTemplate mongoTemplate) {
|
||||
super(mongoTemplate);
|
||||
}
|
||||
|
||||
public <T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> class1) {
|
||||
|
||||
Criteria criteria = makeCriteria(startTime, endTime);
|
||||
List<AggregationOperation> operations = setDefaultOperation(criteria);
|
||||
|
||||
GroupOperation groupByUserAccountId = Aggregation.group()
|
||||
.addToSet(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).as(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID)
|
||||
.max(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
ProjectionOperation projectWithAccountIdistCount = Aggregation.project()
|
||||
.and(AdminConstants.MONGO_DB_KEY_ACCOUNT_ID).size().as(AdminConstants.MONGO_DB_KEY_ACCOUNT_IDS_COUNT)
|
||||
.and(AdminConstants.MONGO_DB_KEY_LOGDAY).as(AdminConstants.MONGO_DB_KEY_LOGDAY)
|
||||
;
|
||||
operations.add(groupByUserAccountId);
|
||||
operations.add(projectWithAccountIdistCount);
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
log.info("loadBusinessLogData WAU Query: {}", aggregation);
|
||||
AggregationResults<T> results = getMongoTemplate().aggregate(aggregation, AdminConstants.MONGO_DB_COLLECTION_LOG, class1);
|
||||
|
||||
return results.getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
protected Criteria makeCriteria(String startTime, String endTime) {
|
||||
return new Criteria()
|
||||
.andOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).gte(startTime)
|
||||
,Criteria.where(AdminConstants.MONGO_DB_KEY_LOGTIME).lt(endTime)
|
||||
, new Criteria()
|
||||
.orOperator(
|
||||
Criteria.where(AdminConstants.MONGO_DB_KEY_MESSAGE).regex(AdminConstants.REGEX_MSG_LOGIN_TO_GAME)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.caliverse.admin.logs.logservice.businesslogservice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBusinessLogService {
|
||||
|
||||
//<T> List<T> loadBusinessLogData(String startTime, String endTime, Class<T> clazz);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogAuByLangService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.AuPerMinLogInfo;
|
||||
import com.caliverse.admin.logs.Indicatordomain.AuMongoLog;
|
||||
|
||||
|
||||
@Service
|
||||
public abstract class IndicatorAuServiceBase {
|
||||
|
||||
//이 클래스 사용할지 말지 나중에 생각해볼것
|
||||
|
||||
|
||||
|
||||
|
||||
//protected abstract void saveStatLogData(String logTimeStr, IndicatorsLog log);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.logs.Indicatordomain.AuMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogAuByLangService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.AuPerMinLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorAuPerMinRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsAuService extends IndicatorAuServiceBase {
|
||||
|
||||
@Autowired private IndicatorAuPerMinRepository indicatorAuPerMinRepository;
|
||||
@Autowired private BusinessLogAuByLangService businessLogAuByLangService;
|
||||
|
||||
public void collectActiveUser(String startTime, String endTime)
|
||||
{
|
||||
List<AuMongoLog> auByLanglogs = businessLogAuByLangService.loadBusinessLogData(startTime, endTime, AuMongoLog.class);
|
||||
|
||||
for(AuMongoLog log : auByLanglogs) {
|
||||
String logMin = log.getLogMinute();
|
||||
|
||||
AuPerMinLogInfo indicatorLog = new AuPerMinLogInfo(logMin, log.getLanguageType(), log.getUserGuidList(), log.getUserGuidListCount());
|
||||
|
||||
saveStatLogData(logMin, indicatorLog);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void saveStatLogData(String logMin, IndicatorsLog indicatorsLog) {
|
||||
|
||||
|
||||
if (indicatorsLog instanceof AuPerMinLogInfo) {
|
||||
AuPerMinLogInfo auLogInfo = (AuPerMinLogInfo) indicatorsLog;
|
||||
try {
|
||||
indicatorAuPerMinRepository.save(auLogInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof AuPerMinLogInfo");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.DBCapacityInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorDBCapacityRepository;
|
||||
import com.caliverse.admin.domain.service.DynamoDBMetricsService;
|
||||
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataResponse;
|
||||
import software.amazon.awssdk.services.cloudwatch.model.MetricDataResult;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsDBCapacityService {
|
||||
|
||||
@Autowired private IndicatorDBCapacityRepository capacityRepository;
|
||||
@Autowired private DynamoDBMetricsService dynamoDBMetricsService;
|
||||
|
||||
public void collectDBCapacity(String startTime, String endTime){
|
||||
GetMetricDataResponse response = dynamoDBMetricsService.getConsumedCapacityData(Instant.parse(startTime), Instant.parse(endTime));
|
||||
|
||||
try {
|
||||
Map<String, Long> dailyReadCapacity = new HashMap<>();
|
||||
Map<String, Long> dailyWriteCapacity = new HashMap<>();
|
||||
|
||||
for (MetricDataResult result : response.metricDataResults()) {
|
||||
for (int i = 0; i < result.timestamps().size(); i++) {
|
||||
String date = result.timestamps().get(i)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDate()
|
||||
.toString();
|
||||
|
||||
double value = result.values().get(i);
|
||||
|
||||
if (result.id().equals("readCapacity")) {
|
||||
dailyReadCapacity.merge(date, Math.round(value), Long::sum);
|
||||
} else if (result.id().equals("writeCapacity")) {
|
||||
dailyWriteCapacity.merge(date, Math.round(value), Long::sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dailyReadCapacity.forEach((date, readTotal) -> {
|
||||
var writeTotal = dailyWriteCapacity.getOrDefault(date, 0L);
|
||||
var capacityInfo = new DBCapacityInfo(date, DynamoDBConstants.NAMESPACE, readTotal, writeTotal);
|
||||
log.info("collectDBCapacity DBCapacity Log Save info: {}", capacityInfo);
|
||||
saveStatLogData(capacityInfo);
|
||||
});
|
||||
}catch (Exception e){
|
||||
log.error("collectUserPlayTime Error Message: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof DBCapacityInfo capacityInfo) {
|
||||
try {
|
||||
capacityRepository.save(capacityInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("saveStatLogData: {}", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof IndicatorsLog");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.DauLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorDauRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.DauMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogDauService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsDauService{
|
||||
|
||||
@Autowired private BusinessLogDauService businessLogDauService;
|
||||
@Autowired private IndicatorDauRepository dauRepository;
|
||||
|
||||
public void collectDailyActiveUser(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<DauMongoLog> indicatorLog = businessLogDauService.loadBusinessLogData(startTime, endTime, DauMongoLog.class);
|
||||
|
||||
if (indicatorLog == null || indicatorLog.isEmpty()) {
|
||||
DauLogInfo dauLog = new DauLogInfo(logTimeStr, 0);
|
||||
log.info("collectDailyActiveUser DAU Log Save logDay: {}, Dau: {}", logTimeStr, dauLog.getDau());
|
||||
saveStatLogData(dauLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(DauMongoLog mongo_log : indicatorLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
DauLogInfo dauLog = new DauLogInfo(logDay, mongo_log.getAccountIdListCount());
|
||||
log.info("collectDailyActiveUser DAU Log Save logDay: {}, Dau: {}", logDay, dauLog.getDau());
|
||||
saveStatLogData(dauLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof DauLogInfo) {
|
||||
DauLogInfo dau_log_info = (DauLogInfo) indicatorsLog;
|
||||
try {
|
||||
dauRepository.save(dau_log_info);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write DAUInfo: {}, Message: {}", dau_log_info, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof DauLogInfo");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 날짜의 DAU 정보를 조회합니다.
|
||||
* @param date 조회할 날짜 (형식: "YYYY-MM-DD")
|
||||
* @return 해당 날짜의 DAU 정보, 없을 경우 null
|
||||
*/
|
||||
// public DauLogInfo getDauLogData(LocalDate date) {
|
||||
// try {
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// String logDay = date.format(formatter);
|
||||
// List<DauLogInfo> dauLogInfo = dauRepository.findByLogDay(logDay);
|
||||
// if (dauLogInfo == null) {
|
||||
// log.info("No DAU data found for date: {}", logDay);
|
||||
// return null;
|
||||
// }
|
||||
// return dauLogInfo.isEmpty() ? null : dauLogInfo.get(0);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Error while fetching DAU for date: {}", date, e);
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.DglcLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorDglcRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.DglcMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogDglcService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsDglcService{
|
||||
|
||||
@Autowired private BusinessLogDglcService businessLogDglcService;
|
||||
@Autowired private IndicatorDglcRepository dglcRepository;
|
||||
|
||||
|
||||
public void collectDailyGameLoginCount(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<DglcMongoLog> indicatorsLog = businessLogDglcService.loadBusinessLogData(startTime, endTime, DglcMongoLog.class);
|
||||
|
||||
if (indicatorsLog == null || indicatorsLog.isEmpty()) {
|
||||
DglcLogInfo dglcLog = new DglcLogInfo(logTimeStr, 0);
|
||||
log.info("collectDailyGameLoginCount DGLC Log Save logDay: {}, TotalCount: {}", logTimeStr, dglcLog.getDglc());
|
||||
saveStatLogData(dglcLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(DglcMongoLog mongo_log : indicatorsLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
DglcLogInfo dglcLog = new DglcLogInfo(logDay, mongo_log.getTotalCount());
|
||||
log.info("collectDailyGameLoginCount DGLC Log Save logDay: {}, TotalCount: {}", logDay, dglcLog.getDglc());
|
||||
saveStatLogData(dglcLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof DglcLogInfo dglcLogInfo) {
|
||||
try {
|
||||
dglcRepository.save(dglcLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write DGLCInfo: {}, Message: {}", dglcLogInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof DglcLogiInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.caliverse.admin.domain.entity.LANGUAGETYPE;
|
||||
import com.caliverse.admin.logs.Indicatordomain.AuMongoLog;
|
||||
|
||||
|
||||
public class IndicatorsLogHelper {
|
||||
|
||||
public static Map<String, AuMongoLog> createLanguageMap()
|
||||
{
|
||||
Map<String, AuMongoLog> map = new HashMap<String, AuMongoLog>();
|
||||
|
||||
for(LANGUAGETYPE lang : LANGUAGETYPE.getAllLanguages()){
|
||||
map.put(lang.toString(), new AuMongoLog());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// public static Class getClassByAuDayNumber(int dayNumber){
|
||||
// switch(dayNumber){
|
||||
// case AdmiinConstants.STAT_DAY_NUM:
|
||||
// return DauLogInfo.class;
|
||||
// case AdmiinConstants.STAT_WEEK_NUM:
|
||||
// return WauLogInfo.class;
|
||||
// case AdmiinConstants.STAT_MONTH_NUM:
|
||||
// return MauLogInfo.class;
|
||||
// default:
|
||||
// return DauLogInfo.class;
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.MauLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorMauRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.MauMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogMauService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsMauService{
|
||||
|
||||
@Autowired private IndicatorMauRepository mauRepository;
|
||||
@Autowired private BusinessLogMauService businessLogMauService;
|
||||
|
||||
public void collectMonthlyActiveUser(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<MauMongoLog> indicatorLog = businessLogMauService.loadBusinessLogData(startTime, endTime, MauMongoLog.class);
|
||||
|
||||
for(MauMongoLog mongo_log : indicatorLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
MauLogInfo mauLog = new MauLogInfo(logDay, mongo_log.getAccountIdListCount());
|
||||
log.info("collectMonthlyActiveUser MAU Log Save logDay: {}, mau: {}", logDay, mauLog.getMau());
|
||||
saveStatLogData(mauLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
if (indicatorsLog instanceof MauLogInfo mau_log_info) {
|
||||
try {
|
||||
mauRepository.save(mau_log_info);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write MAUInfo: {}, Message: {}", mau_log_info, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof DauLogInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorMcuRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.McuMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogMcuService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.caliverse.admin.Indicators.entity.McuLogInfo;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsMcuService {
|
||||
|
||||
@Autowired private IndicatorMcuRepository mcuRepository;
|
||||
@Autowired private BusinessLogMcuService businessLogMcuService;
|
||||
|
||||
public void collectMaxCountUser(String startTime, String endTime)
|
||||
{
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<McuMongoLog> indicatorsLog = businessLogMcuService.loadBusinessLogData(startTime, endTime, McuMongoLog.class);
|
||||
|
||||
if (indicatorsLog == null || indicatorsLog.isEmpty()) {
|
||||
McuLogInfo mcuLog = new McuLogInfo(logTimeStr, 0);
|
||||
log.info("collectMaxCountUser MCU Log Save logDay: {}, MaxCountUser: {}", logTimeStr, mcuLog.getMaxCountUser());
|
||||
saveStatLogData(mcuLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(McuMongoLog mongo_log : indicatorsLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
McuLogInfo mcuLog = new McuLogInfo(logDay, mongo_log.getMaxCountUser());
|
||||
log.info("collectMaxCountUser MCU Log Save logDay: {}, MaxCountUser: {}", logDay, mcuLog.getMaxCountUser());
|
||||
saveStatLogData(mcuLog);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof McuLogInfo) {
|
||||
McuLogInfo mcuLogInfo = (McuLogInfo) indicatorsLog;
|
||||
try {
|
||||
mcuRepository.save(mcuLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write MCUInfo: {}, Message: {}", mcuLogInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof McuLogInfo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public McuLogInfo getMcuLogData(LocalDate date) {
|
||||
// try {
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// String logDay = date.format(formatter);
|
||||
// List<McuLogInfo> mcuLogInfo = mcuRepository.findByLogDay(logDay);
|
||||
// if (mcuLogInfo == null) {
|
||||
// log.info("No MCU data found for date: {}", logDay);
|
||||
// return null;
|
||||
// }
|
||||
// return mcuLogInfo.isEmpty() ? null : mcuLogInfo.get(0);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Error while fetching MCU for date: {}", date, e);
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.MetaverseServerInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorMetaverServerRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsMetaverseServerService {
|
||||
|
||||
@Autowired private IndicatorMetaverServerRepository metaverServerRepository;
|
||||
|
||||
public void collectMetaverseServerCount(String startTime, String endTime, int count){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
|
||||
MetaverseServerInfo metaverseServerLog = new MetaverseServerInfo(logTimeStr, count);
|
||||
log.info("collectMetaverseServerCount MetaverseServer Log Save logDay: {}, ServerCount: {}", logTimeStr, metaverseServerLog.getServerCount());
|
||||
saveStatLogData(metaverseServerLog);
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof MetaverseServerInfo metaverseServerInfo) {
|
||||
try {
|
||||
metaverServerRepository.save(metaverseServerInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write MetaverseServerInfo: {}, Message: {}", metaverseServerInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof MetaverseServerInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.MoneyLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorMoneyRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsMoneyService {
|
||||
|
||||
@Autowired private IndicatorMoneyRepository moneyRepository;
|
||||
// @Autowired private BusinessLogMauService businessLogMauService;
|
||||
//
|
||||
// public void collectMonthlyActiveUser(String startTime, String endTime){
|
||||
// String logTimeStr = startTime.substring(0, 10);
|
||||
// List<MauMongoLog> indicatorLog = businessLogMauService.loadBusinessLogData(startTime, endTime, MauMongoLog.class);
|
||||
//
|
||||
// for(MauMongoLog mongo_log : indicatorLog){
|
||||
// String logDay = mongo_log.getLogDay();
|
||||
//
|
||||
// MauLogInfo mauLog = new MauLogInfo(logDay, mongo_log.getAccountIdListCount());
|
||||
// log.info("collectMonthlyActiveUser MAU Log Save logDay: {}, mau: {}", logDay, mauLog.getMau());
|
||||
// saveStatLogData(mauLog);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
if (indicatorsLog instanceof MoneyLogInfo money_log_info) {
|
||||
try {
|
||||
moneyRepository.save(money_log_info);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write MoneyInfo: {}, Message: {}", money_log_info, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof MoneyLogInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.NruLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorNruRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.NruMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogNruService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsNruService {
|
||||
|
||||
@Autowired private IndicatorNruRepository indicatorNruRepository;
|
||||
@Autowired private BusinessLogNruService businessLogNruService;
|
||||
|
||||
public void collectCharacterCreateCount(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<NruMongoLog> indicatorsLog = businessLogNruService.loadBusinessLogData(startTime, endTime, NruMongoLog.class);
|
||||
|
||||
if (indicatorsLog == null || indicatorsLog.isEmpty()) {
|
||||
NruLogInfo nruLog = new NruLogInfo(logTimeStr, 0);
|
||||
log.info("collectCharacterCreateCount CharacterCreate Log Save logDay: {}, CharacterCreateCount: {}", logTimeStr, nruLog.getNru());
|
||||
saveStatLogData(nruLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(NruMongoLog mongo_log : indicatorsLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
NruLogInfo nruLog = new NruLogInfo(logDay, mongo_log.getNru());
|
||||
log.info("collectCharacterCreateCount CharacterCreate Log Save logDay: {}, CharacterCreateCount: {}", logDay, nruLog.getNru());
|
||||
saveStatLogData(nruLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof NruLogInfo nruLogInfo) {
|
||||
try {
|
||||
indicatorNruRepository.save(nruLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write nruInfo: {}, Message: {}", nruLogInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof NruLogInfo");
|
||||
}
|
||||
}
|
||||
|
||||
// public NruLogInfo getNruLogData(LocalDate date) {
|
||||
// try {
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// String logDay = date.format(formatter);
|
||||
// List<NruLogInfo> nruLogInfo = indicatorNruRepository.findByLogDay(logDay);
|
||||
// if (nruLogInfo == null) {
|
||||
// log.info("No NRU data found for date: {}", logDay);
|
||||
// return null;
|
||||
// }
|
||||
// return nruLogInfo.isEmpty() ? null : nruLogInfo.get(0);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Error while fetching NRU for date: {}", date, e);
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.PlayTimeLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorPlayTimRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.PlayTimeMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogPlayTimeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsPlayTimeService{
|
||||
|
||||
@Autowired private BusinessLogPlayTimeService businessLogPlayTimeService;
|
||||
@Autowired private IndicatorPlayTimRepository playTimeRepository;
|
||||
|
||||
public void collectUserPlayTime(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<PlayTimeMongoLog> indicatorsLog = businessLogPlayTimeService.loadBusinessLogData(startTime, endTime, PlayTimeMongoLog.class);
|
||||
|
||||
try {
|
||||
if (indicatorsLog == null || indicatorsLog.isEmpty()) {
|
||||
PlayTimeLogInfo playTimeLog = new PlayTimeLogInfo(logTimeStr, 0L);
|
||||
log.info("collectUserPlayTime PlayTime Log Save logDay: {}, TotalPlayTimeCount: {}", logTimeStr, playTimeLog.getTotalPlayTimeCount());
|
||||
saveStatLogData(playTimeLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for (PlayTimeMongoLog mongoLog : indicatorsLog) {
|
||||
String logDay = mongoLog.getLogDay();
|
||||
|
||||
PlayTimeLogInfo playTimeLog = new PlayTimeLogInfo(logDay, mongoLog.getTotalPlayTimeCount());
|
||||
log.info("collectUserPlayTime PlayTime Log Save logDay: {}, TotalPlayTimeCount: {}", logDay, playTimeLog.getTotalPlayTimeCount());
|
||||
saveStatLogData(playTimeLog);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("collectUserPlayTime Error Message: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof PlayTimeLogInfo playTimeLogInfo) {
|
||||
try {
|
||||
playTimeRepository.save(playTimeLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("saveStatLogData: {}", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof PlayTimeLogiInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.UgqCreateLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorUgqCreateRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.UgqCreateMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogUgqCreateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsUgqCreateService {
|
||||
|
||||
@Autowired private BusinessLogUgqCreateService businessLogUgqCreateService;
|
||||
@Autowired private IndicatorUgqCreateRepository ugqCreateRepository;
|
||||
|
||||
|
||||
public void collectUGQCreateCount(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<UgqCreateMongoLog> indicatorsLog = businessLogUgqCreateService.loadBusinessLogData(startTime, endTime, UgqCreateMongoLog.class);
|
||||
|
||||
if (indicatorsLog == null || indicatorsLog.isEmpty()) {
|
||||
UgqCreateLogInfo ugqCreateLog = new UgqCreateLogInfo(logTimeStr, 0);
|
||||
log.info("collectUGQCreateCount ugqCreateLog Log Save logDay: {}, UGQCreateCount: {}", logTimeStr, ugqCreateLog.getUgqCrateCount());
|
||||
saveStatLogData(ugqCreateLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(UgqCreateMongoLog mongo_log : indicatorsLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
UgqCreateLogInfo ugqCreateLog = new UgqCreateLogInfo(logDay, mongo_log.getUgqCrateCount());
|
||||
log.info("collectUGQCreateCount ugqCreateLog Log Save logDay: {}, UGQCreateCount: {}", logDay, ugqCreateLog.getUgqCrateCount());
|
||||
saveStatLogData(ugqCreateLog);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof UgqCreateLogInfo ugqCreateLogInfo) {
|
||||
try {
|
||||
ugqCreateRepository.save(ugqCreateLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write UgqCreateLogInfo: {}, Message: {}", ugqCreateLogInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof UgqCreateLogInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.caliverse.admin.logs.logservice.indicators;
|
||||
|
||||
import com.caliverse.admin.Indicators.Indicatordomain.IndicatorsLog;
|
||||
import com.caliverse.admin.Indicators.entity.WauLogInfo;
|
||||
import com.caliverse.admin.Indicators.indicatorrepository.IndicatorWauRepository;
|
||||
import com.caliverse.admin.logs.Indicatordomain.WauMongoLog;
|
||||
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogWauService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IndicatorsWauService{
|
||||
|
||||
@Autowired private IndicatorWauRepository wauRepository;
|
||||
@Autowired private BusinessLogWauService businessLogWauService;
|
||||
|
||||
public void collectWeeklyActiveUser(String startTime, String endTime){
|
||||
String logTimeStr = startTime.substring(0, 10);
|
||||
List<WauMongoLog> indicatorLog = businessLogWauService.loadBusinessLogData(startTime, endTime, WauMongoLog.class);
|
||||
|
||||
try {
|
||||
if (indicatorLog == null || indicatorLog.isEmpty()) {
|
||||
WauLogInfo wauLog = new WauLogInfo(logTimeStr, 0);
|
||||
log.info("collectWeeklyActiveUser WAU Log Save logDay: {}, Wau: {}", logTimeStr, wauLog.getWau());
|
||||
saveStatLogData(wauLog);
|
||||
return;
|
||||
}
|
||||
|
||||
for(WauMongoLog mongo_log : indicatorLog){
|
||||
String logDay = mongo_log.getLogDay();
|
||||
|
||||
WauLogInfo wauLog = new WauLogInfo(logDay, mongo_log.getAccountIdListCount());
|
||||
log.info("collectWeeklyActiveUser WAU Log Save logDay: {}, Wau: {}", logDay, wauLog.getWau());
|
||||
saveStatLogData(wauLog);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("collectWeeklyActiveUser Error Message: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStatLogData(IndicatorsLog indicatorsLog) {
|
||||
|
||||
if (indicatorsLog instanceof WauLogInfo) {
|
||||
WauLogInfo wauLogInfo = (WauLogInfo) indicatorsLog;
|
||||
try {
|
||||
wauRepository.save(wauLogInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("Error Repository Write WAUInfo: {}, Message: {}", wauLogInfo, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("Not instanceof WauLogInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user