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.

stephan 2013-07-16 15:49 UTC stats-report-weekly
Commit 0019550a0300880e08ab311c9741746f42eb999b
2 files changed +13 +21 -7
+13
--- src/style.c
+++ src/style.c
@@ -1033,10 +1033,23 @@
10331033
@ padding: 0.1em 1em 0.1em 1em;
10341034
},
10351035
{ ".statistics-report-row-year",
10361036
"",
10371037
@ 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;
10381051
},
10391052
{ "tr.row0",
10401053
"even table row color",
10411054
@ /* use default */
10421055
},
10431056
--- 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 @@
10321032
const char *zTagName = P("t"); /* Show events with this tag */
10331033
const char *zBrName = P("r"); /* Show events related to this tag */
10341034
const char *zSearch = P("s"); /* Search string */
10351035
const char *zUses = P("uf"); /* Only show checkins hold this file */
10361036
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) */
10371038
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
10381039
int renameOnly = P("namechng")!=0; /* Show only checkins that rename files */
10391040
int tagid; /* Tag ID */
10401041
int tmFlags; /* Timeline flags */
10411042
const char *zThisTag = 0; /* Suppress links to this tag */
@@ -1218,10 +1219,14 @@
12181219
}
12191220
if( zYearMonth ){
12201221
blob_appendf(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
12211222
zYearMonth);
12221223
}
1224
+ else if( zYearWeek ){
1225
+ blob_appendf(&sql, " AND %Q=strftime('%%Y-%%W',event.mtime) ",
1226
+ zYearWeek);
1227
+ }
12231228
if( tagid>0 ){
12241229
blob_appendf(&sql,
12251230
"AND (EXISTS(SELECT 1 FROM tagxref"
12261231
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid);
12271232
@@ -1350,10 +1355,12 @@
13501355
db_multi_exec("%s", blob_str(&sql));
13511356
13521357
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
13531358
if( zYearMonth ){
13541359
blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
1360
+ }if( zYearWeek ){
1361
+ blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek);
13551362
}else if( zAfter==0 && zBefore==0 && zCirca==0 ){
13561363
blob_appendf(&desc, "%d most recent %ss", n, zEType);
13571364
}else{
13581365
blob_appendf(&desc, "%d %ss", n, zEType);
13591366
}
@@ -1836,10 +1843,12 @@
18361843
** week numbers. zTimeframe should be either a timeframe in the form YYYY
18371844
** or YYYY-MM.
18381845
*/
18391846
static void stats_report_output_week_links( char const * zTimeframe){
18401847
Stmt stWeek = empty_Stmt;
1848
+ char yearPart[5] = {0,0,0,0,0};
1849
+ memcpy(yearPart, zTimeframe, 4);
18411850
db_prepare(&stWeek,
18421851
"SELECT DISTINCT strftime('%%W',mtime) AS wk, "
18431852
"count(*) AS n, "
18441853
"substr(date(mtime),1,%d) AS ym "
18451854
"FROM event "
@@ -1846,13 +1855,13 @@
18461855
"WHERE ym=%Q AND mtime < current_timestamp "
18471856
"GROUP BY wk ORDER BY wk",
18481857
strlen(zTimeframe),
18491858
zTimeframe);
18501859
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>
18541863
}
18551864
db_finalize(&stWeek);
18561865
}
18571866
18581867
/*
@@ -1957,14 +1966,19 @@
19571966
@ <td>
19581967
@ <div class='statistics-report-graph-line'
19591968
@ style='height:16px;width:%d(nSize)px;'>
19601969
@ </div></td>
19611970
@</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
+ }
19661980
19671981
/*
19681982
Potential improvement: calculate the min/max event counts and
19691983
use percent-based graph bars.
19701984
*/
19711985
--- 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

Keyboard Shortcuts

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