File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
app/lib/service/download_counts Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ double computeRelativeGrowthRate(List<int> totalDownloads) {
38
38
recentDownloads.reduce ((prev, element) => prev + element) /
39
39
recentDownloads.length;
40
40
41
- if (averageRecentDownloads == 0 ) {
41
+ final averageTotalDownloads =
42
+ totalDownloads.reduce ((prev, element) => prev + element) /
43
+ totalDownloads.length;
44
+
45
+ if (averageRecentDownloads == 0 || averageTotalDownloads == 0 ) {
42
46
return 0 ;
43
47
}
44
48
@@ -51,7 +55,7 @@ double computeRelativeGrowthRate(List<int> totalDownloads) {
51
55
// Normalize slope by average downloads to represent relative growth.
52
56
// This measures how much the download count is growing relative to its
53
57
// current volume.
54
- return growthRate / averageRecentDownloads ;
58
+ return growthRate / averageTotalDownloads ;
55
59
}
56
60
57
61
/// Computes the slope of the best-fit line for a given list of data points
You can’t perform that action at this time.
0 commit comments