From: Jean-Philippe Orsini Date: Sat, 15 Feb 2014 18:42:16 +0000 (+0000) Subject: perf: sum ddts to compute total downloads instead of LP query. X-Git-Tag: v1.3.0~48 X-Git-Url: http://git.wpitchoune.net/gitweb/?p=ppastats.git;a=commitdiff_plain;h=79ab1c25edcfe1de08d6a2bbc6066bb29c0b55d1 perf: sum ddts to compute total downloads instead of LP query. --- diff --git a/NEWS b/NEWS index f1c2d2c..73fd9b6 100644 --- 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 ------ diff --git a/src/lp.c b/src/lp.c index c307a36..351b8fe 100644 --- 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; +} diff --git a/src/lp.h b/src/lp.h index c52ce31..394aa17 100644 --- 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 diff --git a/src/ppastats.c b/src/ppastats.c index 4232e53..ed6efe4 100644 --- a/src/ppastats.c +++ b/src/ppastats.c @@ -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