Fossil

Check-in [881b4646]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved handling of the the yw= query parameter on /timeline.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 881b4646171e7767c4c2e03211a69f4788b0a03e0d6c1eed184dc6b056c47e1e
User & Date: drh 2018-04-26 19:02:04
Context
2018-04-26
19:20
Further enhancements to the timeline label for the yw= query parameter. check-in: b89e7452 user: drh tags: trunk
19:02
Improved handling of the the yw= query parameter on /timeline. check-in: 881b4646 user: drh tags: trunk
2018-04-25
13:34
Update the built-in SQLite to the latest 3.24.0 alpha version. check-in: de76c92a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/timeline.c.

  1410   1410     const char *zMatchDesc = 0;        /* Tag match expression description text */
  1411   1411     const char *zError = 0;            /* Tag match error string */
  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 */
  1422   1423     int bisectOnly = PB("bisect");     /* Show the check-ins of the bisect */
  1423   1424     int tmFlags = 0;                   /* Timeline flags */
................................................................................
  1756   1757         blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
  1757   1758       }
  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) ",
  1768   1785                      zDay);
  1769   1786       }
................................................................................
  1912   1929       if( nEntry>0 ) blob_append_sql(&sql, " LIMIT %d", nEntry);
  1913   1930       db_multi_exec("%s", blob_sql_text(&sql));
  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         blob_appendf(&desc, "%d %ss", n, zEType);
  1926   1944       }