X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/e21da6c2a6ffcd8b4a2b2b06cf7486f36f291a5b..3c53ebfb57a5dba8fc65b2f99ebbfb6356666e34:/ui-stats.c diff --git a/ui-stats.c b/ui-stats.c index 84b247c..a264f6a 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -209,13 +209,12 @@ static int cmp_total_commits(const void *a1, const void *a2) /* Walk the commit DAG and collect number of commits per author per * timeperiod into a nested string_list collection. */ -static struct string_list collect_stats(struct cgit_context *ctx, - struct cgit_period *period) +static struct string_list collect_stats(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}; + const char *argv[] = {NULL, ctx.qry.head, NULL, NULL, NULL, NULL}; int argc = 3; time_t now; long i; @@ -229,9 +228,9 @@ static struct string_list collect_stats(struct cgit_context *ctx, period->dec(tm); strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm); argv[2] = xstrdup(fmt("--since=%s", tmp)); - if (ctx->qry.path) { + if (ctx.qry.path) { argv[3] = "--"; - argv[4] = ctx->qry.path; + argv[4] = ctx.qry.path; argc += 2; } init_revisions(&rev, NULL); @@ -245,8 +244,9 @@ static struct string_list collect_stats(struct cgit_context *ctx, memset(&authors, 0, sizeof(authors)); while ((commit = get_revision(&rev)) != NULL) { add_commit(&authors, commit, period); - free(commit->buffer); + free_commit_buffer(commit); free_commit_list(commit->parents); + commit->parents = NULL; } return authors; } @@ -360,30 +360,30 @@ static void print_authors(struct string_list *authors, int top, * 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) +void cgit_show_stats(void) { struct string_list authors; struct cgit_period *period; int top, i; const char *code = "w"; - if (ctx->qry.period) - code = ctx->qry.period; + if (ctx.qry.period) + code = ctx.qry.period; i = cgit_find_stats_period(code, &period); if (!i) { cgit_print_error("Unknown statistics type: %c", code[0]); return; } - if (i > ctx->repo->max_stats) { + if (i > ctx.repo->max_stats) { cgit_print_error("Statistics type disabled: %s", period->name); return; } - authors = collect_stats(ctx, period); + authors = collect_stats(period); qsort(authors.items, authors.nr, sizeof(struct string_list_item), cmp_total_commits); - top = ctx->qry.ofs; + top = ctx.qry.ofs; if (!top) top = 10; @@ -392,10 +392,10 @@ void cgit_show_stats(struct cgit_context *ctx) html("
"); cgit_add_hidden_formfields(1, 0, "stats"); html(""); - if (ctx->repo->max_stats > 1) { + if (ctx.repo->max_stats > 1) { html(""); html(""); @@ -414,9 +414,9 @@ void cgit_show_stats(struct cgit_context *ctx) html(""); html(""); htmlf("

Commits per author per %s", period->name); - if (ctx->qry.path) { + if (ctx.qry.path) { html(" (path '"); - html_txt(ctx->qry.path); + html_txt(ctx.qry.path); html("')"); } html("

");
Period: