Fossil SCM
Minor fix and cleanup to the byweek variant of /report.
Commit
c00b72f463f8a40311a224e04c5d61d7e5c49e26dedfbd7a6f517bc3c1df9e16
Parent
a5a08c343941168…
1 file changed
+15
-16
+15
-16
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -671,24 +671,23 @@ | ||
| 671 | 671 | ** |
| 672 | 672 | ** If zUserName is not NULL then the report is restricted to events |
| 673 | 673 | ** created by the named user account. |
| 674 | 674 | */ |
| 675 | 675 | static void stats_report_byweek(const char *zUserName){ |
| 676 | - const char *zYear = P("y"); /* Year for which report shown */ | |
| 677 | - int bShowAll = PB("sa"); /* Show all weeks if true, active if false */ | |
| 678 | - Stmt q; | |
| 679 | - int nMaxEvents = 1; /* max number of events for all rows. */ | |
| 680 | - int rowCount = 0; | |
| 681 | - int total; | |
| 682 | - int iCurrentWeek; /* Current week number */ | |
| 683 | - double rNowFraction = 0.0; /* Fraction of current week that has | |
| 684 | - ** passed */ | |
| 685 | - double rYearStart; /* Start of year */ | |
| 686 | - double rYearEnd; /* End of the year */ | |
| 687 | - double rWeekOne; /* Start of first Monday of the year */ | |
| 688 | - double rWeekZero; /* If Jan01 is Mon, then rWeekOne, else rWeekOne-7.0 */ | |
| 689 | - double rAllEnd; /* End of last week of year, overflow into next year */ | |
| 676 | + const char *zYear = P("y"); /* Year for which report shown */ | |
| 677 | + int bShowAll = PB("sa"); /* Show all weeks if true, active if false */ | |
| 678 | + Stmt q; /* Query */ | |
| 679 | + int nMaxEvents = 1; /* max number of events in any row */ | |
| 680 | + int rowCount = 0; /* Rows of output generated */ | |
| 681 | + int total; /* Total number of events */ | |
| 682 | + int iCurrentWeek; /* Current week number */ | |
| 683 | + double rNowFraction = 0.0; /* Fraction of current week that has passed */ | |
| 684 | + double rYearStart; /* Start of year */ | |
| 685 | + double rYearEnd; /* End of the year */ | |
| 686 | + double rWeekOne; /* Start of first Monday of the year */ | |
| 687 | + double rWeekZero; /* If Jan01 is Mon, then rWeekOne, else rWeekOne-7.0 */ | |
| 688 | + double rAllEnd; /* End of last week of year, overflow into next year */ | |
| 690 | 689 | |
| 691 | 690 | stats_report_init_view(); |
| 692 | 691 | style_submenu_sql("y", "Year:", |
| 693 | 692 | "WITH RECURSIVE a(b) AS (" |
| 694 | 693 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -711,16 +710,16 @@ | ||
| 711 | 710 | db_prepare(&q, |
| 712 | 711 | "WITH RECURSIVE c(wkn) AS (\n" |
| 713 | 712 | " VALUES(if(:WeekZero<:WeekOne,0,1))\n" |
| 714 | 713 | " UNION ALL\n" |
| 715 | 714 | " SELECT wkn+1 FROM c\n" |
| 716 | - " WHERE (:YearStart+wkn*7+7)<=:AllEnd\n" | |
| 715 | + " WHERE (:YearStart+wkn*7)<=:AllEnd\n" | |
| 717 | 716 | ")\n" |
| 718 | 717 | "INSERT INTO wkdata(wk,n)\n" |
| 719 | 718 | " SELECT c.wkn, coalesce(x.n,0)\n" |
| 720 | 719 | " FROM c LEFT JOIN (\n" |
| 721 | - " SELECT 0+strftime('%%W',min(max(:YearStart,mtime),:YearEnd)) AS w,\n" | |
| 720 | + " SELECT 0+strftime('%%W',min(max(mtime,:YearStart),:YearEnd)) AS w,\n" | |
| 722 | 721 | " count(*) AS n\n" |
| 723 | 722 | " FROM v_reports\n" |
| 724 | 723 | " WHERE mtime BETWEEN :WeekZero AND :AllEnd\n" |
| 725 | 724 | " AND ifnull(coalesce(euser,user,'')=%Q,1)\n" |
| 726 | 725 | " GROUP BY w\n" |
| 727 | 726 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -671,24 +671,23 @@ | |
| 671 | ** |
| 672 | ** If zUserName is not NULL then the report is restricted to events |
| 673 | ** created by the named user account. |
| 674 | */ |
| 675 | static void stats_report_byweek(const char *zUserName){ |
| 676 | const char *zYear = P("y"); /* Year for which report shown */ |
| 677 | int bShowAll = PB("sa"); /* Show all weeks if true, active if false */ |
| 678 | Stmt q; |
| 679 | int nMaxEvents = 1; /* max number of events for all rows. */ |
| 680 | int rowCount = 0; |
| 681 | int total; |
| 682 | int iCurrentWeek; /* Current week number */ |
| 683 | double rNowFraction = 0.0; /* Fraction of current week that has |
| 684 | ** passed */ |
| 685 | double rYearStart; /* Start of year */ |
| 686 | double rYearEnd; /* End of the year */ |
| 687 | double rWeekOne; /* Start of first Monday of the year */ |
| 688 | double rWeekZero; /* If Jan01 is Mon, then rWeekOne, else rWeekOne-7.0 */ |
| 689 | double rAllEnd; /* End of last week of year, overflow into next year */ |
| 690 | |
| 691 | stats_report_init_view(); |
| 692 | style_submenu_sql("y", "Year:", |
| 693 | "WITH RECURSIVE a(b) AS (" |
| 694 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -711,16 +710,16 @@ | |
| 711 | db_prepare(&q, |
| 712 | "WITH RECURSIVE c(wkn) AS (\n" |
| 713 | " VALUES(if(:WeekZero<:WeekOne,0,1))\n" |
| 714 | " UNION ALL\n" |
| 715 | " SELECT wkn+1 FROM c\n" |
| 716 | " WHERE (:YearStart+wkn*7+7)<=:AllEnd\n" |
| 717 | ")\n" |
| 718 | "INSERT INTO wkdata(wk,n)\n" |
| 719 | " SELECT c.wkn, coalesce(x.n,0)\n" |
| 720 | " FROM c LEFT JOIN (\n" |
| 721 | " SELECT 0+strftime('%%W',min(max(:YearStart,mtime),:YearEnd)) AS w,\n" |
| 722 | " count(*) AS n\n" |
| 723 | " FROM v_reports\n" |
| 724 | " WHERE mtime BETWEEN :WeekZero AND :AllEnd\n" |
| 725 | " AND ifnull(coalesce(euser,user,'')=%Q,1)\n" |
| 726 | " GROUP BY w\n" |
| 727 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -671,24 +671,23 @@ | |
| 671 | ** |
| 672 | ** If zUserName is not NULL then the report is restricted to events |
| 673 | ** created by the named user account. |
| 674 | */ |
| 675 | static void stats_report_byweek(const char *zUserName){ |
| 676 | const char *zYear = P("y"); /* Year for which report shown */ |
| 677 | int bShowAll = PB("sa"); /* Show all weeks if true, active if false */ |
| 678 | Stmt q; /* Query */ |
| 679 | int nMaxEvents = 1; /* max number of events in any row */ |
| 680 | int rowCount = 0; /* Rows of output generated */ |
| 681 | int total; /* Total number of events */ |
| 682 | int iCurrentWeek; /* Current week number */ |
| 683 | double rNowFraction = 0.0; /* Fraction of current week that has passed */ |
| 684 | double rYearStart; /* Start of year */ |
| 685 | double rYearEnd; /* End of the year */ |
| 686 | double rWeekOne; /* Start of first Monday of the year */ |
| 687 | double rWeekZero; /* If Jan01 is Mon, then rWeekOne, else rWeekOne-7.0 */ |
| 688 | double rAllEnd; /* End of last week of year, overflow into next year */ |
| 689 | |
| 690 | stats_report_init_view(); |
| 691 | style_submenu_sql("y", "Year:", |
| 692 | "WITH RECURSIVE a(b) AS (" |
| 693 | " SELECT substr(date('now'),1,4) UNION ALL" |
| @@ -711,16 +710,16 @@ | |
| 710 | db_prepare(&q, |
| 711 | "WITH RECURSIVE c(wkn) AS (\n" |
| 712 | " VALUES(if(:WeekZero<:WeekOne,0,1))\n" |
| 713 | " UNION ALL\n" |
| 714 | " SELECT wkn+1 FROM c\n" |
| 715 | " WHERE (:YearStart+wkn*7)<=:AllEnd\n" |
| 716 | ")\n" |
| 717 | "INSERT INTO wkdata(wk,n)\n" |
| 718 | " SELECT c.wkn, coalesce(x.n,0)\n" |
| 719 | " FROM c LEFT JOIN (\n" |
| 720 | " SELECT 0+strftime('%%W',min(max(mtime,:YearStart),:YearEnd)) AS w,\n" |
| 721 | " count(*) AS n\n" |
| 722 | " FROM v_reports\n" |
| 723 | " WHERE mtime BETWEEN :WeekZero AND :AllEnd\n" |
| 724 | " AND ifnull(coalesce(euser,user,'')=%Q,1)\n" |
| 725 | " GROUP BY w\n" |
| 726 |