91 lines
5.9 KiB
SQL
91 lines
5.9 KiB
SQL
-- MySQL 메인 콘텐츠 랭킹 탭 스냅샷 테이블
|
|
-- 날짜/시간 표시 컬럼은 TIMESTAMP를 사용한다.
|
|
-- 같은 랭킹 타입/기간 재생성 시 삭제 기준:
|
|
-- delete from content_ranking_snapshot
|
|
-- where ranking_type = :rankingType
|
|
-- and aggregation_start_at_utc = :aggregationStartAtUtc
|
|
-- and aggregation_end_at_utc = :aggregationEndAtUtc;
|
|
|
|
create table content_ranking_snapshot (
|
|
id bigint not null auto_increment comment '콘텐츠 랭킹 스냅샷 ID',
|
|
ranking_type varchar(30) not null comment '랭킹 타입(WEEKLY_POPULAR, RISING, REVENUE, SALES_COUNT, COMMENT_COUNT, LIKE_COUNT)',
|
|
aggregation_start_at_utc timestamp not null comment '집계 시작 시각(UTC, 포함)',
|
|
aggregation_end_at_utc timestamp not null comment '집계 종료 시각(UTC, 미포함)',
|
|
visible_from_at timestamp not null comment '공개 조회 노출 시작 시각(UTC)',
|
|
content_id bigint not null comment '오디오 콘텐츠 ID',
|
|
title varchar(255) not null comment '스냅샷 생성 시점 콘텐츠 제목',
|
|
creator_member_id bigint not null comment '크리에이터 회원 ID(member.id)',
|
|
creator_nickname varchar(100) not null comment '스냅샷 생성 시점 크리에이터 닉네임',
|
|
cover_image_url varchar(500) null comment '스냅샷 생성 시점 콘텐츠 커버 이미지 URL',
|
|
release_date timestamp not null comment '콘텐츠 공개 시각',
|
|
is_adult tinyint(1) not null default 0 comment '스냅샷 생성 시점 성인 콘텐츠 여부',
|
|
rank_no int not null comment '스냅샷 생성 시점 순위',
|
|
final_score double not null comment '최종 랭킹 점수 또는 정렬 지표',
|
|
normalized_score double null comment '유료/무료 그룹 정규화 점수',
|
|
raw_score double null comment '정규화 전 원점수',
|
|
revenue_can_amount bigint null comment '집계 기간 매출 캔 합계',
|
|
sales_count bigint null comment '집계 기간 판매량',
|
|
view_count bigint null comment '집계 기간 상세 페이지 조회수',
|
|
like_count bigint null comment '집계 기간 좋아요 수',
|
|
comment_count bigint null comment '집계 기간 댓글 수',
|
|
previous_sales_count bigint null comment '직전 비교 기간 판매량',
|
|
previous_view_count bigint null comment '직전 비교 기간 상세 페이지 조회수',
|
|
previous_like_count bigint null comment '직전 비교 기간 좋아요 수',
|
|
previous_comment_count bigint null comment '직전 비교 기간 댓글 수',
|
|
sales_growth_rate double null comment '판매 증가율',
|
|
view_growth_rate double null comment '조회수 증가율',
|
|
like_growth_rate double null comment '좋아요 증가율',
|
|
comment_growth_rate double null comment '댓글 증가율',
|
|
content_growth_score double null comment '지금 뜨는 중 콘텐츠 성장 점수',
|
|
boost_multiplier double null comment '신규 콘텐츠 부스트 배수',
|
|
created_at timestamp not null default current_timestamp comment '생성 시각',
|
|
updated_at timestamp not null default current_timestamp on update current_timestamp comment '수정 시각',
|
|
primary key (id)
|
|
) engine=InnoDB default charset=utf8mb4 comment='메인 콘텐츠 랭킹 탭 주간 스냅샷';
|
|
|
|
create unique index uk_content_ranking_snapshot_period_content
|
|
on content_ranking_snapshot (ranking_type, aggregation_start_at_utc, aggregation_end_at_utc, content_id);
|
|
|
|
create index idx_content_ranking_snapshot_period_rank
|
|
on content_ranking_snapshot (ranking_type, aggregation_end_at_utc, rank_no);
|
|
|
|
create index idx_content_ranking_snapshot_visible_rank
|
|
on content_ranking_snapshot (ranking_type, visible_from_at desc, rank_no);
|
|
|
|
create index idx_content_ranking_snapshot_visible_adult_rank
|
|
on content_ranking_snapshot (ranking_type, visible_from_at desc, is_adult, rank_no);
|
|
|
|
create index idx_content_ranking_snapshot_period_score
|
|
on content_ranking_snapshot (ranking_type, aggregation_end_at_utc, final_score desc, release_date desc, content_id desc);
|
|
|
|
create index idx_content_ranking_snapshot_content
|
|
on content_ranking_snapshot (content_id);
|
|
|
|
create table content_ranking_snapshot_job (
|
|
id bigint not null auto_increment comment '콘텐츠 랭킹 스냅샷 생성 job ID',
|
|
ranking_type varchar(30) not null comment '랭킹 타입(WEEKLY_POPULAR, RISING, REVENUE, SALES_COUNT, COMMENT_COUNT, LIKE_COUNT)',
|
|
aggregation_start_at_utc timestamp not null comment '집계 시작 시각(UTC, 포함)',
|
|
aggregation_end_at_utc timestamp not null comment '집계 종료 시각(UTC, 미포함)',
|
|
visible_from_at timestamp not null comment '공개 조회 노출 시작 시각(UTC)',
|
|
trigger_type varchar(20) not null comment '실행 트리거(SCHEDULED, MANUAL, FALLBACK)',
|
|
status varchar(20) not null comment 'job 상태(PENDING, PROCESSING, DONE, FAILED)',
|
|
last_error text null comment '마지막 실패 사유',
|
|
processing_started_at timestamp null comment '처리 시작 시각',
|
|
processed_at timestamp null comment '처리 완료 시각',
|
|
created_at timestamp not null default current_timestamp comment '생성 시각',
|
|
updated_at timestamp not null default current_timestamp on update current_timestamp comment '수정 시각',
|
|
primary key (id)
|
|
) engine=InnoDB default charset=utf8mb4 comment='메인 콘텐츠 랭킹 탭 스냅샷 생성 job 이력';
|
|
|
|
create index idx_content_ranking_snapshot_job_period_status
|
|
on content_ranking_snapshot_job (ranking_type, aggregation_start_at_utc, aggregation_end_at_utc, status);
|
|
|
|
create index idx_content_ranking_snapshot_job_visible_status
|
|
on content_ranking_snapshot_job (ranking_type, visible_from_at, status);
|
|
|
|
create index idx_content_ranking_snapshot_job_trigger_period
|
|
on content_ranking_snapshot_job (ranking_type, aggregation_start_at_utc, aggregation_end_at_utc, trigger_type, created_at);
|
|
|
|
create index idx_content_ranking_snapshot_job_status_created_at
|
|
on content_ranking_snapshot_job (status, created_at);
|