Fossil SCM
Initial support for user=drh in byweek view, but need to add support for carrying it over in the year links. Bed time.
Commit
52dc6c80ec741f9fea7ff636933a350ec4e89bdc
Parent
c8b024bb1bc6dcf…
1 file changed
+22
-10
+22
-10
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2068,14 +2068,16 @@ | ||
| 2068 | 2068 | char const * zYear = P("y"); |
| 2069 | 2069 | int nYear = zYear ? strlen(zYear) : 0; |
| 2070 | 2070 | int i = 0; |
| 2071 | 2071 | Stmt qYears = empty_Stmt; |
| 2072 | 2072 | char * zDefaultYear = NULL; |
| 2073 | + char const * zUserName = P("user"); | |
| 2073 | 2074 | cgi_printf("Select year: "); |
| 2074 | 2075 | db_prepare(&qYears, |
| 2075 | 2076 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2076 | 2077 | "FROM event GROUP BY y ORDER BY y"); |
| 2078 | + | |
| 2077 | 2079 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2078 | 2080 | char const * zT = db_column_text(&qYears, 0); |
| 2079 | 2081 | if( i++ ){ |
| 2080 | 2082 | cgi_printf(" "); |
| 2081 | 2083 | } |
| @@ -2091,29 +2093,39 @@ | ||
| 2091 | 2093 | } |
| 2092 | 2094 | if(4 == nYear){ |
| 2093 | 2095 | int const nPixelsPerEvent = 3; /* for sizing the "graph" part */ |
| 2094 | 2096 | Stmt stWeek = empty_Stmt; |
| 2095 | 2097 | int rowCount = 0; |
| 2096 | - cgi_printf("<h1>Timeline events for the calendar weeks of %h.</h1>", | |
| 2097 | - zYear); | |
| 2098 | + Blob sql = empty_blob; | |
| 2099 | + Blob header = empty_blob; | |
| 2100 | + blob_appendf(&header, "Timeline events for the calendar weeks " | |
| 2101 | + "of %h", zYear); | |
| 2102 | + blob_appendf(&sql, | |
| 2103 | + "SELECT DISTINCT strftime('%%%%W',mtime) AS wk, " | |
| 2104 | + "count(*) AS n " | |
| 2105 | + "FROM event " | |
| 2106 | + "WHERE %Q=substr(date(mtime),1,4) " | |
| 2107 | + "AND mtime < current_timestamp ", | |
| 2108 | + zYear); | |
| 2109 | + if(zUserName&&*zUserName){ | |
| 2110 | + blob_appendf(&sql, " AND user=%Q ", zUserName); | |
| 2111 | + blob_appendf(&header," for user %h", zUserName); | |
| 2112 | + } | |
| 2113 | + blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC"); | |
| 2114 | + cgi_printf("<h1>%h</h1>", blob_str(&header)); | |
| 2115 | + blob_reset(&header); | |
| 2098 | 2116 | cgi_printf("<table class='statistics-report-table-events' " |
| 2099 | 2117 | "border='0' cellpadding='2' " |
| 2100 | 2118 | "cellspacing='0' id='statsTable'>"); |
| 2101 | 2119 | cgi_printf("<thead><tr>" |
| 2102 | 2120 | "<th>Week</th>" |
| 2103 | 2121 | "<th>Events</th>" |
| 2104 | 2122 | "<th><!-- relative commits graph --></th>" |
| 2105 | 2123 | "</tr></thead>" |
| 2106 | 2124 | "<tbody>"); |
| 2107 | - db_prepare(&stWeek, | |
| 2108 | - "SELECT DISTINCT strftime('%%W',mtime) AS wk, " | |
| 2109 | - "count(*) AS n " | |
| 2110 | - "FROM event " | |
| 2111 | - "WHERE %Q=substr(date(mtime),1,4) " | |
| 2112 | - "AND mtime < current_timestamp " | |
| 2113 | - "GROUP BY wk ORDER BY wk DESC", | |
| 2114 | - zYear); | |
| 2125 | + db_prepare(&stWeek, blob_str(&sql)); | |
| 2126 | + blob_reset(&sql); | |
| 2115 | 2127 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2116 | 2128 | char const * zWeek = db_column_text(&stWeek,0); |
| 2117 | 2129 | int nCount = db_column_int(&stWeek,1); |
| 2118 | 2130 | int const graphSize = nPixelsPerEvent * nCount; |
| 2119 | 2131 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2120 | 2132 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2068,14 +2068,16 @@ | |
| 2068 | char const * zYear = P("y"); |
| 2069 | int nYear = zYear ? strlen(zYear) : 0; |
| 2070 | int i = 0; |
| 2071 | Stmt qYears = empty_Stmt; |
| 2072 | char * zDefaultYear = NULL; |
| 2073 | cgi_printf("Select year: "); |
| 2074 | db_prepare(&qYears, |
| 2075 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2076 | "FROM event GROUP BY y ORDER BY y"); |
| 2077 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2078 | char const * zT = db_column_text(&qYears, 0); |
| 2079 | if( i++ ){ |
| 2080 | cgi_printf(" "); |
| 2081 | } |
| @@ -2091,29 +2093,39 @@ | |
| 2091 | } |
| 2092 | if(4 == nYear){ |
| 2093 | int const nPixelsPerEvent = 3; /* for sizing the "graph" part */ |
| 2094 | Stmt stWeek = empty_Stmt; |
| 2095 | int rowCount = 0; |
| 2096 | cgi_printf("<h1>Timeline events for the calendar weeks of %h.</h1>", |
| 2097 | zYear); |
| 2098 | cgi_printf("<table class='statistics-report-table-events' " |
| 2099 | "border='0' cellpadding='2' " |
| 2100 | "cellspacing='0' id='statsTable'>"); |
| 2101 | cgi_printf("<thead><tr>" |
| 2102 | "<th>Week</th>" |
| 2103 | "<th>Events</th>" |
| 2104 | "<th><!-- relative commits graph --></th>" |
| 2105 | "</tr></thead>" |
| 2106 | "<tbody>"); |
| 2107 | db_prepare(&stWeek, |
| 2108 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| 2109 | "count(*) AS n " |
| 2110 | "FROM event " |
| 2111 | "WHERE %Q=substr(date(mtime),1,4) " |
| 2112 | "AND mtime < current_timestamp " |
| 2113 | "GROUP BY wk ORDER BY wk DESC", |
| 2114 | zYear); |
| 2115 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2116 | char const * zWeek = db_column_text(&stWeek,0); |
| 2117 | int nCount = db_column_int(&stWeek,1); |
| 2118 | int const graphSize = nPixelsPerEvent * nCount; |
| 2119 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2120 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2068,14 +2068,16 @@ | |
| 2068 | char const * zYear = P("y"); |
| 2069 | int nYear = zYear ? strlen(zYear) : 0; |
| 2070 | int i = 0; |
| 2071 | Stmt qYears = empty_Stmt; |
| 2072 | char * zDefaultYear = NULL; |
| 2073 | char const * zUserName = P("user"); |
| 2074 | cgi_printf("Select year: "); |
| 2075 | db_prepare(&qYears, |
| 2076 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2077 | "FROM event GROUP BY y ORDER BY y"); |
| 2078 | |
| 2079 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2080 | char const * zT = db_column_text(&qYears, 0); |
| 2081 | if( i++ ){ |
| 2082 | cgi_printf(" "); |
| 2083 | } |
| @@ -2091,29 +2093,39 @@ | |
| 2093 | } |
| 2094 | if(4 == nYear){ |
| 2095 | int const nPixelsPerEvent = 3; /* for sizing the "graph" part */ |
| 2096 | Stmt stWeek = empty_Stmt; |
| 2097 | int rowCount = 0; |
| 2098 | Blob sql = empty_blob; |
| 2099 | Blob header = empty_blob; |
| 2100 | blob_appendf(&header, "Timeline events for the calendar weeks " |
| 2101 | "of %h", zYear); |
| 2102 | blob_appendf(&sql, |
| 2103 | "SELECT DISTINCT strftime('%%%%W',mtime) AS wk, " |
| 2104 | "count(*) AS n " |
| 2105 | "FROM event " |
| 2106 | "WHERE %Q=substr(date(mtime),1,4) " |
| 2107 | "AND mtime < current_timestamp ", |
| 2108 | zYear); |
| 2109 | if(zUserName&&*zUserName){ |
| 2110 | blob_appendf(&sql, " AND user=%Q ", zUserName); |
| 2111 | blob_appendf(&header," for user %h", zUserName); |
| 2112 | } |
| 2113 | blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC"); |
| 2114 | cgi_printf("<h1>%h</h1>", blob_str(&header)); |
| 2115 | blob_reset(&header); |
| 2116 | cgi_printf("<table class='statistics-report-table-events' " |
| 2117 | "border='0' cellpadding='2' " |
| 2118 | "cellspacing='0' id='statsTable'>"); |
| 2119 | cgi_printf("<thead><tr>" |
| 2120 | "<th>Week</th>" |
| 2121 | "<th>Events</th>" |
| 2122 | "<th><!-- relative commits graph --></th>" |
| 2123 | "</tr></thead>" |
| 2124 | "<tbody>"); |
| 2125 | db_prepare(&stWeek, blob_str(&sql)); |
| 2126 | blob_reset(&sql); |
| 2127 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2128 | char const * zWeek = db_column_text(&stWeek,0); |
| 2129 | int nCount = db_column_int(&stWeek,1); |
| 2130 | int const graphSize = nPixelsPerEvent * nCount; |
| 2131 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2132 |