Fossil SCM

Added initial version of /activity page, intended to show "activity reports." Currently shows commit count by month.

stephan 2013-05-04 20:39 trunk
Commit 495bf1ea8d1615c249bd6d4bcb863ceb6e368d80
2 files changed +18 +47
+18
--- src/style.c
+++ src/style.c
@@ -612,10 +612,28 @@
612612
@ table.label-value th {
613613
@ vertical-align: top;
614614
@ text-align: right;
615615
@ padding: 0.2ex 2ex;
616616
@ }
617
+@
618
+@ /* .activity-* are for the /activity views */
619
+@ .activity-graph-line {
620
+@ background-color: #446979;
621
+@ }
622
+@ .activity-table-commits-by-month th {
623
+@ padding: 0 1em 0 1em;
624
+@ }
625
+@ .activity-table-commits-by-month td {
626
+@ padding: 0.1em 1em 0.1em 1em;
627
+@ }
628
+@ /* row0 and row1 are for alternating table row colors */
629
+@ tr.row0 {
630
+@ background: #fff;
631
+@ }
632
+@ tr.row1 {
633
+@ background-color: #dadada;
634
+@ }
617635
;
618636
619637
620638
/* The following table contains bits of default CSS that must
621639
** be included if they are not found in the application-defined
622640
--- src/style.c
+++ src/style.c
@@ -612,10 +612,28 @@
612 @ table.label-value th {
613 @ vertical-align: top;
614 @ text-align: right;
615 @ padding: 0.2ex 2ex;
616 @ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
617 ;
618
619
620 /* The following table contains bits of default CSS that must
621 ** be included if they are not found in the application-defined
622
--- src/style.c
+++ src/style.c
@@ -612,10 +612,28 @@
612 @ table.label-value th {
613 @ vertical-align: top;
614 @ text-align: right;
615 @ padding: 0.2ex 2ex;
616 @ }
617 @
618 @ /* .activity-* are for the /activity views */
619 @ .activity-graph-line {
620 @ background-color: #446979;
621 @ }
622 @ .activity-table-commits-by-month th {
623 @ padding: 0 1em 0 1em;
624 @ }
625 @ .activity-table-commits-by-month td {
626 @ padding: 0.1em 1em 0.1em 1em;
627 @ }
628 @ /* row0 and row1 are for alternating table row colors */
629 @ tr.row0 {
630 @ background: #fff;
631 @ }
632 @ tr.row1 {
633 @ background-color: #dadada;
634 @ }
635 ;
636
637
638 /* The following table contains bits of default CSS that must
639 ** be included if they are not found in the application-defined
640
--- src/timeline.c
+++ src/timeline.c
@@ -1824,5 +1824,52 @@
18241824
@ <a href="%s(g.zTop)/timeline?p=%S(zUuid)&amp;d=%S(zUuid)">%S(zUuid)</a>
18251825
}
18261826
db_finalize(&q);
18271827
style_footer();
18281828
}
1829
+
1830
+/*
1831
+** WEBPAGE: activity
1832
+**
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>
1855
+ @ <th><!-- relative commits graph --></th>
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
+ nCommitCount += nCount;
1862
+ char rowClass = ++nRowNumber % 2;
1863
+ @<tr class='row%d(rowClass)'>
1864
+ @ <td>
1865
+ @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
1866
+ @ </td><td>%d(nCount)</td>
1867
+ @ <td>
1868
+ @ <div class='activity-graph-line' style='height:16px; width:%d(nSize)px;'>
1869
+ @ </div></td>
1870
+ @</tr>
1871
+ }
1872
+ @ </tbody></table>
1873
+ @ Total commits: %d(nCommitCount)
1874
+ style_footer();
1875
+}
18291876
--- src/timeline.c
+++ src/timeline.c
@@ -1824,5 +1824,52 @@
1824 @ <a href="%s(g.zTop)/timeline?p=%S(zUuid)&amp;d=%S(zUuid)">%S(zUuid)</a>
1825 }
1826 db_finalize(&q);
1827 style_footer();
1828 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1829
--- src/timeline.c
+++ src/timeline.c
@@ -1824,5 +1824,52 @@
1824 @ <a href="%s(g.zTop)/timeline?p=%S(zUuid)&amp;d=%S(zUuid)">%S(zUuid)</a>
1825 }
1826 db_finalize(&q);
1827 style_footer();
1828 }
1829
1830 /*
1831 ** WEBPAGE: activity
1832 **
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>
1855 @ <th><!-- relative commits graph --></th>
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 nCommitCount += nCount;
1862 char rowClass = ++nRowNumber % 2;
1863 @<tr class='row%d(rowClass)'>
1864 @ <td>
1865 @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
1866 @ </td><td>%d(nCount)</td>
1867 @ <td>
1868 @ <div class='activity-graph-line' style='height:16px; width:%d(nSize)px;'>
1869 @ </div></td>
1870 @</tr>
1871 }
1872 @ </tbody></table>
1873 @ Total commits: %d(nCommitCount)
1874 style_footer();
1875 }
1876

Keyboard Shortcuts

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