Fossil SCM

Minor fix and cleanup to the byweek variant of /report.

drh 2026-07-01 13:37 UTC trunk
Commit c00b72f463f8a40311a224e04c5d61d7e5c49e26dedfbd7a6f517bc3c1df9e16
1 file changed +15 -16
+15 -16
--- src/statrep.c
+++ src/statrep.c
@@ -671,24 +671,23 @@
671671
**
672672
** If zUserName is not NULL then the report is restricted to events
673673
** created by the named user account.
674674
*/
675675
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 */
690689
691690
stats_report_init_view();
692691
style_submenu_sql("y", "Year:",
693692
"WITH RECURSIVE a(b) AS ("
694693
" SELECT substr(date('now'),1,4) UNION ALL"
@@ -711,16 +710,16 @@
711710
db_prepare(&q,
712711
"WITH RECURSIVE c(wkn) AS (\n"
713712
" VALUES(if(:WeekZero<:WeekOne,0,1))\n"
714713
" UNION ALL\n"
715714
" SELECT wkn+1 FROM c\n"
716
- " WHERE (:YearStart+wkn*7+7)<=:AllEnd\n"
715
+ " WHERE (:YearStart+wkn*7)<=:AllEnd\n"
717716
")\n"
718717
"INSERT INTO wkdata(wk,n)\n"
719718
" SELECT c.wkn, coalesce(x.n,0)\n"
720719
" 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"
722721
" count(*) AS n\n"
723722
" FROM v_reports\n"
724723
" WHERE mtime BETWEEN :WeekZero AND :AllEnd\n"
725724
" AND ifnull(coalesce(euser,user,'')=%Q,1)\n"
726725
" GROUP BY w\n"
727726
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button