Fossil SCM
Also show the projection number of events for the by-week activity report.
Commit
09ca77f76a48353a31bca56475c8b21daa3d400ad61fda92cb1e6d9ccff61998
Parent
42ce541d1208d4c…
1 file changed
+38
-7
+38
-7
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -639,10 +639,13 @@ | ||
| 639 | 639 | int nMaxEvents = 1; /* max number of events for |
| 640 | 640 | all rows. */ |
| 641 | 641 | int iterations = 0; /* # of active time periods. */ |
| 642 | 642 | int rowCount = 0; |
| 643 | 643 | int total = 0; |
| 644 | + char *zCurrentWeek; /* Current week number */ | |
| 645 | + double rNowFraction = 0.0; /* Fraction of current week that has | |
| 646 | + ** passed */ | |
| 644 | 647 | |
| 645 | 648 | stats_report_init_view(); |
| 646 | 649 | style_submenu_sql("y", "Year:", |
| 647 | 650 | "WITH RECURSIVE a(b) AS (" |
| 648 | 651 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -665,11 +668,18 @@ | ||
| 665 | 668 | @ for the calendar weeks of %h(zYear) |
| 666 | 669 | if( zUserName ){ |
| 667 | 670 | @ for user %h(zUserName) |
| 668 | 671 | } |
| 669 | 672 | @ </h1> |
| 670 | - style_table_sorter(); | |
| 673 | + zCurrentWeek = db_text(0, | |
| 674 | + "SELECT strftime('%%W','now') WHERE date() LIKE '%q%%'", | |
| 675 | + zYear); | |
| 676 | + if( zCurrentWeek ){ | |
| 677 | + rNowFraction = db_double(0.5, | |
| 678 | + "SELECT (unixepoch()-unixepoch('now','weekday 0','-7 days'))/604800.0;"); | |
| 679 | + } | |
| 680 | + style_table_sorter(); | |
| 671 | 681 | cgi_printf("<table class='statistics-report-table-events sortable' " |
| 672 | 682 | "border='0' cellpadding='2' width='100%%' " |
| 673 | 683 | "cellspacing='0' data-column-types='tnx' data-init-sort='0'>\n"); |
| 674 | 684 | cgi_printf("<thead><tr>" |
| 675 | 685 | "<th>Week</th>" |
| @@ -676,21 +686,27 @@ | ||
| 676 | 686 | "<th>Events</th>" |
| 677 | 687 | "<th width='90%%'><!-- relative commits graph --></th>" |
| 678 | 688 | "</tr></thead>\n" |
| 679 | 689 | "<tbody>\n"); |
| 680 | 690 | while( SQLITE_ROW == db_step(&q) ){ |
| 681 | - const int nCount = db_column_int(&q, 1); | |
| 691 | + int nCount = db_column_int(&q, 1); | |
| 692 | + if( zCurrentWeek!=0 | |
| 693 | + && strcmp(db_column_text(&q,0),zCurrentWeek)==0 | |
| 694 | + && rNowFraction>0.05 | |
| 695 | + ){ | |
| 696 | + nCount = (int)(((double)nCount)/rNowFraction); | |
| 697 | + } | |
| 682 | 698 | if(nCount>nMaxEvents){ |
| 683 | 699 | nMaxEvents = nCount; |
| 684 | 700 | } |
| 685 | 701 | ++iterations; |
| 686 | 702 | } |
| 687 | 703 | db_reset(&q); |
| 688 | 704 | while( SQLITE_ROW == db_step(&q) ){ |
| 689 | 705 | const char *zWeek = db_column_text(&q,0); |
| 690 | 706 | const int nCount = db_column_int(&q,1); |
| 691 | - int nSize = nCount | |
| 707 | + int nSize = (nCount>0 && nMaxEvents>0) | |
| 692 | 708 | ? (int)(100 * nCount / nMaxEvents) |
| 693 | 709 | : 0; |
| 694 | 710 | if(!nSize) nSize = 1; |
| 695 | 711 | total += nCount; |
| 696 | 712 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| @@ -702,14 +718,29 @@ | ||
| 702 | 718 | } |
| 703 | 719 | cgi_printf("'>%s</a></td>",zWeek); |
| 704 | 720 | |
| 705 | 721 | cgi_printf("<td>%d</td>",nCount); |
| 706 | 722 | cgi_printf("<td>"); |
| 707 | - if(nCount){ | |
| 708 | - cgi_printf("<div class='statistics-report-graph-line'" | |
| 709 | - "style='width:%d%%;'> </div>", | |
| 710 | - nSize); | |
| 723 | + if( nCount ){ | |
| 724 | + if( zCurrentWeek!=0 | |
| 725 | + && strcmp(zWeek, zCurrentWeek)==0 | |
| 726 | + && rNowFraction>0.05 | |
| 727 | + && nMaxEvents>0 | |
| 728 | + ){ | |
| 729 | + /* If the covered covered by this row contains "now", then project | |
| 730 | + ** the number of changes until the completion of the week and | |
| 731 | + ** show a dashed box of that projection. */ | |
| 732 | + int nExtra = (int)(((double)nCount)/rNowFraction) - nCount; | |
| 733 | + int nXSize = (100 * nExtra)/nMaxEvents; | |
| 734 | + @ <span class='statistics-report-graph-line' \ | |
| 735 | + @ style='display:inline-block;min-width:%d(nSize)%%;'> </span>\ | |
| 736 | + @ <span class='statistics-report-graph-extra' \ | |
| 737 | + @ style='display:inline-block;min-width:%d(nXSize)%%;'> </span>\ | |
| 738 | + }else{ | |
| 739 | + @ <div class='statistics-report-graph-line' \ | |
| 740 | + @ style='width:%d(nSize)%%;'> </div> \ | |
| 741 | + } | |
| 711 | 742 | } |
| 712 | 743 | cgi_printf("</td></tr>\n"); |
| 713 | 744 | } |
| 714 | 745 | db_finalize(&q); |
| 715 | 746 | cgi_printf("</tbody></table>"); |
| 716 | 747 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -639,10 +639,13 @@ | |
| 639 | int nMaxEvents = 1; /* max number of events for |
| 640 | all rows. */ |
| 641 | int iterations = 0; /* # of active time periods. */ |
| 642 | int rowCount = 0; |
| 643 | int total = 0; |
| 644 | |
| 645 | stats_report_init_view(); |
| 646 | style_submenu_sql("y", "Year:", |
| 647 | "WITH RECURSIVE a(b) AS (" |
| 648 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -665,11 +668,18 @@ | |
| 665 | @ for the calendar weeks of %h(zYear) |
| 666 | if( zUserName ){ |
| 667 | @ for user %h(zUserName) |
| 668 | } |
| 669 | @ </h1> |
| 670 | style_table_sorter(); |
| 671 | cgi_printf("<table class='statistics-report-table-events sortable' " |
| 672 | "border='0' cellpadding='2' width='100%%' " |
| 673 | "cellspacing='0' data-column-types='tnx' data-init-sort='0'>\n"); |
| 674 | cgi_printf("<thead><tr>" |
| 675 | "<th>Week</th>" |
| @@ -676,21 +686,27 @@ | |
| 676 | "<th>Events</th>" |
| 677 | "<th width='90%%'><!-- relative commits graph --></th>" |
| 678 | "</tr></thead>\n" |
| 679 | "<tbody>\n"); |
| 680 | while( SQLITE_ROW == db_step(&q) ){ |
| 681 | const int nCount = db_column_int(&q, 1); |
| 682 | if(nCount>nMaxEvents){ |
| 683 | nMaxEvents = nCount; |
| 684 | } |
| 685 | ++iterations; |
| 686 | } |
| 687 | db_reset(&q); |
| 688 | while( SQLITE_ROW == db_step(&q) ){ |
| 689 | const char *zWeek = db_column_text(&q,0); |
| 690 | const int nCount = db_column_int(&q,1); |
| 691 | int nSize = nCount |
| 692 | ? (int)(100 * nCount / nMaxEvents) |
| 693 | : 0; |
| 694 | if(!nSize) nSize = 1; |
| 695 | total += nCount; |
| 696 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| @@ -702,14 +718,29 @@ | |
| 702 | } |
| 703 | cgi_printf("'>%s</a></td>",zWeek); |
| 704 | |
| 705 | cgi_printf("<td>%d</td>",nCount); |
| 706 | cgi_printf("<td>"); |
| 707 | if(nCount){ |
| 708 | cgi_printf("<div class='statistics-report-graph-line'" |
| 709 | "style='width:%d%%;'> </div>", |
| 710 | nSize); |
| 711 | } |
| 712 | cgi_printf("</td></tr>\n"); |
| 713 | } |
| 714 | db_finalize(&q); |
| 715 | cgi_printf("</tbody></table>"); |
| 716 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -639,10 +639,13 @@ | |
| 639 | int nMaxEvents = 1; /* max number of events for |
| 640 | all rows. */ |
| 641 | int iterations = 0; /* # of active time periods. */ |
| 642 | int rowCount = 0; |
| 643 | int total = 0; |
| 644 | char *zCurrentWeek; /* Current week number */ |
| 645 | double rNowFraction = 0.0; /* Fraction of current week that has |
| 646 | ** passed */ |
| 647 | |
| 648 | stats_report_init_view(); |
| 649 | style_submenu_sql("y", "Year:", |
| 650 | "WITH RECURSIVE a(b) AS (" |
| 651 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -665,11 +668,18 @@ | |
| 668 | @ for the calendar weeks of %h(zYear) |
| 669 | if( zUserName ){ |
| 670 | @ for user %h(zUserName) |
| 671 | } |
| 672 | @ </h1> |
| 673 | zCurrentWeek = db_text(0, |
| 674 | "SELECT strftime('%%W','now') WHERE date() LIKE '%q%%'", |
| 675 | zYear); |
| 676 | if( zCurrentWeek ){ |
| 677 | rNowFraction = db_double(0.5, |
| 678 | "SELECT (unixepoch()-unixepoch('now','weekday 0','-7 days'))/604800.0;"); |
| 679 | } |
| 680 | style_table_sorter(); |
| 681 | cgi_printf("<table class='statistics-report-table-events sortable' " |
| 682 | "border='0' cellpadding='2' width='100%%' " |
| 683 | "cellspacing='0' data-column-types='tnx' data-init-sort='0'>\n"); |
| 684 | cgi_printf("<thead><tr>" |
| 685 | "<th>Week</th>" |
| @@ -676,21 +686,27 @@ | |
| 686 | "<th>Events</th>" |
| 687 | "<th width='90%%'><!-- relative commits graph --></th>" |
| 688 | "</tr></thead>\n" |
| 689 | "<tbody>\n"); |
| 690 | while( SQLITE_ROW == db_step(&q) ){ |
| 691 | int nCount = db_column_int(&q, 1); |
| 692 | if( zCurrentWeek!=0 |
| 693 | && strcmp(db_column_text(&q,0),zCurrentWeek)==0 |
| 694 | && rNowFraction>0.05 |
| 695 | ){ |
| 696 | nCount = (int)(((double)nCount)/rNowFraction); |
| 697 | } |
| 698 | if(nCount>nMaxEvents){ |
| 699 | nMaxEvents = nCount; |
| 700 | } |
| 701 | ++iterations; |
| 702 | } |
| 703 | db_reset(&q); |
| 704 | while( SQLITE_ROW == db_step(&q) ){ |
| 705 | const char *zWeek = db_column_text(&q,0); |
| 706 | const int nCount = db_column_int(&q,1); |
| 707 | int nSize = (nCount>0 && nMaxEvents>0) |
| 708 | ? (int)(100 * nCount / nMaxEvents) |
| 709 | : 0; |
| 710 | if(!nSize) nSize = 1; |
| 711 | total += nCount; |
| 712 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| @@ -702,14 +718,29 @@ | |
| 718 | } |
| 719 | cgi_printf("'>%s</a></td>",zWeek); |
| 720 | |
| 721 | cgi_printf("<td>%d</td>",nCount); |
| 722 | cgi_printf("<td>"); |
| 723 | if( nCount ){ |
| 724 | if( zCurrentWeek!=0 |
| 725 | && strcmp(zWeek, zCurrentWeek)==0 |
| 726 | && rNowFraction>0.05 |
| 727 | && nMaxEvents>0 |
| 728 | ){ |
| 729 | /* If the covered covered by this row contains "now", then project |
| 730 | ** the number of changes until the completion of the week and |
| 731 | ** show a dashed box of that projection. */ |
| 732 | int nExtra = (int)(((double)nCount)/rNowFraction) - nCount; |
| 733 | int nXSize = (100 * nExtra)/nMaxEvents; |
| 734 | @ <span class='statistics-report-graph-line' \ |
| 735 | @ style='display:inline-block;min-width:%d(nSize)%%;'> </span>\ |
| 736 | @ <span class='statistics-report-graph-extra' \ |
| 737 | @ style='display:inline-block;min-width:%d(nXSize)%%;'> </span>\ |
| 738 | }else{ |
| 739 | @ <div class='statistics-report-graph-line' \ |
| 740 | @ style='width:%d(nSize)%%;'> </div> \ |
| 741 | } |
| 742 | } |
| 743 | cgi_printf("</td></tr>\n"); |
| 744 | } |
| 745 | db_finalize(&q); |
| 746 | cgi_printf("</tbody></table>"); |
| 747 |