From mboxrd@z Thu Jan 1 00:00:00 1970 From: plenz at cis.fu-berlin.de (Julius Plenz) Date: Tue, 30 Oct 2012 14:07:17 +0100 Subject: [PATCH 3/4] Make number of columns in stat overview configurable In-Reply-To: <1351602438-955878-1-git-send-email-plenz@cis.fu-berlin.de> References: <1351602438-955878-1-git-send-email-plenz@cis.fu-berlin.de> Message-ID: <1351602438-955878-4-git-send-email-plenz@cis.fu-berlin.de> I'm pretty sure this constitutes a violation of how the data structure cgit_period's use was intended, but that's much easier than passing the "count" parameter to all the functions that need it. Signed-off-by: Julius Plenz --- cgit.c | 2 ++ cgit.h | 1 + ui-stats.c | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cgit.c b/cgit.c index f1105fb..04637ab 100644 --- a/cgit.c +++ b/cgit.c @@ -305,6 +305,8 @@ static void querystring_cb(const char *name, const char *value) ctx.qry.showmsg = atoi(value); } else if (!strcmp(name, "period")) { ctx.qry.period = xstrdup(value); + } else if (!strcmp(name, "nr_periods")) { + ctx.qry.nr_periods = atoi(value); } else if (!strcmp(name, "ss")) { ctx.qry.ssdiff = atoi(value); ctx.qry.has_ssdiff = 1; diff --git a/cgit.h b/cgit.h index 5692224..4a3f528 100644 --- a/cgit.h +++ b/cgit.h @@ -161,6 +161,7 @@ struct cgit_query { int context; int ignorews; char *vpath; + int nr_periods; }; struct cgit_config { diff --git a/ui-stats.c b/ui-stats.c index 59f4c1e..4ca8c4a 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -128,10 +128,10 @@ static char *pretty_year(struct tm *tm) } struct cgit_period periods[] = { - {'w', "week", 12, 4, trunc_week, dec_week, inc_week, pretty_week}, - {'m', "month", 12, 4, trunc_month, dec_month, inc_month, pretty_month}, - {'q', "quarter", 12, 4, trunc_quarter, dec_quarter, inc_quarter, pretty_quarter}, - {'y', "year", 12, 4, trunc_year, dec_year, inc_year, pretty_year}, + {'w', "week", 24, 4, trunc_week, dec_week, inc_week, pretty_week}, + {'m', "month", 24, 4, trunc_month, dec_month, inc_month, pretty_month}, + {'q', "quarter", 24, 4, trunc_quarter, dec_quarter, inc_quarter, pretty_quarter}, + {'y', "year", 24, 4, trunc_year, dec_year, inc_year, pretty_year}, }; /* Given a period code or name, return a period index (1, 2, 3 or 4) @@ -363,7 +363,7 @@ void cgit_show_stats(struct cgit_context *ctx) { struct string_list authors; struct cgit_period *period; - int top, i; + int top, cols, i; const char *code = "w"; if (ctx->qry.period) @@ -379,6 +379,13 @@ void cgit_show_stats(struct cgit_context *ctx) period->name)); return; } + + cols = ctx->qry.nr_periods; + if(!cols || cols > period->max_periods) + cols = period->count; + else + period->count = cols; + authors = collect_stats(ctx, period); qsort(authors.items, authors.nr, sizeof(struct string_list_item), cmp_total_commits); @@ -408,6 +415,15 @@ void cgit_show_stats(struct cgit_context *ctx) html_intoption(100, "100", top); html_intoption(-1, "all", top); html(""); + + html("Columns:"); + html(""); + html(""); html(""); html(""); -- 1.7.12.3-zedat