merged plib
[ppastats.git] / src / ppastats.c
index c1c18d8..a03ecf0 100644 (file)
@@ -147,6 +147,20 @@ static struct package_stats *get_package_stats(struct ppa_stats *stats,
        return p;
 }
 
+static struct version_stats *version_stats_new(const char *version)
+{
+       struct version_stats *v;
+
+       v = malloc(sizeof(struct version_stats));
+       v->version = strdup(version);
+       v->distros = NULL;
+       v->download_count = 0;
+       v->daily_download_totals = NULL;
+       v->date_created = 0;
+
+       return v;
+}
+
 static struct version_stats *get_version_stats(struct package_stats *package,
                                               const char *version)
 {
@@ -162,11 +176,7 @@ static struct version_stats *get_version_stats(struct package_stats *package,
                cur++;
        }
 
-       v = malloc(sizeof(struct version_stats));
-       v->version = strdup(version);
-       v->distros = NULL;
-       v->download_count = 0;
-       v->daily_download_totals = NULL;
+       v = version_stats_new(version);
 
        tmp = (struct version_stats **)list_add((void **)package->versions,
                                                v);
@@ -386,6 +396,8 @@ create_ppa_stats(const char *owner,
                pkg->daily_download_totals = tmp;
 
                version = get_version_stats(pkg, pkg_version);
+               version->date_created = h->date_created;
+
                version->download_count += count;
                tmp = add_totals(version->daily_download_totals, totals);
                if (version->daily_download_totals != tmp)