Fossil SCM
Add the "Checkins Per File" report to the /reports page.
Commit
ec8c7498c0eb34183722ecc8b6b8b670c68de274
Parent
39cd06c9f764cf6…
1 file changed
+53
+53
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -453,10 +453,59 @@ | ||
| 453 | 453 | } |
| 454 | 454 | @ </tbody></table> |
| 455 | 455 | db_finalize(&query); |
| 456 | 456 | output_table_sorting_javascript("statsTable","tkx",2); |
| 457 | 457 | } |
| 458 | + | |
| 459 | +/* | |
| 460 | +** Implements the "byfile" view for /reports. | |
| 461 | +*/ | |
| 462 | +static void stats_report_by_file(){ | |
| 463 | + Stmt query; | |
| 464 | + int mxEvent = 1; /* max number of events across all rows */ | |
| 465 | + int nRowNumber = 0; | |
| 466 | + | |
| 467 | + db_multi_exec( | |
| 468 | + "CREATE TEMP TABLE statrep(filename, cnt);" | |
| 469 | + "INSERT INTO statrep(filename, cnt)" | |
| 470 | + " SELECT filename.name, count(distinct mlink.mid)" | |
| 471 | + " FROM filename, mlink" | |
| 472 | + " WHERE filename.fnid=mlink.fnid" | |
| 473 | + " GROUP BY 1" | |
| 474 | + ); | |
| 475 | + db_prepare(&query, | |
| 476 | + "SELECT filename, cnt FROM statrep ORDER BY cnt DESC /*sort*/" | |
| 477 | + ); | |
| 478 | + mxEvent = db_int(1, "SELECT max(cnt) FROM statrep"); | |
| 479 | + @ <h1>Checkins Per File</h1> | |
| 480 | + @ <table class='statistics-report-table-events' border='0' | |
| 481 | + @ cellpadding='2' cellspacing='0' id='statsTable'> | |
| 482 | + @ <thead><tr> | |
| 483 | + @ <th>File</th> | |
| 484 | + @ <th>Checkins</th> | |
| 485 | + @ <th width='90%%'><!-- relative commits graph --></th> | |
| 486 | + @ </tr></thead><tbody> | |
| 487 | + while( SQLITE_ROW == db_step(&query) ){ | |
| 488 | + const char *zFile = db_column_text(&query, 0); | |
| 489 | + const int n = db_column_int(&query, 1); | |
| 490 | + int sz; | |
| 491 | + if( n<=0 ) continue; | |
| 492 | + sz = (int)(100*n/mxEvent); | |
| 493 | + if( sz==0 ) sz = 1; | |
| 494 | + @<tr class='row%d(++nRowNumber%2)'> | |
| 495 | + @ <td>@ %z(href("%R/finfo?name=%T",zFile))%h(zFile)</a></td> | |
| 496 | + @ <td>%d(n)</td> | |
| 497 | + @ <td> | |
| 498 | + @ <div class='statistics-report-graph-line' | |
| 499 | + @ style='width:%d(sz)%%;'> </div> | |
| 500 | + @ </td> | |
| 501 | + @</tr> | |
| 502 | + } | |
| 503 | + @ </tbody></table> | |
| 504 | + db_finalize(&query); | |
| 505 | + output_table_sorting_javascript("statsTable","tNx",2); | |
| 506 | +} | |
| 458 | 507 | |
| 459 | 508 | /* |
| 460 | 509 | ** Implements the "byweekday" view for /reports. |
| 461 | 510 | */ |
| 462 | 511 | static void stats_report_day_of_week(){ |
| @@ -691,10 +740,11 @@ | ||
| 691 | 740 | statrep_submenu(&url, "By Year", "view", "byyear", 0); |
| 692 | 741 | statrep_submenu(&url, "By Month", "view", "bymonth", 0); |
| 693 | 742 | statrep_submenu(&url, "By Week", "view", "byweek", 0); |
| 694 | 743 | statrep_submenu(&url, "By Weekday", "view", "byweekday", 0); |
| 695 | 744 | statrep_submenu(&url, "By User", "view", "byuser", "user"); |
| 745 | + statrep_submenu(&url, "By File", "view", "byfile", "file"); | |
| 696 | 746 | url_reset(&url); |
| 697 | 747 | style_header("Activity Reports"); |
| 698 | 748 | if(0==fossil_strcmp(zView,"byyear")){ |
| 699 | 749 | stats_report_by_month_year(0, 0, zUserName); |
| 700 | 750 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| @@ -703,18 +753,21 @@ | ||
| 703 | 753 | stats_report_year_weeks(zUserName); |
| 704 | 754 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 705 | 755 | stats_report_by_user(); |
| 706 | 756 | }else if(0==fossil_strcmp(zView,"byweekday")){ |
| 707 | 757 | stats_report_day_of_week(); |
| 758 | + }else if(0==fossil_strcmp(zView,"byfile")){ | |
| 759 | + stats_report_by_file(); | |
| 708 | 760 | }else{ |
| 709 | 761 | @ <h1>Select a report to show:</h1> |
| 710 | 762 | @ <ul> |
| 711 | 763 | @ <li><a href='?view=byyear'>Events by year</a></li> |
| 712 | 764 | @ <li><a href='?view=bymonth'>Events by month</a></li> |
| 713 | 765 | @ <li><a href='?view=byweek'>Events by calendar week</a></li> |
| 714 | 766 | @ <li><a href='?view=byweekday'>Events by day of the week</a></li> |
| 715 | 767 | @ <li><a href='?view=byuser'>Events by user</a></li> |
| 768 | + @ <li><a href='?view=byfile'>Events by file</a></li> | |
| 716 | 769 | @ </ul> |
| 717 | 770 | } |
| 718 | 771 | |
| 719 | 772 | style_footer(); |
| 720 | 773 | } |
| 721 | 774 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -453,10 +453,59 @@ | |
| 453 | } |
| 454 | @ </tbody></table> |
| 455 | db_finalize(&query); |
| 456 | output_table_sorting_javascript("statsTable","tkx",2); |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | ** Implements the "byweekday" view for /reports. |
| 461 | */ |
| 462 | static void stats_report_day_of_week(){ |
| @@ -691,10 +740,11 @@ | |
| 691 | statrep_submenu(&url, "By Year", "view", "byyear", 0); |
| 692 | statrep_submenu(&url, "By Month", "view", "bymonth", 0); |
| 693 | statrep_submenu(&url, "By Week", "view", "byweek", 0); |
| 694 | statrep_submenu(&url, "By Weekday", "view", "byweekday", 0); |
| 695 | statrep_submenu(&url, "By User", "view", "byuser", "user"); |
| 696 | url_reset(&url); |
| 697 | style_header("Activity Reports"); |
| 698 | if(0==fossil_strcmp(zView,"byyear")){ |
| 699 | stats_report_by_month_year(0, 0, zUserName); |
| 700 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| @@ -703,18 +753,21 @@ | |
| 703 | stats_report_year_weeks(zUserName); |
| 704 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 705 | stats_report_by_user(); |
| 706 | }else if(0==fossil_strcmp(zView,"byweekday")){ |
| 707 | stats_report_day_of_week(); |
| 708 | }else{ |
| 709 | @ <h1>Select a report to show:</h1> |
| 710 | @ <ul> |
| 711 | @ <li><a href='?view=byyear'>Events by year</a></li> |
| 712 | @ <li><a href='?view=bymonth'>Events by month</a></li> |
| 713 | @ <li><a href='?view=byweek'>Events by calendar week</a></li> |
| 714 | @ <li><a href='?view=byweekday'>Events by day of the week</a></li> |
| 715 | @ <li><a href='?view=byuser'>Events by user</a></li> |
| 716 | @ </ul> |
| 717 | } |
| 718 | |
| 719 | style_footer(); |
| 720 | } |
| 721 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -453,10 +453,59 @@ | |
| 453 | } |
| 454 | @ </tbody></table> |
| 455 | db_finalize(&query); |
| 456 | output_table_sorting_javascript("statsTable","tkx",2); |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | ** Implements the "byfile" view for /reports. |
| 461 | */ |
| 462 | static void stats_report_by_file(){ |
| 463 | Stmt query; |
| 464 | int mxEvent = 1; /* max number of events across all rows */ |
| 465 | int nRowNumber = 0; |
| 466 | |
| 467 | db_multi_exec( |
| 468 | "CREATE TEMP TABLE statrep(filename, cnt);" |
| 469 | "INSERT INTO statrep(filename, cnt)" |
| 470 | " SELECT filename.name, count(distinct mlink.mid)" |
| 471 | " FROM filename, mlink" |
| 472 | " WHERE filename.fnid=mlink.fnid" |
| 473 | " GROUP BY 1" |
| 474 | ); |
| 475 | db_prepare(&query, |
| 476 | "SELECT filename, cnt FROM statrep ORDER BY cnt DESC /*sort*/" |
| 477 | ); |
| 478 | mxEvent = db_int(1, "SELECT max(cnt) FROM statrep"); |
| 479 | @ <h1>Checkins Per File</h1> |
| 480 | @ <table class='statistics-report-table-events' border='0' |
| 481 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 482 | @ <thead><tr> |
| 483 | @ <th>File</th> |
| 484 | @ <th>Checkins</th> |
| 485 | @ <th width='90%%'><!-- relative commits graph --></th> |
| 486 | @ </tr></thead><tbody> |
| 487 | while( SQLITE_ROW == db_step(&query) ){ |
| 488 | const char *zFile = db_column_text(&query, 0); |
| 489 | const int n = db_column_int(&query, 1); |
| 490 | int sz; |
| 491 | if( n<=0 ) continue; |
| 492 | sz = (int)(100*n/mxEvent); |
| 493 | if( sz==0 ) sz = 1; |
| 494 | @<tr class='row%d(++nRowNumber%2)'> |
| 495 | @ <td>@ %z(href("%R/finfo?name=%T",zFile))%h(zFile)</a></td> |
| 496 | @ <td>%d(n)</td> |
| 497 | @ <td> |
| 498 | @ <div class='statistics-report-graph-line' |
| 499 | @ style='width:%d(sz)%%;'> </div> |
| 500 | @ </td> |
| 501 | @</tr> |
| 502 | } |
| 503 | @ </tbody></table> |
| 504 | db_finalize(&query); |
| 505 | output_table_sorting_javascript("statsTable","tNx",2); |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | ** Implements the "byweekday" view for /reports. |
| 510 | */ |
| 511 | static void stats_report_day_of_week(){ |
| @@ -691,10 +740,11 @@ | |
| 740 | statrep_submenu(&url, "By Year", "view", "byyear", 0); |
| 741 | statrep_submenu(&url, "By Month", "view", "bymonth", 0); |
| 742 | statrep_submenu(&url, "By Week", "view", "byweek", 0); |
| 743 | statrep_submenu(&url, "By Weekday", "view", "byweekday", 0); |
| 744 | statrep_submenu(&url, "By User", "view", "byuser", "user"); |
| 745 | statrep_submenu(&url, "By File", "view", "byfile", "file"); |
| 746 | url_reset(&url); |
| 747 | style_header("Activity Reports"); |
| 748 | if(0==fossil_strcmp(zView,"byyear")){ |
| 749 | stats_report_by_month_year(0, 0, zUserName); |
| 750 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| @@ -703,18 +753,21 @@ | |
| 753 | stats_report_year_weeks(zUserName); |
| 754 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 755 | stats_report_by_user(); |
| 756 | }else if(0==fossil_strcmp(zView,"byweekday")){ |
| 757 | stats_report_day_of_week(); |
| 758 | }else if(0==fossil_strcmp(zView,"byfile")){ |
| 759 | stats_report_by_file(); |
| 760 | }else{ |
| 761 | @ <h1>Select a report to show:</h1> |
| 762 | @ <ul> |
| 763 | @ <li><a href='?view=byyear'>Events by year</a></li> |
| 764 | @ <li><a href='?view=bymonth'>Events by month</a></li> |
| 765 | @ <li><a href='?view=byweek'>Events by calendar week</a></li> |
| 766 | @ <li><a href='?view=byweekday'>Events by day of the week</a></li> |
| 767 | @ <li><a href='?view=byuser'>Events by user</a></li> |
| 768 | @ <li><a href='?view=byfile'>Events by file</a></li> |
| 769 | @ </ul> |
| 770 | } |
| 771 | |
| 772 | style_footer(); |
| 773 | } |
| 774 |