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.
Commit
d16c09f8c1069650e621e3244fa09453b0d48275
Parent
fd74734bf87ada4…
1 file changed
+9
-10
+9
-10
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1350,11 +1350,13 @@ | ||
| 1350 | 1350 | } |
| 1351 | 1351 | blob_appendf(&sql, " LIMIT %d", nEntry); |
| 1352 | 1352 | db_multi_exec("%s", blob_str(&sql)); |
| 1353 | 1353 | |
| 1354 | 1354 | 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 ){ | |
| 1356 | 1358 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1357 | 1359 | }else{ |
| 1358 | 1360 | blob_appendf(&desc, "%d %ss", n, zEType); |
| 1359 | 1361 | } |
| 1360 | 1362 | if( zUses ){ |
| @@ -1833,22 +1835,19 @@ | ||
| 1833 | 1835 | ** Shows an activity report for the repository. |
| 1834 | 1836 | */ |
| 1835 | 1837 | void activity_page(){ |
| 1836 | 1838 | Stmt query = empty_Stmt; |
| 1837 | 1839 | int const nPixelsPerCommit = 2; |
| 1838 | - int const nTimelineCount = 200; | |
| 1839 | 1840 | int nRowNumber = 0; |
| 1840 | 1841 | int nCommitCount = 0; |
| 1841 | 1842 | style_header("Repository Activity"); |
| 1842 | - | |
| 1843 | 1843 | db_prepare(&query, |
| 1844 | 1844 | "SELECT substr(date(mtime),1,7) AS Month, " |
| 1845 | 1845 | "count(*) AS Commits FROM event " |
| 1846 | 1846 | "WHERE type='ci' " |
| 1847 | 1847 | "GROUP BY Month " |
| 1848 | 1848 | "ORDER BY Month DESC", -1); |
| 1849 | - | |
| 1850 | 1849 | @ <h1>Commits by Month</h1> |
| 1851 | 1850 | @ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'> |
| 1852 | 1851 | @ <thead> |
| 1853 | 1852 | @ <th>Year/Month</th> |
| 1854 | 1853 | @ <th>Commits</th> |
| @@ -1856,17 +1855,16 @@ | ||
| 1856 | 1855 | @ </thead><tbody> |
| 1857 | 1856 | while( SQLITE_ROW == db_step(&query) ){ |
| 1858 | 1857 | char const * zMonth = db_column_text(&query, 0); |
| 1859 | 1858 | int const nCount = db_column_int(&query, 1); |
| 1860 | 1859 | 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); | |
| 1862 | 1865 | 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 | 1866 | @<tr class='row%d(rowClass)'> |
| 1869 | 1867 | @ <td> |
| 1870 | 1868 | @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a> |
| 1871 | 1869 | @ </td><td>%d(nCount)</td> |
| 1872 | 1870 | @ <td> |
| @@ -1874,7 +1872,8 @@ | ||
| 1874 | 1872 | @ </div></td> |
| 1875 | 1873 | @</tr> |
| 1876 | 1874 | } |
| 1877 | 1875 | @ </tbody></table> |
| 1878 | 1876 | @ Total commits: %d(nCommitCount) |
| 1877 | + db_finalize(&query); | |
| 1879 | 1878 | style_footer(); |
| 1880 | 1879 | } |
| 1881 | 1880 |
| --- 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 |