summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-12-07 12:17:21 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-12-07 12:17:21 (UTC)
commitfb2f3f6c29bad733723152893c5246a756e4cada (patch) (side-by-side diff)
tree5b2953c0c116f276ca48beee676a6662b6329d95
parentc6a6aa2186daf39814baa0e71378c2e9e1041002 (diff)
downloadcgit-fb2f3f6c29bad733723152893c5246a756e4cada.zip
cgit-fb2f3f6c29bad733723152893c5246a756e4cada.tar.gz
cgit-fb2f3f6c29bad733723152893c5246a756e4cada.tar.bz2
ui-stats: replace 'enable-stats' setting with 'max-stats'
The new 'max-stats' and 'repo.max-stats' settings makes it possible to define the maximum statistics period, both globally and per repo. Hence, it is now feasible to allow statistics on repositories with a high commit frequency, like linux-2.6, by setting repo.max-stats to e.g. 'month'. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c10
-rw-r--r--cgit.h4
-rw-r--r--cgitrc.5.txt23
-rw-r--r--cmd.c5
-rw-r--r--shared.c2
-rw-r--r--ui-shared.c2
-rw-r--r--ui-stats.c97
-rw-r--r--ui-stats.h19
8 files changed, 104 insertions, 58 deletions
diff --git a/cgit.c b/cgit.c
index 22b6d7c..57e11cd 100644
--- a/cgit.c
+++ b/cgit.c
@@ -3,24 +3,25 @@
* Copyright (C) 2006 Lars Hjemli
*
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
#include "cache.h"
#include "cmd.h"
#include "configfile.h"
#include "html.h"
#include "ui-shared.h"
+#include "ui-stats.h"
#include "scan-tree.h"
const char *cgit_version = CGIT_VERSION;
void config_cb(const char *name, const char *value)
{
if (!strcmp(name, "root-title"))
ctx.cfg.root_title = xstrdup(value);
else if (!strcmp(name, "root-desc"))
ctx.cfg.root_desc = xstrdup(value);
else if (!strcmp(name, "root-readme"))
ctx.cfg.root_readme = xstrdup(value);
@@ -45,26 +46,26 @@ void config_cb(const char *name, const char *value)
if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
ctx.cfg.virtual_root = "";
} else if (!strcmp(name, "nocache"))
ctx.cfg.nocache = atoi(value);
else if (!strcmp(name, "snapshots"))
ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-index-links"))
ctx.cfg.enable_index_links = atoi(value);
else if (!strcmp(name, "enable-log-filecount"))
ctx.cfg.enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
ctx.cfg.enable_log_linecount = atoi(value);
- else if (!strcmp(name, "enable-stats"))
- ctx.cfg.enable_stats = atoi(value);
+ else if (!strcmp(name, "max-stats"))
+ ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
else if (!strcmp(name, "cache-size"))
ctx.cfg.cache_size = atoi(value);
else if (!strcmp(name, "cache-root"))
ctx.cfg.cache_root = xstrdup(value);
else if (!strcmp(name, "cache-root-ttl"))
ctx.cfg.cache_root_ttl = atoi(value);
else if (!strcmp(name, "cache-repo-ttl"))
ctx.cfg.cache_repo_ttl = atoi(value);
else if (!strcmp(name, "cache-static-ttl"))
ctx.cfg.cache_static_ttl = atoi(value);
else if (!strcmp(name, "cache-dynamic-ttl"))
ctx.cfg.cache_dynamic_ttl = atoi(value);
@@ -105,26 +106,26 @@ void config_cb(const char *name, const char *value)
else if (ctx.repo && !strcmp(name, "repo.desc"))
ctx.repo->desc = xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.owner"))
ctx.repo->owner = xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.defbranch"))
ctx.repo->defbranch = xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.snapshots"))
ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
- else if (ctx.repo && !strcmp(name, "repo.enable-stats"))
- ctx.repo->enable_stats = ctx.cfg.enable_stats && atoi(value);
+ else if (ctx.repo && !strcmp(name, "repo.max-stats"))
+ ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
else if (ctx.repo && !strcmp(name, "repo.module-link"))
ctx.repo->module_link= xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
if (*value == '/')
ctx.repo->readme = xstrdup(value);
else
ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
} else if (!strcmp(name, "include"))
parse_configfile(value, config_cb);
}
static void querystring_cb(const char *name, const char *value)
@@ -174,24 +175,25 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.cache_repo_ttl = 5;
ctx->cfg.cache_root = CGIT_CACHE_ROOT;
ctx->cfg.cache_root_ttl = 5;
ctx->cfg.cache_static_ttl = -1;
ctx->cfg.css = "/cgit.css";
ctx->cfg.logo = "/git-logo.png";
ctx->cfg.local_time = 0;
ctx->cfg.max_repo_count = 50;
ctx->cfg.max_commit_count = 50;
ctx->cfg.max_lock_attempts = 5;
ctx->cfg.max_msg_len = 80;
ctx->cfg.max_repodesc_len = 80;
+ ctx->cfg.max_stats = 0;
ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
ctx->cfg.renamelimit = -1;
ctx->cfg.robots = "index, nofollow";
ctx->cfg.root_title = "Git repository browser";
ctx->cfg.root_desc = "a fast webinterface for the git dscm";
ctx->cfg.script_name = CGIT_SCRIPT_NAME;
ctx->cfg.summary_branches = 10;
ctx->cfg.summary_log = 10;
ctx->cfg.summary_tags = 10;
ctx->page.mimetype = "text/html";
ctx->page.charset = PAGE_ENCODING;
ctx->page.filename = NULL;
diff --git a/cgit.h b/cgit.h
index 85045c4..f2cb671 100644
--- a/cgit.h
+++ b/cgit.h
@@ -52,25 +52,25 @@ struct cgit_repo {
char *name;
char *path;
char *desc;
char *owner;
char *defbranch;
char *group;
char *module_link;
char *readme;
char *clone_url;
int snapshots;
int enable_log_filecount;
int enable_log_linecount;
- int enable_stats;
+ int max_stats;
};
struct cgit_repolist {
int length;
int count;
struct cgit_repo *repos;
};
struct commitinfo {
struct commit *commit;
char *author;
char *author_email;
@@ -144,31 +144,31 @@ struct cgit_config {
char *root_readme;
char *script_name;
char *virtual_root;
int cache_size;
int cache_dynamic_ttl;
int cache_max_create_time;
int cache_repo_ttl;
int cache_root_ttl;
int cache_static_ttl;
int enable_index_links;
int enable_log_filecount;
int enable_log_linecount;
- int enable_stats;
int local_time;
int max_repo_count;
int max_commit_count;
int max_lock_attempts;
int max_msg_len;
int max_repodesc_len;
+ int max_stats;
int nocache;
int renamelimit;
int snapshots;
int summary_branches;
int summary_log;
int summary_tags;
};
struct cgit_page {
time_t modified;
time_t expires;
size_t size;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 60d3ea4..0bbbea3 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -65,28 +65,24 @@ enable-index-links
"commit" and "tree" pages). Default value: "0".
enable-log-filecount
Flag which, when set to "1", will make cgit print the number of
modified files for each commit on the repository log page. Default
value: "0".
enable-log-linecount
Flag which, when set to "1", will make cgit print the number of added
and removed lines for each commit on the repository log page. Default
value: "0".
-enable-stats
- Globally enable/disable statistics for each repository. Default
- value: "0".
-
favicon
Url used as link to a shortcut icon for cgit. If specified, it is
suggested to use the value "/favicon.ico" since certain browsers will
ignore other values. Default value: none.
footer
The content of the file specified with this option will be included
verbatim at the bottom of all pages (i.e. it replaces the standard
"generated by..." message. Default value: none.
include
Name of a configfile to include before the rest of the current config-
@@ -124,24 +120,29 @@ max-commit-count
max-message-length
Specifies the maximum number of commit message characters to display in
"log" view. Default value: "80".
max-repo-count
Specifies the number of entries to list per page on the repository
index page. Default value: "50".
max-repodesc-length
Specifies the maximum number of repo description characters to display
on the repository index page. Default value: "80".
+max-stats
+ Set the default maximum statistics period. Valid values are "week",
+ "month", "quarter" and "year". If unspecified, statistics are
+ disabled. Default value: none. See also: "repo.max-stats".
+
module-link
Text which will be used as the formatstring for a hyperlink when a
submodule is printed in a directory listing. The arguments for the
formatstring are the path and SHA1 of the submodule commit. Default
value: "./?repo=%s&page=commit&id=%s"
nocache
If set to the value "1" caching will be disabled. This settings is
deprecated, and will not be honored starting with cgit-1.0. Default
value: "0".
renamelimit
@@ -213,27 +214,28 @@ repo.defbranch
repo.desc
The value to show as repository description. Default value: none.
repo.enable-log-filecount
A flag which can be used to disable the global setting
`enable-log-filecount'. Default value: none.
repo.enable-log-linecount
A flag which can be used to disable the global setting
`enable-log-linecount'. Default value: none.
-repo.enable-stats
- A flag which can be used to disable the global setting
- `enable-stats'. Default value: none.
+repo.max-stats
+ Override the default maximum statistics period. Valid values are equal
+ to the values specified for the global "max-stats" setting. Default
+ value: none.
repo.name
The value to show as repository name. Default value: <repo.url>.
repo.owner
A value used to identify the owner of the repository. Default value:
none.
repo.path
An absolute path to the repository directory. For non-bare repositories
this is the .git-directory. Default value: none.
@@ -275,24 +277,28 @@ enable-log-filecount=1
# Show number of added/removed lines per commit on the log pages
enable-log-linecount=1
# Add a cgit favicon
favicon=/favicon.ico
# Use a custom logo
logo=/img/mylogo.png
+# Enable statistics per week, month and quarter
+max-stats=quarter
+
+
# Set the title and heading of the repository index page
root-title=foobar.com git repositories
# Set a subheading for the repository index page
root-desc=tracking the foobar development
# Include some more info about foobar.com on the index page
root-readme=/var/www/htdocs/about.html
@@ -347,24 +353,27 @@ repo.desc=the dscm
repo.url=linux
repo.path=/pub/git/linux.git
repo.desc=the kernel
# Disable adhoc downloads of this repo
repo.snapshots=0
# Disable line-counts for this repo
repo.enable-log-linecount=0
+# Restrict the max statistics period for this repo
+repo.max-stats=month
+
BUGS
----
Comments currently cannot appear on the same line as a setting; the comment
will be included as part of the value. E.g. this line:
robots=index # allow indexing
will generate the following html element:
<meta name='robots' content='index # allow indexing'/>
diff --git a/cmd.c b/cmd.c
index 744bf84..763a558 100644
--- a/cmd.c
+++ b/cmd.c
@@ -103,28 +103,25 @@ static void refs_fn(struct cgit_context *ctx)
cgit_print_refs();
}
static void snapshot_fn(struct cgit_context *ctx)
{
cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1,
cgit_repobasename(ctx->repo->url), ctx->qry.path,
ctx->repo->snapshots, ctx->qry.nohead);
}
static void stats_fn(struct cgit_context *ctx)
{
- if (ctx->repo->enable_stats)
- cgit_show_stats(ctx);
- else
- cgit_print_error("Stats disabled for this repo");
+ cgit_show_stats(ctx);
}
static void summary_fn(struct cgit_context *ctx)
{
cgit_print_summary();
}
static void tag_fn(struct cgit_context *ctx)
{
cgit_print_tag(ctx->qry.sha1);
}
diff --git a/shared.c b/shared.c
index 37333f0..7382609 100644
--- a/shared.c
+++ b/shared.c
@@ -49,25 +49,25 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret = &cgit_repolist.repos[cgit_repolist.count-1];
ret->url = trim_end(url, '/');
ret->name = ret->url;
ret->path = NULL;
ret->desc = "[no description]";
ret->owner = NULL;
ret->group = ctx.cfg.repo_group;
ret->defbranch = "master";
ret->snapshots = ctx.cfg.snapshots;
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
- ret->enable_stats = ctx.cfg.enable_stats;
+ ret->max_stats = ctx.cfg.max_stats;
ret->module_link = ctx.cfg.module_link;
ret->readme = NULL;
return ret;
}
struct cgit_repo *cgit_get_repoinfo(const char *url)
{
int i;
struct cgit_repo *repo;
for (i=0; i<cgit_repolist.count; i++) {
repo = &cgit_repolist.repos[i];
diff --git a/ui-shared.c b/ui-shared.c
index 0e688a0..97b9d46 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -632,25 +632,25 @@ void cgit_print_pageheader(struct cgit_context *ctx)
cgit_summary_link("summary", NULL, hc(cmd, "summary"),
ctx->qry.head);
cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
ctx->qry.sha1, NULL);
cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
NULL, NULL, 0, NULL, NULL);
cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
ctx->qry.sha1, NULL);
cgit_commit_link("commit", NULL, hc(cmd, "commit"),
ctx->qry.head, ctx->qry.sha1);
cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
ctx->qry.sha1, ctx->qry.sha2, NULL);
- if (ctx->repo->enable_stats)
+ if (ctx->repo->max_stats)
reporevlink("stats", "stats", NULL, hc(cmd, "stats"),
ctx->qry.head, NULL, NULL);
if (ctx->repo->readme)
reporevlink("about", "about", NULL,
hc(cmd, "about"), ctx->qry.head, NULL,
NULL);
html("</td><td class='form'>");
html("<form class='right' method='get' action='");
if (ctx->cfg.virtual_root)
html_url_path(cgit_fileurl(ctx->qry.repo, "log",
ctx->qry.path, NULL));
html("'>\n");
diff --git a/ui-stats.c b/ui-stats.c
index 3cc8d70..1104485 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -1,35 +1,21 @@
+#include <string-list.h>
+
#include "cgit.h"
#include "html.h"
-#include <string-list.h>
+#include "ui-shared.h"
+#include "ui-stats.h"
#define MONTHS 6
-struct Period {
- const char code;
- const char *name;
- int max_periods;
- int count;
-
- /* Convert a tm value to the first day in the period */
- void (*trunc)(struct tm *tm);
-
- /* Update tm value to start of next/previous period */
- void (*dec)(struct tm *tm);
- void (*inc)(struct tm *tm);
-
- /* Pretty-print a tm value */
- char *(*pretty)(struct tm *tm);
-};
-
struct authorstat {
long total;
struct string_list list;
};
#define DAY_SECS (60 * 60 * 24)
#define WEEK_SECS (DAY_SECS * 7)
static void trunc_week(struct tm *tm)
{
time_t t = timegm(tm);
t -= ((tm->tm_wday + 6) % 7) * DAY_SECS;
@@ -128,33 +114,57 @@ static void dec_year(struct tm *tm)
}
static void inc_year(struct tm *tm)
{
tm->tm_year++;
}
static char *pretty_year(struct tm *tm)
{
return fmt("%d", tm->tm_year + 1900);
}
-struct Period periods[] = {
+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},
};
+/* Given a period code or name, return a period index (1, 2, 3 or 4)
+ * and update the period pointer to the correcsponding struct.
+ * If no matching code is found, return 0.
+ */
+int cgit_find_stats_period(const char *expr, struct cgit_period **period)
+{
+ int i;
+ char code = '\0';
+
+ if (!expr)
+ return 0;
+
+ if (strlen(expr) == 1)
+ code = expr[0];
+
+ for (i = 0; i < sizeof(periods) / sizeof(periods[0]); i++)
+ if (periods[i].code == code || !strcmp(periods[i].name, expr)) {
+ if (period)
+ *period = &periods[i];
+ return i+1;
+ }
+ return 0;
+}
+
static void add_commit(struct string_list *authors, struct commit *commit,
- struct Period *period)
+ struct cgit_period *period)
{
struct commitinfo *info;
struct string_list_item *author, *item;
struct authorstat *authorstat;
struct string_list *items;
char *tmp;
struct tm *date;
time_t t;
info = cgit_parse_commit(commit);
tmp = xstrdup(info->author);
author = string_list_insert(tmp, authors);
@@ -181,25 +191,25 @@ static int cmp_total_commits(const void *a1, const void *a2)
const struct string_list_item *i1 = a1;
const struct string_list_item *i2 = a2;
const struct authorstat *auth1 = i1->util;
const struct authorstat *auth2 = i2->util;
return auth2->total - auth1->total;
}
/* Walk the commit DAG and collect number of commits per author per
* timeperiod into a nested string_list collection.
*/
struct string_list collect_stats(struct cgit_context *ctx,
- struct Period *period)
+ struct cgit_period *period)
{
struct string_list authors;
struct rev_info rev;
struct commit *commit;
const char *argv[] = {NULL, ctx->qry.head, NULL, NULL, NULL, NULL};
int argc = 3;
time_t now;
long i;
struct tm *tm;
char tmp[11];
time(&now);
@@ -224,25 +234,25 @@ struct string_list collect_stats(struct cgit_context *ctx,
prepare_revision_walk(&rev);
memset(&authors, 0, sizeof(authors));
while ((commit = get_revision(&rev)) != NULL) {
add_commit(&authors, commit, period);
free(commit->buffer);
free_commit_list(commit->parents);
}
return authors;
}
void print_combined_authorrow(struct string_list *authors, int from, int to,
const char *name, const char *leftclass, const char *centerclass,
- const char *rightclass, struct Period *period)
+ const char *rightclass, struct cgit_period *period)
{
struct string_list_item *author;
struct authorstat *authorstat;
struct string_list *items;
struct string_list_item *date;
time_t now;
long i, j, total, subtotal;
struct tm *tm;
char *tmp;
time(&now);
tm = gmtime(&now);
@@ -262,25 +272,26 @@ void print_combined_authorrow(struct string_list *authors, int from, int to,
authorstat = author->util;
items = &authorstat->list;
date = string_list_lookup(tmp, items);
if (date)
subtotal += (size_t)date->util;
}
htmlf("<td class='%s'>%d</td>", centerclass, subtotal);
total += subtotal;
}
htmlf("<td class='%s'>%d</td></tr>", rightclass, total);
}
-void print_authors(struct string_list *authors, int top, struct Period *period)
+void print_authors(struct string_list *authors, int top,
+ struct cgit_period *period)
{
struct string_list_item *author;
struct authorstat *authorstat;
struct string_list *items;
struct string_list_item *date;
time_t now;
long i, j, total;
struct tm *tm;
char *tmp;
time(&now);
tm = gmtime(&now);
@@ -330,61 +341,69 @@ void print_authors(struct string_list *authors, int top, struct Period *period)
print_combined_authorrow(authors, 0, authors->nr - 1, "Total",
"total", "sum", "sum", period);
html("</table>");
}
/* Create a sorted string_list with one entry per author. The util-field
* for each author is another string_list which is used to calculate the
* number of commits per time-interval.
*/
void cgit_show_stats(struct cgit_context *ctx)
{
struct string_list authors;
- struct Period *period;
+ struct cgit_period *period;
int top, i;
+ const char *code = "w";
- period = &periods[0];
- if (ctx->qry.period) {
- for (i = 0; i < sizeof(periods) / sizeof(periods[0]); i++)
- if (periods[i].code == ctx->qry.period[0]) {
- period = &periods[i];
- break;
- }
+ if (ctx->qry.period)
+ code = ctx->qry.period;
+
+ i = cgit_find_stats_period(code, &period);
+ if (!i) {
+ cgit_print_error(fmt("Unknown statistics type: %c", code));
+ return;
+ }
+ if (i > ctx->repo->max_stats) {
+ cgit_print_error(fmt("Statistics type disabled: %s",
+ period->name));
+ return;
}
authors = collect_stats(ctx, period);
qsort(authors.items, authors.nr, sizeof(struct string_list_item),
cmp_total_commits);
top = ctx->qry.ofs;
if (!top)
top = 10;
htmlf("<h2>Commits per author per %s", period->name);
if (ctx->qry.path) {
html(" (path '");
html_txt(ctx->qry.path);
html("')");
}
html("</h2>");
html("<form method='get' action='.' style='float: right; text-align: right;'>");
if (strcmp(ctx->qry.head, ctx->repo->defbranch))
htmlf("<input type='hidden' name='h' value='%s'/>", ctx->qry.head);
- html("Period: ");
- html("<select name='period' onchange='this.form.submit();'>");
- for (i = 0; i < sizeof(periods) / sizeof(periods[0]); i++)
- htmlf("<option value='%c'%s>%s</option>",
- periods[i].code,
- period == &periods[i] ? " selected" : "",
- periods[i].name);
- html("</select><br/><br/>");
+ if (ctx->repo->max_stats > 1) {
+ html("Period: ");
+ html("<select name='period' onchange='this.form.submit();'>");
+ for (i = 0; i < ctx->repo->max_stats; i++)
+ htmlf("<option value='%c'%s>%s</option>",
+ periods[i].code,
+ period == &periods[i] ? " selected" : "",
+ periods[i].name);
+ html("</select><br/><br/>");
+ }
html("Authors: ");
html("");
html("<select name='ofs' onchange='this.form.submit();'>");
htmlf("<option value='10'%s>10</option>", top == 10 ? " selected" : "");
htmlf("<option value='25'%s>25</option>", top == 25 ? " selected" : "");
htmlf("<option value='50'%s>50</option>", top == 50 ? " selected" : "");
htmlf("<option value='100'%s>100</option>", top == 100 ? " selected" : "");
htmlf("<option value='-1'%s>All</option>", top == -1 ? " selected" : "");
html("</select>");
html("<noscript>&nbsp;&nbsp;<input type='submit' value='Reload'/></noscript>");
html("</form>");
print_authors(&authors, top, period);
diff --git a/ui-stats.h b/ui-stats.h
index f1d744c..4f13dba 100644
--- a/ui-stats.h
+++ b/ui-stats.h
@@ -1,8 +1,27 @@
#ifndef UI_STATS_H
#define UI_STATS_H
#include "cgit.h"
+struct cgit_period {
+ const char code;
+ const char *name;
+ int max_periods;
+ int count;
+
+ /* Convert a tm value to the first day in the period */
+ void (*trunc)(struct tm *tm);
+
+ /* Update tm value to start of next/previous period */
+ void (*dec)(struct tm *tm);
+ void (*inc)(struct tm *tm);
+
+ /* Pretty-print a tm value */
+ char *(*pretty)(struct tm *tm);
+};
+
+extern int cgit_find_stats_period(const char *expr, struct cgit_period **period);
+
extern void cgit_show_stats(struct cgit_context *ctx);
#endif /* UI_STATS_H */