TimelineData 샘플 데이터 생성 기능 추가
- 각 이벤트당 30일 치 daily 데이터 생성 - 참여자, 조회수, 참여행동, 전환수, 누적 참여자 수 포함 - 총 90건의 시간대별 데이터 생성 (3 이벤트 × 30일)
This commit is contained in:
parent
884c964af6
commit
a34037cdd1
@ -104,6 +104,10 @@ public class SampleDataLoader implements ApplicationRunner {
|
|||||||
log.info("⏳ Consumer 처리 대기 중... (3초)");
|
log.info("⏳ Consumer 처리 대기 중... (3초)");
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
|
||||||
|
// 4. TimelineData 생성 (시간대별 데이터)
|
||||||
|
createTimelineData();
|
||||||
|
log.info("✅ TimelineData 생성 완료");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("샘플 데이터 적재 중 오류 발생", e);
|
log.error("샘플 데이터 적재 중 오류 발생", e);
|
||||||
}
|
}
|
||||||
@ -275,6 +279,65 @@ public class SampleDataLoader implements ApplicationRunner {
|
|||||||
log.info("✅ ParticipantRegistered 이벤트 {}건 발행 완료", totalPublished);
|
log.info("✅ ParticipantRegistered 이벤트 {}건 발행 완료", totalPublished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TimelineData 생성 (시간대별 샘플 데이터)
|
||||||
|
*
|
||||||
|
* - 각 이벤트마다 30일 치 daily 데이터 생성
|
||||||
|
* - 참여자 수, 조회수, 참여행동, 전환수, 누적 참여자 수
|
||||||
|
*/
|
||||||
|
private void createTimelineData() {
|
||||||
|
log.info("📊 TimelineData 생성 시작...");
|
||||||
|
|
||||||
|
String[] eventIds = {"evt_2025012301", "evt_2025020101", "evt_2025011501"};
|
||||||
|
|
||||||
|
// 각 이벤트별 기준 참여자 수 (이벤트 성과에 따라 다름)
|
||||||
|
int[] baseParticipants = {20, 12, 5}; // 이벤트1(높음), 이벤트2(중간), 이벤트3(낮음)
|
||||||
|
|
||||||
|
for (int eventIndex = 0; eventIndex < eventIds.length; eventIndex++) {
|
||||||
|
String eventId = eventIds[eventIndex];
|
||||||
|
int baseParticipant = baseParticipants[eventIndex];
|
||||||
|
int cumulativeParticipants = 0;
|
||||||
|
|
||||||
|
// 30일 치 데이터 생성 (2024-09-24부터)
|
||||||
|
java.time.LocalDateTime startDate = java.time.LocalDateTime.of(2024, 9, 24, 0, 0);
|
||||||
|
|
||||||
|
for (int day = 0; day < 30; day++) {
|
||||||
|
java.time.LocalDateTime timestamp = startDate.plusDays(day);
|
||||||
|
|
||||||
|
// 랜덤한 참여자 수 생성 (기준값 ± 50%)
|
||||||
|
int dailyParticipants = baseParticipant + random.nextInt(baseParticipant + 1);
|
||||||
|
cumulativeParticipants += dailyParticipants;
|
||||||
|
|
||||||
|
// 조회수는 참여자의 3~5배
|
||||||
|
int dailyViews = dailyParticipants * (3 + random.nextInt(3));
|
||||||
|
|
||||||
|
// 참여행동은 참여자의 1~2배
|
||||||
|
int dailyEngagement = dailyParticipants * (1 + random.nextInt(2));
|
||||||
|
|
||||||
|
// 전환수는 참여자의 50~80%
|
||||||
|
int dailyConversions = (int) (dailyParticipants * (0.5 + random.nextDouble() * 0.3));
|
||||||
|
|
||||||
|
// TimelineData 생성
|
||||||
|
com.kt.event.analytics.entity.TimelineData timelineData =
|
||||||
|
com.kt.event.analytics.entity.TimelineData.builder()
|
||||||
|
.eventId(eventId)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.participants(dailyParticipants)
|
||||||
|
.views(dailyViews)
|
||||||
|
.engagement(dailyEngagement)
|
||||||
|
.conversions(dailyConversions)
|
||||||
|
.cumulativeParticipants(cumulativeParticipants)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
timelineDataRepository.save(timelineData);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("✅ TimelineData 생성 완료: eventId={}, 30일 데이터", eventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("✅ 전체 TimelineData 생성 완료: 3개 이벤트 × 30일 = 90건");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kafka 이벤트 발행 공통 메서드
|
* Kafka 이벤트 발행 공통 메서드
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user