Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Replaced /activity with /stats_report. Supported by-month and by-year reports. Use user=NAME to limit report to that user (no UI yet for user selection). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
0de658266004a9436119e852a6b144e3 |
| User & Date: | stephan 2013-05-05 12:56:03.166 |
Context
|
2013-05-05
| ||
| 13:19 | Added view=byuser param to /stats_report. ... (check-in: 08b9b5b0d9 user: stephan tags: trunk) | |
| 12:56 | Replaced /activity with /stats_report. Supported by-month and by-year reports. Use user=NAME to limit report to that user (no UI yet for user selection). ... (check-in: 0de6582660 user: stephan tags: trunk) | |
|
2013-05-04
| ||
| 21:47 | Minor cosmetic tweaks to /activity page. Now counts all events, not just commits. ... (check-in: 2889bfb227 user: stephan tags: trunk) | |
Changes
Changes to src/style.c.
| ︙ | ︙ | |||
611 612 613 614 615 616 617 |
@ /* The label/value pairs on (for example) the ci page */
@ table.label-value th {
@ vertical-align: top;
@ text-align: right;
@ padding: 0.2ex 2ex;
@ }
@
| | | | | > > > | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
@ /* The label/value pairs on (for example) the ci page */
@ table.label-value th {
@ vertical-align: top;
@ text-align: right;
@ padding: 0.2ex 2ex;
@ }
@
@ /* .statistics-report-* are for the /stats_report views */
@ .statistics-report-graph-line {
@ background-color: #446979;
@ }
@ .statistics-report-table-events th {
@ padding: 0 1em 0 1em;
@ }
@ .statistics-report-table-events td {
@ padding: 0.1em 1em 0.1em 1em;
@ }
@ .statistics-report-row-year {
@ text-align: left;
@ }
@ /* row0 and row1 are for alternating table row colors */
@ tr.row0 {
@ background: #fff;
@ }
@ tr.row1 {
@ background-color: #dadada;
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
1824 1825 1826 1827 1828 1829 1830 1831 1832 |
const char *zUuid = db_column_text(&q, 0);
@ <li>
@ <a href="%s(g.zTop)/timeline?p=%S(zUuid)&d=%S(zUuid)">%S(zUuid)</a>
}
db_finalize(&q);
style_footer();
}
/*
| > > < > > > > | < | > | | | | > > > > > > > > > | > | | | > > > > > > > | | > > > | | | > | | > > > > > > > > | > > > > > > > > > > > > > > | > > | > > > | | > > > > > > > > | | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 |
const char *zUuid = db_column_text(&q, 0);
@ <li>
@ <a href="%s(g.zTop)/timeline?p=%S(zUuid)&d=%S(zUuid)">%S(zUuid)</a>
}
db_finalize(&q);
style_footer();
}
/*
** Implements the "byyear" and "bymonth" reports for /stats_report.
** If includeMonth is true then it generates the "bymonth" report,
** else the "byyear" report. If zUserName is not NULL and not empty
** then the report is restricted to events created by the named user
** account.
*/
static void stats_report_bymonthyear(char includeMonth,
char const * zUserName){
Stmt query = empty_Stmt;
int const nPixelsPerEvent = 1; /* for sizing the "graph" part */
int nRowNumber = 0; /* current TR number */
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
Blob sql = empty_blob; /* SQL */
char const * zTimeLabel = includeMonth ? "Year/Month" : "Year";
char zPrevYear[5] = {0}; /* For keeping track of when
we change years while looping */
int nEventsPerYear = 0; /* Total even count for the
current year */
char showYearTotal = 0; /* Flag telling us when to show
the per-year event totals */
Blob header = empty_blob; /* Page header text */
blob_appendf(&header, "Timeline Events by %s", zTimeLabel);
blob_appendf(&sql,
"SELECT substr(date(mtime),1,%d) AS timeframe, "
"count(*) AS eventCount "
"FROM event ",
includeMonth ? 7 : 4);
if(zUserName&&*zUserName){
blob_appendf(&sql, " WHERE user=%Q ", zUserName);
blob_appendf(&header," for user %q", zUserName);
}
blob_append(&sql,
" GROUP BY timeframe"
" ORDER BY timeframe DESC",
-1);
db_prepare(&query, blob_str(&sql));
blob_reset(&sql);
@ <h1>%b(&header)</h1>
@ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
@ <thead>
@ <th>%s(zTimeLabel)</th>
@ <th>Events</th>
@ <th><!-- relative commits graph --></th>
@ </thead><tbody>
blob_reset(&header);
while( SQLITE_ROW == db_step(&query) ){
char const * zTimeframe = db_column_text(&query, 0);
int const nCount = db_column_int(&query, 1);
int const nSize = 1 + ((nPixelsPerEvent * nCount)
/ (includeMonth ? 1 : 10));
showYearTotal = 0;
if(includeMonth){
/* For Month/year view, add a separator for each distinct year. */
if(!*zPrevYear ||
(0!=fossil_strncmp(zPrevYear,zTimeframe,4))){
showYearTotal = *zPrevYear;
if(showYearTotal){
rowClass = ++nRowNumber % 2;
@ <tr class='row%d(rowClass)'>
@ <td></td>
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
@</tr>
}
nEventsPerYear = 0;
memcpy(zPrevYear,zTimeframe,4);
rowClass = ++nRowNumber % 2;
@ <tr class='row%d(rowClass)'>
@ <th colspan='3' class='statistics-report-row-year'>%s(zPrevYear)</th>
@ </tr>
}
}
rowClass = ++nRowNumber % 2;
nEventTotal += nCount;
nEventsPerYear += nCount;
@<tr class='row%d(rowClass)'>
@ <td>
if(includeMonth){
@ <a href="%s(g.zTop)/timeline?ym=%s(zTimeframe)&n=%d(nCount)" target="_new">%s(zTimeframe)</a>
}else {
@ %s(zTimeframe)
}
@ </td><td>%d(nCount)</td>
@ <td>
@ <div class='statistics-report-graph-line' style='height:16px; width:%d(nSize)px;'>
@ </div></td>
@</tr>
/*
Potential improvement: calculate the min/max event counts and
use percent-based graph bars.
*/
}
if(includeMonth && !showYearTotal && *zPrevYear){
/* Add final year total separator. */
rowClass = ++nRowNumber % 2;
@ <tr class='row%d(rowClass)'>
@ <td></td>
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
@</tr>
}
rowClass = ++nRowNumber % 2;
@ <tr class='row%d(rowClass)'>
@ <td colspan='3'>Total events: %d(nEventTotal)</td>
@ </tr>
@ </tbody></table>
db_finalize(&query);
}
/*
** WEBPAGE: stats_report
**
** Shows activity reports for the repository.
**
** Query Parameters:
**
** view=REPORT_NAME Valid values: bymonth, byyear
** user=NAME Restricts statistics to the given user
*/
void stats_report_page(){
HQuery url; /* URL for various branch links */
char const * zView = PD("view","bymonth"); /* Which view/report to show. */
char const *zUserName = P("user");
url_initialize(&url, "stats_report");
if(zUserName && *zUserName){
url_add_parameter(&url,"user", zUserName);
}
timeline_submenu(&url, "By Year", "view", "byyear", 0);
timeline_submenu(&url, "By Month", "view", "bymonth", 0);
url_reset(&url);
style_header("Activity Reports");
if(0==fossil_strcmp(zView,"bymonth")){
stats_report_bymonthyear(1, zUserName);
}else if(0==fossil_strcmp(zView,"byyear")){
stats_report_bymonthyear(0, zUserName);
}else if(0==fossil_strcmp(zView,"byweek")){
@ TODO: by-week report.
}
style_footer();
}
|
Changes to src/url.c.
| ︙ | ︙ | |||
369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
** Initialize the URL object.
*/
void url_initialize(HQuery *p, const char *zBase){
blob_zero(&p->url);
p->zBase = zBase;
p->nParam = 0;
}
/*
** Add a fixed parameter to an HQuery.
*/
void url_add_parameter(HQuery *p, const char *zName, const char *zValue){
assert( p->nParam < count(p->azName) );
assert( p->nParam < count(p->azValue) );
| > > > > > > > > > | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
** Initialize the URL object.
*/
void url_initialize(HQuery *p, const char *zBase){
blob_zero(&p->url);
p->zBase = zBase;
p->nParam = 0;
}
/*
** Resets the given URL object, deallocating any memory
** it uses.
*/
void url_reset(HQuery *p){
blob_reset(&p->url);
url_initialize(p, p->zBase);
}
/*
** Add a fixed parameter to an HQuery.
*/
void url_add_parameter(HQuery *p, const char *zName, const char *zValue){
assert( p->nParam < count(p->azName) );
assert( p->nParam < count(p->azValue) );
|
| ︙ | ︙ |