|
|
|
@@ -166,36 +166,36 @@ static void add_commit(struct string_list *authors, struct commit *commit, |
166 | struct cgit_period *period) |
166 | struct cgit_period *period) |
167 | { |
167 | { |
168 | struct commitinfo *info; |
168 | struct commitinfo *info; |
169 | struct string_list_item *author, *item; |
169 | struct string_list_item *author, *item; |
170 | struct authorstat *authorstat; |
170 | struct authorstat *authorstat; |
171 | struct string_list *items; |
171 | struct string_list *items; |
172 | char *tmp; |
172 | char *tmp; |
173 | struct tm *date; |
173 | struct tm *date; |
174 | time_t t; |
174 | time_t t; |
175 | |
175 | |
176 | info = cgit_parse_commit(commit); |
176 | info = cgit_parse_commit(commit); |
177 | tmp = xstrdup(info->author); |
177 | tmp = xstrdup(info->author); |
178 | author = string_list_insert(tmp, authors); |
178 | author = string_list_insert(authors, tmp); |
179 | if (!author->util) |
179 | if (!author->util) |
180 | author->util = xcalloc(1, sizeof(struct authorstat)); |
180 | author->util = xcalloc(1, sizeof(struct authorstat)); |
181 | else |
181 | else |
182 | free(tmp); |
182 | free(tmp); |
183 | authorstat = author->util; |
183 | authorstat = author->util; |
184 | items = &authorstat->list; |
184 | items = &authorstat->list; |
185 | t = info->committer_date; |
185 | t = info->committer_date; |
186 | date = gmtime(&t); |
186 | date = gmtime(&t); |
187 | period->trunc(date); |
187 | period->trunc(date); |
188 | tmp = xstrdup(period->pretty(date)); |
188 | tmp = xstrdup(period->pretty(date)); |
189 | item = string_list_insert(tmp, items); |
189 | item = string_list_insert(items, tmp); |
190 | if (item->util) |
190 | if (item->util) |
191 | free(tmp); |
191 | free(tmp); |
192 | item->util++; |
192 | item->util++; |
193 | authorstat->total++; |
193 | authorstat->total++; |
194 | cgit_free_commitinfo(info); |
194 | cgit_free_commitinfo(info); |
195 | } |
195 | } |
196 | |
196 | |
197 | static int cmp_total_commits(const void *a1, const void *a2) |
197 | static int cmp_total_commits(const void *a1, const void *a2) |
198 | { |
198 | { |
199 | const struct string_list_item *i1 = a1; |
199 | const struct string_list_item *i1 = a1; |
200 | const struct string_list_item *i2 = a2; |
200 | const struct string_list_item *i2 = a2; |
201 | const struct authorstat *auth1 = i1->util; |
201 | const struct authorstat *auth1 = i1->util; |
@@ -270,25 +270,25 @@ void print_combined_authorrow(struct string_list *authors, int from, int to, |
270 | |
270 | |
271 | total = 0; |
271 | total = 0; |
272 | htmlf("<tr><td class='%s'>%s</td>", leftclass, |
272 | htmlf("<tr><td class='%s'>%s</td>", leftclass, |
273 | fmt(name, to - from + 1)); |
273 | fmt(name, to - from + 1)); |
274 | for (j = 0; j < period->count; j++) { |
274 | for (j = 0; j < period->count; j++) { |
275 | tmp = period->pretty(tm); |
275 | tmp = period->pretty(tm); |
276 | period->inc(tm); |
276 | period->inc(tm); |
277 | subtotal = 0; |
277 | subtotal = 0; |
278 | for (i = from; i <= to; i++) { |
278 | for (i = from; i <= to; i++) { |
279 | author = &authors->items[i]; |
279 | author = &authors->items[i]; |
280 | authorstat = author->util; |
280 | authorstat = author->util; |
281 | items = &authorstat->list; |
281 | items = &authorstat->list; |
282 | date = string_list_lookup(tmp, items); |
282 | date = string_list_lookup(items, tmp); |
283 | if (date) |
283 | if (date) |
284 | subtotal += (size_t)date->util; |
284 | subtotal += (size_t)date->util; |
285 | } |
285 | } |
286 | htmlf("<td class='%s'>%d</td>", centerclass, subtotal); |
286 | htmlf("<td class='%s'>%d</td>", centerclass, subtotal); |
287 | total += subtotal; |
287 | total += subtotal; |
288 | } |
288 | } |
289 | htmlf("<td class='%s'>%d</td></tr>", rightclass, total); |
289 | htmlf("<td class='%s'>%d</td></tr>", rightclass, total); |
290 | } |
290 | } |
291 | |
291 | |
292 | void print_authors(struct string_list *authors, int top, |
292 | void print_authors(struct string_list *authors, int top, |
293 | struct cgit_period *period) |
293 | struct cgit_period *period) |
294 | { |
294 | { |
@@ -322,25 +322,25 @@ void print_authors(struct string_list *authors, int top, |
322 | author = &authors->items[i]; |
322 | author = &authors->items[i]; |
323 | html("<tr><td class='left'>"); |
323 | html("<tr><td class='left'>"); |
324 | html_txt(author->string); |
324 | html_txt(author->string); |
325 | html("</td>"); |
325 | html("</td>"); |
326 | authorstat = author->util; |
326 | authorstat = author->util; |
327 | items = &authorstat->list; |
327 | items = &authorstat->list; |
328 | total = 0; |
328 | total = 0; |
329 | for (j = 0; j < period->count; j++) |
329 | for (j = 0; j < period->count; j++) |
330 | period->dec(tm); |
330 | period->dec(tm); |
331 | for (j = 0; j < period->count; j++) { |
331 | for (j = 0; j < period->count; j++) { |
332 | tmp = period->pretty(tm); |
332 | tmp = period->pretty(tm); |
333 | period->inc(tm); |
333 | period->inc(tm); |
334 | date = string_list_lookup(tmp, items); |
334 | date = string_list_lookup(items, tmp); |
335 | if (!date) |
335 | if (!date) |
336 | html("<td>0</td>"); |
336 | html("<td>0</td>"); |
337 | else { |
337 | else { |
338 | htmlf("<td>%d</td>", date->util); |
338 | htmlf("<td>%d</td>", date->util); |
339 | total += (size_t)date->util; |
339 | total += (size_t)date->util; |
340 | } |
340 | } |
341 | } |
341 | } |
342 | htmlf("<td class='sum'>%d</td></tr>", total); |
342 | htmlf("<td class='sum'>%d</td></tr>", total); |
343 | } |
343 | } |
344 | |
344 | |
345 | if (top < authors->nr) |
345 | if (top < authors->nr) |
346 | print_combined_authorrow(authors, top, authors->nr - 1, |
346 | print_combined_authorrow(authors, top, authors->nr - 1, |
|