]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-stats.c
Merge branch 'lh/readme'
[cgit.git] / ui-stats.c
index 9fc06d35135dc950fc1ff252b3c754fb2bced7cc..50c2540c860b6275b06b84576ecfd81c032e208d 100644 (file)
@@ -154,6 +154,14 @@ int cgit_find_stats_period(const char *expr, struct cgit_period **period)
        return 0;
 }
 
+const char *cgit_find_stats_periodname(int idx)
+{
+       if (idx > 0 && idx < 4)
+               return periods[idx - 1].name;
+       else
+               return "";
+}
+
 static void add_commit(struct string_list *authors, struct commit *commit,
        struct cgit_period *period)
 {
@@ -167,7 +175,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
 
        info = cgit_parse_commit(commit);
        tmp = xstrdup(info->author);
-       author = string_list_insert(tmp, authors);
+       author = string_list_insert(authors, tmp);
        if (!author->util)
                author->util = xcalloc(1, sizeof(struct authorstat));
        else
@@ -178,7 +186,7 @@ static void add_commit(struct string_list *authors, struct commit *commit,
        date = gmtime(&t);
        period->trunc(date);
        tmp = xstrdup(period->pretty(date));
-       item = string_list_insert(tmp, items);
+       item = string_list_insert(items, tmp);
        if (item->util)
                free(tmp);
        item->util++;
@@ -271,7 +279,7 @@ void print_combined_authorrow(struct string_list *authors, int from, int to,
                        author = &authors->items[i];
                        authorstat = author->util;
                        items = &authorstat->list;
-                       date = string_list_lookup(tmp, items);
+                       date = string_list_lookup(items, tmp);
                        if (date)
                                subtotal += (size_t)date->util;
                }
@@ -323,7 +331,7 @@ void print_authors(struct string_list *authors, int top,
                for (j = 0; j < period->count; j++) {
                        tmp = period->pretty(tm);
                        period->inc(tm);
-                       date = string_list_lookup(tmp, items);
+                       date = string_list_lookup(items, tmp);
                        if (!date)
                                html("<td>0</td>");
                        else {