Fossil SCM

Added a missing db_finalize(). Replaced a TODO text with the corresponding code. Changed timeline page header when the ym=YYYY-MM param is set.

stephan 2013-05-04 21:36 trunk
Commit d16c09f8c1069650e621e3244fa09453b0d48275
1 file changed +9 -10
+9 -10
--- src/timeline.c
+++ src/timeline.c
@@ -1350,11 +1350,13 @@
13501350
}
13511351
blob_appendf(&sql, " LIMIT %d", nEntry);
13521352
db_multi_exec("%s", blob_str(&sql));
13531353
13541354
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
1355
- if( zAfter==0 && zBefore==0 && zCirca==0 ){
1355
+ if( zYearMonth ){
1356
+ blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
1357
+ }else if( zAfter==0 && zBefore==0 && zCirca==0 ){
13561358
blob_appendf(&desc, "%d most recent %ss", n, zEType);
13571359
}else{
13581360
blob_appendf(&desc, "%d %ss", n, zEType);
13591361
}
13601362
if( zUses ){
@@ -1833,22 +1835,19 @@
18331835
** Shows an activity report for the repository.
18341836
*/
18351837
void activity_page(){
18361838
Stmt query = empty_Stmt;
18371839
int const nPixelsPerCommit = 2;
1838
- int const nTimelineCount = 200;
18391840
int nRowNumber = 0;
18401841
int nCommitCount = 0;
18411842
style_header("Repository Activity");
1842
-
18431843
db_prepare(&query,
18441844
"SELECT substr(date(mtime),1,7) AS Month, "
18451845
"count(*) AS Commits FROM event "
18461846
"WHERE type='ci' "
18471847
"GROUP BY Month "
18481848
"ORDER BY Month DESC", -1);
1849
-
18501849
@ <h1>Commits by Month</h1>
18511850
@ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'>
18521851
@ <thead>
18531852
@ <th>Year/Month</th>
18541853
@ <th>Commits</th>
@@ -1856,17 +1855,16 @@
18561855
@ </thead><tbody>
18571856
while( SQLITE_ROW == db_step(&query) ){
18581857
char const * zMonth = db_column_text(&query, 0);
18591858
int const nCount = db_column_int(&query, 1);
18601859
int const nSize = nPixelsPerCommit * nCount;
1861
- char rowClass = ++nRowNumber % 2;
1860
+ char const rowClass = ++nRowNumber % 2;
1861
+ int const nTimelineCount =
1862
+ db_int(200, "SELECT COUNT(*) FROM event WHERE "
1863
+ "substr(date(mtime),1,7)=%Q",
1864
+ zMonth);
18621865
nCommitCount += nCount;
1863
- /**
1864
- * Potential improvement: set nCount to exactly the number of
1865
- * events for the month. Keep in mind that this query only counts
1866
- * 'ci' events but we link to the timeline for all event types.
1867
- */
18681866
@<tr class='row%d(rowClass)'>
18691867
@ <td>
18701868
@ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
18711869
@ </td><td>%d(nCount)</td>
18721870
@ <td>
@@ -1874,7 +1872,8 @@
18741872
@ </div></td>
18751873
@</tr>
18761874
}
18771875
@ </tbody></table>
18781876
@ Total commits: %d(nCommitCount)
1877
+ db_finalize(&query);
18791878
style_footer();
18801879
}
18811880
--- src/timeline.c
+++ src/timeline.c
@@ -1350,11 +1350,13 @@
1350 }
1351 blob_appendf(&sql, " LIMIT %d", nEntry);
1352 db_multi_exec("%s", blob_str(&sql));
1353
1354 n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
1355 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 }
1360 if( zUses ){
@@ -1833,22 +1835,19 @@
1833 ** Shows an activity report for the repository.
1834 */
1835 void activity_page(){
1836 Stmt query = empty_Stmt;
1837 int const nPixelsPerCommit = 2;
1838 int const nTimelineCount = 200;
1839 int nRowNumber = 0;
1840 int nCommitCount = 0;
1841 style_header("Repository Activity");
1842
1843 db_prepare(&query,
1844 "SELECT substr(date(mtime),1,7) AS Month, "
1845 "count(*) AS Commits FROM event "
1846 "WHERE type='ci' "
1847 "GROUP BY Month "
1848 "ORDER BY Month DESC", -1);
1849
1850 @ <h1>Commits by Month</h1>
1851 @ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'>
1852 @ <thead>
1853 @ <th>Year/Month</th>
1854 @ <th>Commits</th>
@@ -1856,17 +1855,16 @@
1856 @ </thead><tbody>
1857 while( SQLITE_ROW == db_step(&query) ){
1858 char const * zMonth = db_column_text(&query, 0);
1859 int const nCount = db_column_int(&query, 1);
1860 int const nSize = nPixelsPerCommit * nCount;
1861 char rowClass = ++nRowNumber % 2;
 
 
 
 
1862 nCommitCount += nCount;
1863 /**
1864 * Potential improvement: set nCount to exactly the number of
1865 * events for the month. Keep in mind that this query only counts
1866 * 'ci' events but we link to the timeline for all event types.
1867 */
1868 @<tr class='row%d(rowClass)'>
1869 @ <td>
1870 @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
1871 @ </td><td>%d(nCount)</td>
1872 @ <td>
@@ -1874,7 +1872,8 @@
1874 @ </div></td>
1875 @</tr>
1876 }
1877 @ </tbody></table>
1878 @ Total commits: %d(nCommitCount)
 
1879 style_footer();
1880 }
1881
--- src/timeline.c
+++ src/timeline.c
@@ -1350,11 +1350,13 @@
1350 }
1351 blob_appendf(&sql, " LIMIT %d", nEntry);
1352 db_multi_exec("%s", blob_str(&sql));
1353
1354 n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
1355 if( zYearMonth ){
1356 blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
1357 }else if( zAfter==0 && zBefore==0 && zCirca==0 ){
1358 blob_appendf(&desc, "%d most recent %ss", n, zEType);
1359 }else{
1360 blob_appendf(&desc, "%d %ss", n, zEType);
1361 }
1362 if( zUses ){
@@ -1833,22 +1835,19 @@
1835 ** Shows an activity report for the repository.
1836 */
1837 void activity_page(){
1838 Stmt query = empty_Stmt;
1839 int const nPixelsPerCommit = 2;
 
1840 int nRowNumber = 0;
1841 int nCommitCount = 0;
1842 style_header("Repository Activity");
 
1843 db_prepare(&query,
1844 "SELECT substr(date(mtime),1,7) AS Month, "
1845 "count(*) AS Commits FROM event "
1846 "WHERE type='ci' "
1847 "GROUP BY Month "
1848 "ORDER BY Month DESC", -1);
 
1849 @ <h1>Commits by Month</h1>
1850 @ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'>
1851 @ <thead>
1852 @ <th>Year/Month</th>
1853 @ <th>Commits</th>
@@ -1856,17 +1855,16 @@
1855 @ </thead><tbody>
1856 while( SQLITE_ROW == db_step(&query) ){
1857 char const * zMonth = db_column_text(&query, 0);
1858 int const nCount = db_column_int(&query, 1);
1859 int const nSize = nPixelsPerCommit * nCount;
1860 char const rowClass = ++nRowNumber % 2;
1861 int const nTimelineCount =
1862 db_int(200, "SELECT COUNT(*) FROM event WHERE "
1863 "substr(date(mtime),1,7)=%Q",
1864 zMonth);
1865 nCommitCount += nCount;
 
 
 
 
 
1866 @<tr class='row%d(rowClass)'>
1867 @ <td>
1868 @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
1869 @ </td><td>%d(nCount)</td>
1870 @ <td>
@@ -1874,7 +1872,8 @@
1872 @ </div></td>
1873 @</tr>
1874 }
1875 @ </tbody></table>
1876 @ Total commits: %d(nCommitCount)
1877 db_finalize(&query);
1878 style_footer();
1879 }
1880

Keyboard Shortcuts

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