From: plenz at cis.fu-berlin.de (Julius Plenz)
Subject: [PATCH 3/4] Make number of columns in stat overview configurable
Date: Tue, 30 Oct 2012 14:07:17 +0100 [thread overview]
Message-ID: <1351602438-955878-4-git-send-email-plenz@cis.fu-berlin.de> (raw)
In-Reply-To: <1351602438-955878-1-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 <plenz at cis.fu-berlin.de>
---
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("</select></td></tr>");
+
+ html("<tr><td class='label'>Columns:</td>");
+ html("<td class='ctrl'><select name='nr_periods' onchange='this.form.submit();'>");
+ html_intoption(1, "1", cols);
+ html_intoption(4, "4", cols);
+ html_intoption(12, "12", cols);
+ html_intoption(24, "24", cols);
+ html("</select></td></tr>");
+
html("<tr><td/><td class='ctrl'>");
html("<noscript><input type='submit' value='Reload'/></noscript>");
html("</td></tr></table>");
--
1.7.12.3-zedat
next prev parent reply other threads:[~2012-10-30 13:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-30 13:07 [PATCH 0/4] some miscellaneous features plenz
2012-10-30 13:07 ` [PATCH 1/4] tree view: imitate proper permissions plenz
2012-10-30 13:07 ` [PATCH 2/4] Introduce "dont-display-suffix" option plenz
2012-11-01 4:03 ` mathstuf
2012-11-01 4:22 ` Jason
2012-11-01 10:52 ` plenz
2012-10-30 13:07 ` plenz [this message]
2012-10-30 13:07 ` [PATCH 4/4] Introduce a fallback encoding (eg. for blobs) plenz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351602438-955878-4-git-send-email-plenz@cis.fu-berlin.de \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).