사용하지 않는 코드 정리 및 전송 데이터 포멧팅 변경
This commit is contained in:
1 parent
a0c352f567
commit
cb267192d2
5 files changed
+137
-208
No files matched your search
@@ -204,64 +204,64 @@ class DataProcessor:
|
||||
ContentMetric(
|
||||
id="total-views",
|
||||
label="조회수",
|
||||
label_en="Total Views",
|
||||
value=self._format_number(int(views)),
|
||||
value=float(views),
|
||||
unit="count",
|
||||
trend=round(float(views_trend), 1),
|
||||
trend_direction=views_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="total-watch-time",
|
||||
label="시청시간",
|
||||
label_en="Watch Time",
|
||||
value=f"{round(estimated_minutes_watched / 60, 1)}시간",
|
||||
value=round(estimated_minutes_watched / 60, 1),
|
||||
unit="hours",
|
||||
trend=round(watch_trend / 60, 1),
|
||||
trend_direction=watch_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="avg-view-duration",
|
||||
label="평균 시청시간",
|
||||
label_en="Avg. View Duration",
|
||||
value=f"{round(average_view_duration / 60)}분",
|
||||
value=round(average_view_duration / 60, 1),
|
||||
unit="minutes",
|
||||
trend=round(duration_trend / 60, 1),
|
||||
trend_direction=duration_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="new-subscribers",
|
||||
label="신규 구독자",
|
||||
label_en="New Subscribers",
|
||||
value=self._format_number(int(subscribers_gained)),
|
||||
trend=round(float(subs_trend), 1),
|
||||
value=float(subscribers_gained),
|
||||
unit="count",
|
||||
trend=subs_trend,
|
||||
trend_direction=subs_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="likes",
|
||||
label="좋아요",
|
||||
label_en="Likes",
|
||||
value=self._format_number(int(likes)),
|
||||
trend=round(float(likes_trend), 1),
|
||||
value=float(likes),
|
||||
unit="count",
|
||||
trend=likes_trend,
|
||||
trend_direction=likes_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="comments",
|
||||
label="댓글",
|
||||
label_en="Comments",
|
||||
value=self._format_number(int(comments)),
|
||||
trend=round(float(comments_trend), 1),
|
||||
value=float(comments),
|
||||
unit="count",
|
||||
trend=comments_trend,
|
||||
trend_direction=comments_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="shares",
|
||||
label="공유",
|
||||
label_en="Shares",
|
||||
value=self._format_number(int(shares)),
|
||||
trend=round(float(shares_trend), 1),
|
||||
value=float(shares),
|
||||
unit="count",
|
||||
trend=shares_trend,
|
||||
trend_direction=shares_dir,
|
||||
),
|
||||
ContentMetric(
|
||||
id="uploaded-videos",
|
||||
label="업로드 영상",
|
||||
label_en="Uploaded Videos",
|
||||
value=str(period_video_count),
|
||||
value=float(period_video_count),
|
||||
unit="count",
|
||||
trend=0.0,
|
||||
trend_direction="-",
|
||||
),
|
||||
@@ -475,53 +475,6 @@ class DataProcessor:
|
||||
top_regions=top_regions,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _format_number(num: int) -> str:
|
||||
"""숫자 포맷팅 (1234567 → "1.2M")
|
||||
|
||||
조회수, 구독자 수 등 큰 숫자를 읽기 쉽게 포맷팅합니다.
|
||||
|
||||
Args:
|
||||
num: 원본 숫자
|
||||
|
||||
Returns:
|
||||
str: 포맷팅된 문자열
|
||||
- 1,000,000 이상: "1.2M"
|
||||
- 1,000 이상: "12.5K"
|
||||
- 1,000 미만: "123"
|
||||
|
||||
Example:
|
||||
>>> _format_number(1234567)
|
||||
"1.2M"
|
||||
>>> _format_number(12345)
|
||||
"12.3K"
|
||||
>>> _format_number(123)
|
||||
"123"
|
||||
"""
|
||||
if num >= 1_000_000:
|
||||
return f"{num / 1_000_000:.1f}M"
|
||||
elif num >= 1_000:
|
||||
return f"{num / 1_000:.1f}K"
|
||||
else:
|
||||
return str(num)
|
||||
|
||||
@staticmethod
|
||||
def _format_duration(seconds: int) -> str:
|
||||
"""초를 M:SS 형식으로 변환 (평균 시청 시간 표시용)
|
||||
|
||||
Args:
|
||||
seconds: 초 단위 시간
|
||||
|
||||
Returns:
|
||||
str: M:SS 형식 문자열
|
||||
- 204초 → "3:24"
|
||||
- 65초 → "1:05"
|
||||
- 45초 → "0:45"
|
||||
"""
|
||||
minutes = seconds // 60
|
||||
secs = seconds % 60
|
||||
return f"{minutes}:{secs:02d}"
|
||||
|
||||
@staticmethod
|
||||
def _translate_country_code(code: str) -> str:
|
||||
"""국가 코드를 한국어로 변환
|
||||
|
||||
Reference in new issue
Block a user