Added distribution chart in the package page.
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 6 Sep 2011 09:34:37 +0000 (09:34 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 6 Sep 2011 09:34:37 +0000 (09:34 +0000)
NEWS
configure
src/html.c
src/ppastats.1
src/ppastats.c
src/ppastats.h
www/css/ppastats.css
www/js/ppastats.js

diff --git a/NEWS b/NEWS
index 93e45ae..a944fb1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 * v0.0.5
 ** Added information about distribution in the package page.
+** Added distribution chart in the package page.
 
 * v0.0.4
 ** Fixed memory issue (patch submitted by Lekensteyn).
index 57191e3..887a83f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67 for ppastats 0.0.4.
+# Generated by GNU Autoconf 2.67 for ppastats 0.0.5.
 #
 # Report bugs to <jeanfi@gmail.com>.
 #
@@ -552,8 +552,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ppastats'
 PACKAGE_TARNAME='ppastats'
-PACKAGE_VERSION='0.0.4'
-PACKAGE_STRING='ppastats 0.0.4'
+PACKAGE_VERSION='0.0.5'
+PACKAGE_STRING='ppastats 0.0.5'
 PACKAGE_BUGREPORT='jeanfi@gmail.com'
 PACKAGE_URL='http://wpitchoune.net/ppastats'
 
@@ -1253,7 +1253,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ppastats 0.0.4 to adapt to many kinds of systems.
+\`configure' configures ppastats 0.0.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1323,7 +1323,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ppastats 0.0.4:";;
+     short | recursive ) echo "Configuration of ppastats 0.0.5:";;
    esac
   cat <<\_ACEOF
 
@@ -1426,7 +1426,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ppastats configure 0.0.4
+ppastats configure 0.0.5
 generated by GNU Autoconf 2.67
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1728,7 +1728,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ppastats $as_me 0.0.4, which was
+It was created by ppastats $as_me 0.0.5, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   $ $0 $@
@@ -2544,7 +2544,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ppastats'
- VERSION='0.0.4'
+ VERSION='0.0.5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4701,7 +4701,6 @@ fi
 
 
 
-
 ac_config_files="$ac_config_files Makefile src/Makefile tests/Makefile www/Makefile"
 
 
@@ -5270,7 +5269,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ppastats $as_me 0.0.4, which was
+This file was extended by ppastats $as_me 0.0.5, which was
 generated by GNU Autoconf 2.67.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5337,7 +5336,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ppastats config.status 0.0.4
+ppastats config.status 0.0.5
 configured by $0, generated by GNU Autoconf 2.67,
   with options \\"\$ac_cs_config\\"
 
index 3d6c630..e1c9e9f 100644 (file)
@@ -71,7 +71,10 @@ enum file_copy_error {
        <a href=\"index.html\">\n\
           <span id=\"ppa_owner\">N/A</span>/<span id=\"ppa_name\">N/A</span>\n\
        </a></p>\n\
-    <div id=\"chart\"></div>\n\
+    <div id=\"charts\">\n\
+       <div id=\"chart\"></div>\n\
+       <div id=\"chart_distro\"></div>\n\
+    </div>\n\
     <div id=\"details\">\n\
       <div id=\"versions\"><em>Versions:</em></div>\n\
       <div id=\"distros\"><em>Distros:</em></div>\n\
@@ -304,6 +307,9 @@ static char *pkg_to_json(struct ppa_stats *ppa, struct package_stats *pkg)
                                (json_distro,
                                 "count",
                                 json_object_new_int(distro->download_count));
+
+                       json_add_ddts(json_distro, distro->ddts);
+
                        distros++;
                }
        }
index 8394c5a..763800c 100644 (file)
@@ -1,5 +1,5 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.38.4.
-.TH PPASTATS "1" "September 2011" "ppastats 0.0.4" "User Commands"
+.TH PPASTATS "1" "September 2011" "ppastats 0.0.5" "User Commands"
 .SH NAME
 ppastats \- PPA Statistics command line tool
 .SH SYNOPSIS
index 3f94038..fdcd6e1 100644 (file)
@@ -90,6 +90,7 @@ static struct distro_stats *distro_stats_new(const char *name)
        d->name = strdup(name);
        d->archs = NULL;
        d->download_count = 0;
+       d->ddts = NULL;
 
        return d;
 }
@@ -194,7 +195,8 @@ struct daily_download_total **add_totals
 static void
 pkg_add_distro(struct package_stats *pkg,
               const char *distro_name,
-              int distro_count)
+              int distro_count,
+              struct daily_download_total **ddts)
 {
        struct distro_stats **pkg_distros, *pkg_distro;
 
@@ -219,6 +221,7 @@ pkg_add_distro(struct package_stats *pkg,
        }
 
        pkg_distro->download_count += distro_count;
+       pkg_distro->ddts = add_totals(pkg_distro->ddts, ddts);
 }
 
 struct ppa_stats *
@@ -287,7 +290,7 @@ create_ppa_stats(const char *owner,
                arch = get_arch_stats(distro, arch_series->architecture_tag);
                arch->download_count += count;
 
-               pkg_add_distro(pkg, distro_series->name, count);
+               pkg_add_distro(pkg, distro_series->name, count, totals);
 
                daily_download_total_list_free(totals);
 
index 671eea4..4fe6c65 100644 (file)
@@ -35,6 +35,7 @@ struct distro_stats {
 
        struct arch_stats **archs;
        int download_count;
+       struct daily_download_total **ddts;
 };
 
 struct version_stats {
index 9915e4c..f7fec11 100644 (file)
@@ -20,7 +20,7 @@ a:hover {
     text-decoration: underline;
 }
 
-#chart {
+#charts {
     color: #000;
     float: right;
     width: 80%;
index 81d2ef1..9c7e268 100644 (file)
@@ -35,6 +35,58 @@ function ppastats_chart(ddts) {
     });
 }
 
+function ppastats_distros(distros) {
+    var data_chart = [];
+    var max_date = null;
+    var min_date = null;
+    var series_opt = [];
+    
+    $.each(distros, function(i, distro) {
+       var arr = [];
+
+       $.each(distro["ddts"], function(j, item) {
+            var tm = item["time"];
+            var d = new Date(tm[0], tm[1]-1, tm[2]);
+            var entry = [d, item["value"]];
+            arr.push(entry);
+           
+            if (max_date == null || max_date < d) {
+               max_date = d;
+            }
+           
+            if (min_date == null || min_date > d) { 
+               min_date = d;
+            }
+       });
+       data_chart[i] = arr;
+       series_opt[i] = {label: distro["name"]};
+    });
+    
+    var plot1 = $.jqplot ('chart_distro', data_chart, {
+       title: 'Daily Download Count by Ubuntu Distribution',
+        axes: {
+           xaxis: {
+                renderer:$.jqplot.DateAxisRenderer,
+                tickOptions:{formatString:'%Y/%m/%d'},
+                min: min_date,
+                max: max_date
+           },
+           yaxis: {
+                min: 0
+           }
+        },
+        seriesDefaults: {
+           lineWidth:1,
+           showMarker:false
+       },
+       legend: {
+           show: true
+       },
+       series: series_opt
+    });
+}
+
+
 function ppastats_pkg() {
     $(document).ready(function() {
        $("#ppa_owner").html(data["ppa_owner"]);
@@ -54,6 +106,7 @@ function ppastats_pkg() {
 
 
        ppastats_chart(data["ddts"]);
+       ppastats_distros(data["distros"]);
     });
 }