Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Added view=byuser param to /stats_report. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
08b9b5b0d9e9cf885b140e622ca58166 |
| User & Date: | stephan 2013-05-05 13:19:33.876 |
Context
|
2013-05-05
| ||
| 13:26 | /stats_report now shows report list by default. Removed an unused variable. ... (check-in: 6e42254616 user: stephan tags: trunk) | |
| 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) | |
Changes
Changes to src/timeline.c.
| ︙ | ︙ | |||
1834 1835 1836 1837 1838 1839 1840 | /* ** 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. */ | | | | 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
/*
** 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_by_month_year(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 */
|
| ︙ | ︙ | |||
1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 | 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: ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | | | | > > > > > | 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 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 |
rowClass = ++nRowNumber % 2;
@ <tr class='row%d(rowClass)'>
@ <td colspan='3'>Total events: %d(nEventTotal)</td>
@ </tr>
@ </tbody></table>
db_finalize(&query);
}
void stats_report_by_user(){
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 */
blob_append(&sql,
"SELECT user, "
"COUNT(*) AS eventCount "
"FROM event "
"GROUP BY user ORDER BY user",
-1);
db_prepare(&query, blob_str(&sql));
blob_reset(&sql);
@ <h1>Timeline Events by User</h1>
@ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
@ <thead>
@ <th>User</th>
@ <th>Events</th>
@ <th><!-- relative commits graph --></th>
@ </thead><tbody>
while( SQLITE_ROW == db_step(&query) ){
char const * zUser = db_column_text(&query, 0);
int const nCount = db_column_int(&query, 1);
int const nSize = 1+((nPixelsPerEvent * nCount) / 10);
if(!nCount) continue;
rowClass = ++nRowNumber % 2;
nEventTotal += nCount;
@<tr class='row%d(rowClass)'>
@ <td>
@ <a href="?view=byyear&user=%h(zUser)" target="_new">%s(zUser)</a>
@ </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.
*/
}
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, byuser
** 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");
int whichReport = 0;
url_initialize(&url, "stats_report");
/* We have to figure out which report to run before continuing so
that we can add (or not) the user= param to the buttons in a sane
manner.
*/
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);
timeline_submenu(&url, "By User", "view", "byuser", "user");
url_reset(&url);
style_header("Activity Reports");
if(0==fossil_strcmp(zView,"byyear")){
stats_report_by_month_year(0, zUserName);
}else if(0==fossil_strcmp(zView,"bymonth")){
stats_report_by_month_year(1, zUserName);
}else if(0==fossil_strcmp(zView,"byweek")){
@ TODO: by-week report.
}else if(0==fossil_strcmp(zView,"byuser")){
stats_report_by_user();
}else{
@ TODO: show report select list.
}
style_footer();
}
|