Fossil SCM
Improved handling of the the yw= query parameter on /timeline.
Commit
881b4646171e7767c4c2e03211a69f4788b0a03e0d6c1eed184dc6b056c47e1e
Parent
de76c92a63e9e00…
1 file changed
+19
-1
+19
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1412,10 +1412,11 @@ | ||
| 1412 | 1412 | const char *zTagSql = 0; /* Tag/branch match SQL expression */ |
| 1413 | 1413 | const char *zSearch = P("s"); /* Search string */ |
| 1414 | 1414 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1415 | 1415 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1416 | 1416 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1417 | + char *zYearWeekStart = 0; /* YYYY-MM-DD for start of YYYY-WW */ | |
| 1417 | 1418 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1418 | 1419 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1419 | 1420 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1420 | 1421 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| 1421 | 1422 | int forkOnly = PB("forks"); /* Show only forks and their children */ |
| @@ -1758,10 +1759,26 @@ | ||
| 1758 | 1759 | if( zYearMonth ){ |
| 1759 | 1760 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1760 | 1761 | zYearMonth); |
| 1761 | 1762 | } |
| 1762 | 1763 | else if( zYearWeek ){ |
| 1764 | + char *z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek); | |
| 1765 | + if( z && z[0] ){ | |
| 1766 | + zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')", | |
| 1767 | + zYearWeek); | |
| 1768 | + zYearWeek = z; | |
| 1769 | + }else{ | |
| 1770 | + zYearWeekStart = db_text(0, | |
| 1771 | + "SELECT date('%.4q-01-01','+%q weeks','weekday 1')", | |
| 1772 | + zYearWeek, zYearWeek+5); | |
| 1773 | + if( zYearWeekStart==0 || zYearWeekStart[0]==0 ){ | |
| 1774 | + zYearWeekStart = db_text(0, | |
| 1775 | + "SELECT date('now','-6 days','weekday 1');"); | |
| 1776 | + zYearWeek = db_text(0, | |
| 1777 | + "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')"); | |
| 1778 | + } | |
| 1779 | + } | |
| 1763 | 1780 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ", |
| 1764 | 1781 | zYearWeek); |
| 1765 | 1782 | } |
| 1766 | 1783 | else if( zDay ){ |
| 1767 | 1784 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m-%%d',event.mtime) ", |
| @@ -1914,11 +1931,12 @@ | ||
| 1914 | 1931 | |
| 1915 | 1932 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1916 | 1933 | if( zYearMonth ){ |
| 1917 | 1934 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1918 | 1935 | }else if( zYearWeek ){ |
| 1919 | - blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); | |
| 1936 | + blob_appendf(&desc, "%s events for year/week %h (%h)", | |
| 1937 | + zEType, zYearWeek, zYearWeekStart); | |
| 1920 | 1938 | }else if( zDay ){ |
| 1921 | 1939 | blob_appendf(&desc, "%s events occurring on %h", zEType, zDay); |
| 1922 | 1940 | }else if( zBefore==0 && zCirca==0 && n>=nEntry && nEntry>0 ){ |
| 1923 | 1941 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1924 | 1942 | }else{ |
| 1925 | 1943 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1412,10 +1412,11 @@ | |
| 1412 | const char *zTagSql = 0; /* Tag/branch match SQL expression */ |
| 1413 | const char *zSearch = P("s"); /* Search string */ |
| 1414 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1415 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1416 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1417 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1418 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1419 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1420 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| 1421 | int forkOnly = PB("forks"); /* Show only forks and their children */ |
| @@ -1758,10 +1759,26 @@ | |
| 1758 | if( zYearMonth ){ |
| 1759 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1760 | zYearMonth); |
| 1761 | } |
| 1762 | else if( zYearWeek ){ |
| 1763 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ", |
| 1764 | zYearWeek); |
| 1765 | } |
| 1766 | else if( zDay ){ |
| 1767 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m-%%d',event.mtime) ", |
| @@ -1914,11 +1931,12 @@ | |
| 1914 | |
| 1915 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1916 | if( zYearMonth ){ |
| 1917 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1918 | }else if( zYearWeek ){ |
| 1919 | blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); |
| 1920 | }else if( zDay ){ |
| 1921 | blob_appendf(&desc, "%s events occurring on %h", zEType, zDay); |
| 1922 | }else if( zBefore==0 && zCirca==0 && n>=nEntry && nEntry>0 ){ |
| 1923 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1924 | }else{ |
| 1925 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1412,10 +1412,11 @@ | |
| 1412 | const char *zTagSql = 0; /* Tag/branch match SQL expression */ |
| 1413 | const char *zSearch = P("s"); /* Search string */ |
| 1414 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1415 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1416 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1417 | char *zYearWeekStart = 0; /* YYYY-MM-DD for start of YYYY-WW */ |
| 1418 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1419 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1420 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1421 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| 1422 | int forkOnly = PB("forks"); /* Show only forks and their children */ |
| @@ -1758,10 +1759,26 @@ | |
| 1759 | if( zYearMonth ){ |
| 1760 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1761 | zYearMonth); |
| 1762 | } |
| 1763 | else if( zYearWeek ){ |
| 1764 | char *z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek); |
| 1765 | if( z && z[0] ){ |
| 1766 | zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')", |
| 1767 | zYearWeek); |
| 1768 | zYearWeek = z; |
| 1769 | }else{ |
| 1770 | zYearWeekStart = db_text(0, |
| 1771 | "SELECT date('%.4q-01-01','+%q weeks','weekday 1')", |
| 1772 | zYearWeek, zYearWeek+5); |
| 1773 | if( zYearWeekStart==0 || zYearWeekStart[0]==0 ){ |
| 1774 | zYearWeekStart = db_text(0, |
| 1775 | "SELECT date('now','-6 days','weekday 1');"); |
| 1776 | zYearWeek = db_text(0, |
| 1777 | "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')"); |
| 1778 | } |
| 1779 | } |
| 1780 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ", |
| 1781 | zYearWeek); |
| 1782 | } |
| 1783 | else if( zDay ){ |
| 1784 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m-%%d',event.mtime) ", |
| @@ -1914,11 +1931,12 @@ | |
| 1931 | |
| 1932 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1933 | if( zYearMonth ){ |
| 1934 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1935 | }else if( zYearWeek ){ |
| 1936 | blob_appendf(&desc, "%s events for year/week %h (%h)", |
| 1937 | zEType, zYearWeek, zYearWeekStart); |
| 1938 | }else if( zDay ){ |
| 1939 | blob_appendf(&desc, "%s events occurring on %h", zEType, zDay); |
| 1940 | }else if( zBefore==0 && zCirca==0 && n>=nEntry && nEntry>0 ){ |
| 1941 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1942 | }else{ |
| 1943 |