perf: sum ddts to compute total downloads instead of LP query.
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 15 Feb 2014 18:42:16 +0000 (18:42 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 15 Feb 2014 18:42:16 +0000 (18:42 +0000)
NEWS
src/lp.c
src/lp.h
src/ppastats.c

diff --git a/NEWS b/NEWS
index f1c2d2c..73fd9b6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,8 @@ v1.1.0
 ------
 
 * Fixed uninitialized struct fields bug leading to random errors.
-* Improved performance (keep track of the ddts older than 4 weeks).
+* perf: keep track of the ddts older than 4 weeks).
+* perf: sum ddts to compute total downloads instead of LP query.
 
 v1.0.0
 ------
index c307a36..351b8fe 100644 (file)
--- a/src/lp.c
+++ b/src/lp.c
@@ -308,3 +308,15 @@ ddts_merge(struct daily_download_total **ddts1,
 
        return ddts;
 }
+
+int ddts_get_count(struct daily_download_total **ddts)
+{
+       struct daily_download_total **cur;
+       int i;
+
+       i = 0;
+       for (cur = ddts; *cur; cur++)
+               i += (*cur)->count;
+
+       return i;
+}
index c52ce31..394aa17 100644 (file)
--- a/src/lp.h
+++ b/src/lp.h
@@ -99,4 +99,6 @@ struct daily_download_total **
 ddts_merge(struct daily_download_total **,
           struct daily_download_total **);
 
+int ddts_get_count(struct daily_download_total **);
+
 #endif
index 4232e53..ed6efe4 100644 (file)
@@ -270,12 +270,7 @@ create_ppa_stats(const char *owner,
                                h->self_link);
                        continue;
                }
-               count = get_download_count(h->self_link);
-               if (count == -1) {
-                       log_err(_("Failed to retrieve download count for %s"),
-                               h->self_link);
-                       count = 0;
-               }
+               count = ddts_get_count(totals);
                pkg_name = h->binary_package_name;
                pkg_version = h->binary_package_version;
                arch_series