From a48a3dcf56462a9de729ee6e0bcbf789fe74d9cd Mon Sep 17 00:00:00 2001
From: Jean-Philippe Orsini
Date: Tue, 6 Sep 2011 09:34:37 +0000
Subject: [PATCH] Added distribution chart in the package page.
---
NEWS | 1 +
configure | 21 ++++++++++-----------
src/html.c | 8 +++++++-
src/ppastats.1 | 2 +-
src/ppastats.c | 7 +++++--
src/ppastats.h | 1 +
www/css/ppastats.css | 2 +-
www/js/ppastats.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 79 insertions(+), 16 deletions(-)
diff --git a/NEWS b/NEWS
index 93e45ae..a944fb1 100644
--- 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).
diff --git a/configure b/configure
index 57191e3..887a83f 100755
--- 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 .
#
@@ -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\\"
diff --git a/src/html.c b/src/html.c
index 3d6c630..e1c9e9f 100644
--- a/src/html.c
+++ b/src/html.c
@@ -71,7 +71,10 @@ enum file_copy_error {
\n\
N/A/N/A\n\
\n\
- \n\
+ \n\
\n\
Versions:
\n\
Distros:
\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++;
}
}
diff --git a/src/ppastats.1 b/src/ppastats.1
index 8394c5a..763800c 100644
--- a/src/ppastats.1
+++ b/src/ppastats.1
@@ -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
diff --git a/src/ppastats.c b/src/ppastats.c
index 3f94038..fdcd6e1 100644
--- a/src/ppastats.c
+++ b/src/ppastats.c
@@ -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);
diff --git a/src/ppastats.h b/src/ppastats.h
index 671eea4..4fe6c65 100644
--- a/src/ppastats.h
+++ b/src/ppastats.h
@@ -35,6 +35,7 @@ struct distro_stats {
struct arch_stats **archs;
int download_count;
+ struct daily_download_total **ddts;
};
struct version_stats {
diff --git a/www/css/ppastats.css b/www/css/ppastats.css
index 9915e4c..f7fec11 100644
--- a/www/css/ppastats.css
+++ b/www/css/ppastats.css
@@ -20,7 +20,7 @@ a:hover {
text-decoration: underline;
}
-#chart {
+#charts {
color: #000;
float: right;
width: 80%;
diff --git a/www/js/ppastats.js b/www/js/ppastats.js
index 81d2ef1..9c7e268 100644
--- a/www/js/ppastats.js
+++ b/www/js/ppastats.js
@@ -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"]);
});
}
--
2.7.4