Skip to content

Commit f0706f6

Browse files
authored
refactor: remove cwvInterpolationFN, simpleCWVInterploationFN, INTERPOLATION_THRESHOLD from utils (#8)
1 parent a390472 commit f0706f6

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

utils.js

-32
Original file line numberDiff line numberDiff line change
@@ -172,38 +172,6 @@ export function scoreBundle(bundle) {
172172
return 'poor';
173173
}
174174

175-
export const INTERPOLATION_THRESHOLD = 10;
176-
177-
export function simpleCWVInterpolationFn(metric, threshold) {
178-
return (cwvs) => {
179-
const valuedWeights = Object.values(cwvs)
180-
.filter((value) => value.weight !== undefined)
181-
.map((value) => value.weight)
182-
.reduce((acc, value) => acc + value, 0);
183-
return cwvs[threshold + metric].weight / valuedWeights;
184-
};
185-
}
186-
export function cwvInterpolationFn(targetMetric) {
187-
return (cwvs) => {
188-
const valueCount = cwvs.goodCWV.count + cwvs.niCWV.count + cwvs.poorCWV.count;
189-
const valuedWeights = cwvs.goodCWV.weight + cwvs.niCWV.weight + cwvs.poorCWV.weight;
190-
191-
if (valueCount < INTERPOLATION_THRESHOLD) {
192-
// not enough data to interpolate
193-
return 0;
194-
}
195-
// total weight
196-
const totalWeight = cwvs.goodCWV.weight
197-
+ cwvs.niCWV.weight
198-
+ cwvs.poorCWV.weight
199-
+ cwvs.noCWV.weight;
200-
// share of targetMetric compared to all CWV
201-
const share = cwvs[targetMetric].weight / (valuedWeights);
202-
// interpolate the share to the total weight
203-
return Math.round(share * totalWeight);
204-
};
205-
}
206-
207175
/**
208176
* Conversion rates are computed as the ratio of conversions to visits. The conversion rate is
209177
* capped at 100%.

0 commit comments

Comments
 (0)