ccus-cli 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/aggregate.js +20 -8
- package/package.json +1 -1
package/dist/lib/aggregate.js
CHANGED
|
@@ -122,14 +122,26 @@ async function loadWeeklyExportBundles(inputDir) {
|
|
|
122
122
|
function bundlePersonKey(bundle) {
|
|
123
123
|
return toPersonKey(bundle.identity.gitUserEmail, bundle.identity.gitUserName);
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
/**
|
|
126
|
+
* 某天 daySummary 的数据质量等级(越高越优先):
|
|
127
|
+
* 2 = 有 transcript 数据(userMessageCount / apiRequestCount > 0)
|
|
128
|
+
* 1 = 仅有 statusline 采样(sampleCount > 0,但 transcript 字段全为 0)
|
|
129
|
+
* 0 = 全空占位天
|
|
130
|
+
*
|
|
131
|
+
* transcript 级别优先于纯 sampleCount 级别,避免只有采样事件但无消息数的 bundle
|
|
132
|
+
* 抢走有真实 transcript 数据的 bundle 的 winner 位置。
|
|
133
|
+
*/
|
|
134
|
+
function dayDataTier(day) {
|
|
135
|
+
if (day.userMessageCount > 0 || day.apiRequestCount > 0)
|
|
136
|
+
return 2;
|
|
137
|
+
if (day.sampleCount > 0)
|
|
138
|
+
return 1;
|
|
139
|
+
return 0;
|
|
128
140
|
}
|
|
129
|
-
/** winner
|
|
130
|
-
function isBetterCandidate(
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
141
|
+
/** winner 比较:数据质量等级高优先,同级别内 generatedAt 较新优先,最后用 filePath 做稳定 tie-break。 */
|
|
142
|
+
function isBetterCandidate(nextTier, nextGeneratedAt, nextFilePath, currentTier, currentGeneratedAt, currentFilePath) {
|
|
143
|
+
if (nextTier !== currentTier) {
|
|
144
|
+
return nextTier > currentTier;
|
|
133
145
|
}
|
|
134
146
|
if (nextGeneratedAt !== currentGeneratedAt) {
|
|
135
147
|
return nextGeneratedAt > currentGeneratedAt;
|
|
@@ -145,7 +157,7 @@ function selectDailyWinners(bundles) {
|
|
|
145
157
|
for (const day of bundle.dailySummaries) {
|
|
146
158
|
const key = `${personKey}|${day.date}`;
|
|
147
159
|
const current = winners.get(key);
|
|
148
|
-
if (!current || isBetterCandidate(
|
|
160
|
+
if (!current || isBetterCandidate(dayDataTier(day), generatedAt, filePath, dayDataTier(current.day), current.generatedAt, current.filePath)) {
|
|
149
161
|
winners.set(key, { personKey, date: day.date, day, bundle, generatedAt, filePath });
|
|
150
162
|
}
|
|
151
163
|
}
|