Skip to content

Commit a03400c

Browse files
committed
Normalize trend by overall average
1 parent 8d0c76e commit a03400c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/lib/service/download_counts/package_trends.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ double computeRelativeGrowthRate(List<int> totalDownloads) {
3838
recentDownloads.reduce((prev, element) => prev + element) /
3939
recentDownloads.length;
4040

41-
if (averageRecentDownloads == 0) {
41+
final averageTotalDownloads =
42+
totalDownloads.reduce((prev, element) => prev + element) /
43+
totalDownloads.length;
44+
45+
if (averageRecentDownloads == 0 || averageTotalDownloads == 0) {
4246
return 0;
4347
}
4448

@@ -51,7 +55,7 @@ double computeRelativeGrowthRate(List<int> totalDownloads) {
5155
// Normalize slope by average downloads to represent relative growth.
5256
// This measures how much the download count is growing relative to its
5357
// current volume.
54-
return growthRate / averageRecentDownloads;
58+
return growthRate / averageTotalDownloads;
5559
}
5660

5761
/// Computes the slope of the best-fit line for a given list of data points

0 commit comments

Comments
 (0)