Fossil SCM
Added /timeline?yw=YYYY-WW (year/week-of-year). Added links to /stats_report. Disabled year/week links for the year/month view because the current approach is way too slow.
Commit
0019550a0300880e08ab311c9741746f42eb999b
Parent
c43c3a7fd272ab9…
2 files changed
+13
+21
-7
+13
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -1033,10 +1033,23 @@ | ||
| 1033 | 1033 | @ padding: 0.1em 1em 0.1em 1em; |
| 1034 | 1034 | }, |
| 1035 | 1035 | { ".statistics-report-row-year", |
| 1036 | 1036 | "", |
| 1037 | 1037 | @ text-align: left; |
| 1038 | + }, | |
| 1039 | + { ".statistics-report-graph-line", | |
| 1040 | + "for the /stats_report views", | |
| 1041 | + @ background-color: #446979; | |
| 1042 | + }, | |
| 1043 | + { ".statistics-report-week-number-label", | |
| 1044 | + "for the /stats_report views", | |
| 1045 | + @ text-align: right; | |
| 1046 | + @ font-size: 0.8em; | |
| 1047 | + }, | |
| 1048 | + { ".statistics-report-week-of-year-list", | |
| 1049 | + "for the /stats_report views", | |
| 1050 | + @ font-size: 0.8em; | |
| 1038 | 1051 | }, |
| 1039 | 1052 | { "tr.row0", |
| 1040 | 1053 | "even table row color", |
| 1041 | 1054 | @ /* use default */ |
| 1042 | 1055 | }, |
| 1043 | 1056 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1033,10 +1033,23 @@ | |
| 1033 | @ padding: 0.1em 1em 0.1em 1em; |
| 1034 | }, |
| 1035 | { ".statistics-report-row-year", |
| 1036 | "", |
| 1037 | @ text-align: left; |
| 1038 | }, |
| 1039 | { "tr.row0", |
| 1040 | "even table row color", |
| 1041 | @ /* use default */ |
| 1042 | }, |
| 1043 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1033,10 +1033,23 @@ | |
| 1033 | @ padding: 0.1em 1em 0.1em 1em; |
| 1034 | }, |
| 1035 | { ".statistics-report-row-year", |
| 1036 | "", |
| 1037 | @ text-align: left; |
| 1038 | }, |
| 1039 | { ".statistics-report-graph-line", |
| 1040 | "for the /stats_report views", |
| 1041 | @ background-color: #446979; |
| 1042 | }, |
| 1043 | { ".statistics-report-week-number-label", |
| 1044 | "for the /stats_report views", |
| 1045 | @ text-align: right; |
| 1046 | @ font-size: 0.8em; |
| 1047 | }, |
| 1048 | { ".statistics-report-week-of-year-list", |
| 1049 | "for the /stats_report views", |
| 1050 | @ font-size: 0.8em; |
| 1051 | }, |
| 1052 | { "tr.row0", |
| 1053 | "even table row color", |
| 1054 | @ /* use default */ |
| 1055 | }, |
| 1056 |
+21
-7
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1032,10 +1032,11 @@ | ||
| 1032 | 1032 | const char *zTagName = P("t"); /* Show events with this tag */ |
| 1033 | 1033 | const char *zBrName = P("r"); /* Show events related to this tag */ |
| 1034 | 1034 | const char *zSearch = P("s"); /* Search string */ |
| 1035 | 1035 | const char *zUses = P("uf"); /* Only show checkins hold this file */ |
| 1036 | 1036 | const char *zYearMonth = P("ym"); /* Show checkins for the given YYYY-MM */ |
| 1037 | + const char *zYearWeek = P("yw"); /* Show checkins for the given YYYY-WW (weak-of-year) */ | |
| 1037 | 1038 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1038 | 1039 | int renameOnly = P("namechng")!=0; /* Show only checkins that rename files */ |
| 1039 | 1040 | int tagid; /* Tag ID */ |
| 1040 | 1041 | int tmFlags; /* Timeline flags */ |
| 1041 | 1042 | const char *zThisTag = 0; /* Suppress links to this tag */ |
| @@ -1218,10 +1219,14 @@ | ||
| 1218 | 1219 | } |
| 1219 | 1220 | if( zYearMonth ){ |
| 1220 | 1221 | blob_appendf(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1221 | 1222 | zYearMonth); |
| 1222 | 1223 | } |
| 1224 | + else if( zYearWeek ){ | |
| 1225 | + blob_appendf(&sql, " AND %Q=strftime('%%Y-%%W',event.mtime) ", | |
| 1226 | + zYearWeek); | |
| 1227 | + } | |
| 1223 | 1228 | if( tagid>0 ){ |
| 1224 | 1229 | blob_appendf(&sql, |
| 1225 | 1230 | "AND (EXISTS(SELECT 1 FROM tagxref" |
| 1226 | 1231 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid); |
| 1227 | 1232 | |
| @@ -1350,10 +1355,12 @@ | ||
| 1350 | 1355 | db_multi_exec("%s", blob_str(&sql)); |
| 1351 | 1356 | |
| 1352 | 1357 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1353 | 1358 | if( zYearMonth ){ |
| 1354 | 1359 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1360 | + }if( zYearWeek ){ | |
| 1361 | + blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); | |
| 1355 | 1362 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1356 | 1363 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1357 | 1364 | }else{ |
| 1358 | 1365 | blob_appendf(&desc, "%d %ss", n, zEType); |
| 1359 | 1366 | } |
| @@ -1836,10 +1843,12 @@ | ||
| 1836 | 1843 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1837 | 1844 | ** or YYYY-MM. |
| 1838 | 1845 | */ |
| 1839 | 1846 | static void stats_report_output_week_links( char const * zTimeframe){ |
| 1840 | 1847 | Stmt stWeek = empty_Stmt; |
| 1848 | + char yearPart[5] = {0,0,0,0,0}; | |
| 1849 | + memcpy(yearPart, zTimeframe, 4); | |
| 1841 | 1850 | db_prepare(&stWeek, |
| 1842 | 1851 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| 1843 | 1852 | "count(*) AS n, " |
| 1844 | 1853 | "substr(date(mtime),1,%d) AS ym " |
| 1845 | 1854 | "FROM event " |
| @@ -1846,13 +1855,13 @@ | ||
| 1846 | 1855 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1847 | 1856 | "GROUP BY wk ORDER BY wk", |
| 1848 | 1857 | strlen(zTimeframe), |
| 1849 | 1858 | zTimeframe); |
| 1850 | 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1851 | - zTimeframe = db_column_text(&stWeek,0); | |
| 1852 | - /* TODO: link to... what? Maybe add /timeline?yw=YYYY-WW (week #)? */ | |
| 1853 | - @ %s(zTimeframe) | |
| 1860 | + char const * zWeek = db_column_text(&stWeek,0); | |
| 1861 | + @ <a href='%s(g.zTop)/timeline?yw=%t(yearPart)-%t(zWeek)'> | |
| 1862 | + @ %s(zWeek)</a> | |
| 1854 | 1863 | } |
| 1855 | 1864 | db_finalize(&stWeek); |
| 1856 | 1865 | } |
| 1857 | 1866 | |
| 1858 | 1867 | /* |
| @@ -1957,14 +1966,19 @@ | ||
| 1957 | 1966 | @ <td> |
| 1958 | 1967 | @ <div class='statistics-report-graph-line' |
| 1959 | 1968 | @ style='height:16px;width:%d(nSize)px;'> |
| 1960 | 1969 | @ </div></td> |
| 1961 | 1970 | @</tr> |
| 1962 | - @ <tr><td colspan='2' class='statistics-report-week-number-label'>Week #:</td> | |
| 1963 | - @ <td class='statistics-report-week-of-year-list'> | |
| 1964 | - stats_report_output_week_links(zTimeframe); | |
| 1965 | - @ </td></tr> | |
| 1971 | + if(!includeMonth){ | |
| 1972 | + /* This part works fine for months but it terribly slow (4.5s on my PC), | |
| 1973 | + so it's only shown for by-year for now. Suggestions/patches for | |
| 1974 | + a better/faster layout are welcomed. */ | |
| 1975 | + @ <tr><td colspan='2' class='statistics-report-week-number-label'>Week #:</td> | |
| 1976 | + @ <td class='statistics-report-week-of-year-list'> | |
| 1977 | + stats_report_output_week_links(zTimeframe); | |
| 1978 | + @ </td></tr> | |
| 1979 | + } | |
| 1966 | 1980 | |
| 1967 | 1981 | /* |
| 1968 | 1982 | Potential improvement: calculate the min/max event counts and |
| 1969 | 1983 | use percent-based graph bars. |
| 1970 | 1984 | */ |
| 1971 | 1985 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1032,10 +1032,11 @@ | |
| 1032 | const char *zTagName = P("t"); /* Show events with this tag */ |
| 1033 | const char *zBrName = P("r"); /* Show events related to this tag */ |
| 1034 | const char *zSearch = P("s"); /* Search string */ |
| 1035 | const char *zUses = P("uf"); /* Only show checkins hold this file */ |
| 1036 | const char *zYearMonth = P("ym"); /* Show checkins for the given YYYY-MM */ |
| 1037 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1038 | int renameOnly = P("namechng")!=0; /* Show only checkins that rename files */ |
| 1039 | int tagid; /* Tag ID */ |
| 1040 | int tmFlags; /* Timeline flags */ |
| 1041 | const char *zThisTag = 0; /* Suppress links to this tag */ |
| @@ -1218,10 +1219,14 @@ | |
| 1218 | } |
| 1219 | if( zYearMonth ){ |
| 1220 | blob_appendf(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1221 | zYearMonth); |
| 1222 | } |
| 1223 | if( tagid>0 ){ |
| 1224 | blob_appendf(&sql, |
| 1225 | "AND (EXISTS(SELECT 1 FROM tagxref" |
| 1226 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid); |
| 1227 | |
| @@ -1350,10 +1355,12 @@ | |
| 1350 | db_multi_exec("%s", blob_str(&sql)); |
| 1351 | |
| 1352 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1353 | if( zYearMonth ){ |
| 1354 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1355 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1356 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1357 | }else{ |
| 1358 | blob_appendf(&desc, "%d %ss", n, zEType); |
| 1359 | } |
| @@ -1836,10 +1843,12 @@ | |
| 1836 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1837 | ** or YYYY-MM. |
| 1838 | */ |
| 1839 | static void stats_report_output_week_links( char const * zTimeframe){ |
| 1840 | Stmt stWeek = empty_Stmt; |
| 1841 | db_prepare(&stWeek, |
| 1842 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| 1843 | "count(*) AS n, " |
| 1844 | "substr(date(mtime),1,%d) AS ym " |
| 1845 | "FROM event " |
| @@ -1846,13 +1855,13 @@ | |
| 1846 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1847 | "GROUP BY wk ORDER BY wk", |
| 1848 | strlen(zTimeframe), |
| 1849 | zTimeframe); |
| 1850 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1851 | zTimeframe = db_column_text(&stWeek,0); |
| 1852 | /* TODO: link to... what? Maybe add /timeline?yw=YYYY-WW (week #)? */ |
| 1853 | @ %s(zTimeframe) |
| 1854 | } |
| 1855 | db_finalize(&stWeek); |
| 1856 | } |
| 1857 | |
| 1858 | /* |
| @@ -1957,14 +1966,19 @@ | |
| 1957 | @ <td> |
| 1958 | @ <div class='statistics-report-graph-line' |
| 1959 | @ style='height:16px;width:%d(nSize)px;'> |
| 1960 | @ </div></td> |
| 1961 | @</tr> |
| 1962 | @ <tr><td colspan='2' class='statistics-report-week-number-label'>Week #:</td> |
| 1963 | @ <td class='statistics-report-week-of-year-list'> |
| 1964 | stats_report_output_week_links(zTimeframe); |
| 1965 | @ </td></tr> |
| 1966 | |
| 1967 | /* |
| 1968 | Potential improvement: calculate the min/max event counts and |
| 1969 | use percent-based graph bars. |
| 1970 | */ |
| 1971 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1032,10 +1032,11 @@ | |
| 1032 | const char *zTagName = P("t"); /* Show events with this tag */ |
| 1033 | const char *zBrName = P("r"); /* Show events related to this tag */ |
| 1034 | const char *zSearch = P("s"); /* Search string */ |
| 1035 | const char *zUses = P("uf"); /* Only show checkins hold this file */ |
| 1036 | const char *zYearMonth = P("ym"); /* Show checkins for the given YYYY-MM */ |
| 1037 | const char *zYearWeek = P("yw"); /* Show checkins for the given YYYY-WW (weak-of-year) */ |
| 1038 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1039 | int renameOnly = P("namechng")!=0; /* Show only checkins that rename files */ |
| 1040 | int tagid; /* Tag ID */ |
| 1041 | int tmFlags; /* Timeline flags */ |
| 1042 | const char *zThisTag = 0; /* Suppress links to this tag */ |
| @@ -1218,10 +1219,14 @@ | |
| 1219 | } |
| 1220 | if( zYearMonth ){ |
| 1221 | blob_appendf(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ", |
| 1222 | zYearMonth); |
| 1223 | } |
| 1224 | else if( zYearWeek ){ |
| 1225 | blob_appendf(&sql, " AND %Q=strftime('%%Y-%%W',event.mtime) ", |
| 1226 | zYearWeek); |
| 1227 | } |
| 1228 | if( tagid>0 ){ |
| 1229 | blob_appendf(&sql, |
| 1230 | "AND (EXISTS(SELECT 1 FROM tagxref" |
| 1231 | " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid); |
| 1232 | |
| @@ -1350,10 +1355,12 @@ | |
| 1355 | db_multi_exec("%s", blob_str(&sql)); |
| 1356 | |
| 1357 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1358 | if( zYearMonth ){ |
| 1359 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1360 | }if( zYearWeek ){ |
| 1361 | blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); |
| 1362 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1363 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1364 | }else{ |
| 1365 | blob_appendf(&desc, "%d %ss", n, zEType); |
| 1366 | } |
| @@ -1836,10 +1843,12 @@ | |
| 1843 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1844 | ** or YYYY-MM. |
| 1845 | */ |
| 1846 | static void stats_report_output_week_links( char const * zTimeframe){ |
| 1847 | Stmt stWeek = empty_Stmt; |
| 1848 | char yearPart[5] = {0,0,0,0,0}; |
| 1849 | memcpy(yearPart, zTimeframe, 4); |
| 1850 | db_prepare(&stWeek, |
| 1851 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| 1852 | "count(*) AS n, " |
| 1853 | "substr(date(mtime),1,%d) AS ym " |
| 1854 | "FROM event " |
| @@ -1846,13 +1855,13 @@ | |
| 1855 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1856 | "GROUP BY wk ORDER BY wk", |
| 1857 | strlen(zTimeframe), |
| 1858 | zTimeframe); |
| 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1860 | char const * zWeek = db_column_text(&stWeek,0); |
| 1861 | @ <a href='%s(g.zTop)/timeline?yw=%t(yearPart)-%t(zWeek)'> |
| 1862 | @ %s(zWeek)</a> |
| 1863 | } |
| 1864 | db_finalize(&stWeek); |
| 1865 | } |
| 1866 | |
| 1867 | /* |
| @@ -1957,14 +1966,19 @@ | |
| 1966 | @ <td> |
| 1967 | @ <div class='statistics-report-graph-line' |
| 1968 | @ style='height:16px;width:%d(nSize)px;'> |
| 1969 | @ </div></td> |
| 1970 | @</tr> |
| 1971 | if(!includeMonth){ |
| 1972 | /* This part works fine for months but it terribly slow (4.5s on my PC), |
| 1973 | so it's only shown for by-year for now. Suggestions/patches for |
| 1974 | a better/faster layout are welcomed. */ |
| 1975 | @ <tr><td colspan='2' class='statistics-report-week-number-label'>Week #:</td> |
| 1976 | @ <td class='statistics-report-week-of-year-list'> |
| 1977 | stats_report_output_week_links(zTimeframe); |
| 1978 | @ </td></tr> |
| 1979 | } |
| 1980 | |
| 1981 | /* |
| 1982 | Potential improvement: calculate the min/max event counts and |
| 1983 | use percent-based graph bars. |
| 1984 | */ |
| 1985 |