Fossil SCM

Improved handling of the the yw= query parameter on /timeline.

drh 2018-04-26 19:02 trunk
Commit 881b4646171e7767c4c2e03211a69f4788b0a03e0d6c1eed184dc6b056c47e1e
1 file changed +19 -1
+19 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1412,10 +1412,11 @@
14121412
const char *zTagSql = 0; /* Tag/branch match SQL expression */
14131413
const char *zSearch = P("s"); /* Search string */
14141414
const char *zUses = P("uf"); /* Only show check-ins hold this file */
14151415
const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
14161416
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 */
14171418
const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */
14181419
const char *zChng = P("chng"); /* List of GLOBs for files that changed */
14191420
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
14201421
int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
14211422
int forkOnly = PB("forks"); /* Show only forks and their children */
@@ -1758,10 +1759,26 @@
17581759
if( zYearMonth ){
17591760
blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
17601761
zYearMonth);
17611762
}
17621763
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
+ }
17631780
blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ",
17641781
zYearWeek);
17651782
}
17661783
else if( zDay ){
17671784
blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m-%%d',event.mtime) ",
@@ -1914,11 +1931,12 @@
19141931
19151932
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
19161933
if( zYearMonth ){
19171934
blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
19181935
}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);
19201938
}else if( zDay ){
19211939
blob_appendf(&desc, "%s events occurring on %h", zEType, zDay);
19221940
}else if( zBefore==0 && zCirca==0 && n>=nEntry && nEntry>0 ){
19231941
blob_appendf(&desc, "%d most recent %ss", n, zEType);
19241942
}else{
19251943
--- 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

Keyboard Shortcuts

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