Fossil

Check-in [d0ce29b031]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Attempt to make the stats_report?type=byuser tabls sortable by clicking on the column labels. Only works for the "User" column. Further debugging needed.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d0ce29b031e148aa0724d89383eb6a2fd3ba078a
User & Date: drh 2013-05-05 20:05:48.861
Context
2013-05-05
23:49
Implement sorting by event count on some of the stats_report pages. ... (check-in: 10aaf0c971 user: drh tags: trunk)
20:05
Attempt to make the stats_report?type=byuser tabls sortable by clicking on the column labels. Only works for the "User" column. Further debugging needed. ... (check-in: d0ce29b031 user: drh tags: trunk)
19:42
Make the new CSS for the stats_report appear at the end of legacy CSS that does not define the same elements. ... (check-in: 21454dda94 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/report.c.
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
** the id zTableId by clicking.
**
** The javascript is derived from:
**
**     http://www.webtoolkit.info/sortable-html-table.html
**
*/
static void output_table_sorting_javascript(const char *zTableId){
  @ <script>
  @ function SortableTable(tableEl){
  @   this.tbody = tableEl.getElementsByTagName('tbody');
  @   this.sort = function (cell) {
  @     var column = cell.cellIndex;
  @     this.sortIndex = column;
  @     var newRows = new Array();







|







922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
** the id zTableId by clicking.
**
** The javascript is derived from:
**
**     http://www.webtoolkit.info/sortable-html-table.html
**
*/
void output_table_sorting_javascript(const char *zTableId){
  @ <script>
  @ function SortableTable(tableEl){
  @   this.tbody = tableEl.getElementsByTagName('tbody');
  @   this.sort = function (cell) {
  @     var column = cell.cellIndex;
  @     this.sortIndex = column;
  @     var newRows = new Array();
Changes to src/timeline.c.
1868
1869
1870
1871
1872
1873
1874
1875

1876
1877
1878
1879
1880
1881
1882
  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) ){







|
>







1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
  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' id='statsTable'>
  @ <thead>
  @ <th>%s(zTimeLabel)</th>
  @ <th>Events</th>
  @ <th><!-- relative commits graph --></th>
  @ </thead><tbody>
  blob_reset(&header);
  while( SQLITE_ROW == db_step(&query) ){
1907
1908
1909
1910
1911
1912
1913
1914

1915
1916
1917
1918
1919
1920

1921
1922
1923
1924
1925
1926
1927
    }
    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.
    */







|
>





|
>







1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
    }
    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.
    */
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
               "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.
**







|
>
|



|












|
>














>







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
               "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' id='statsTable'>
  @ <thead><tr>
  @ <th>User</th>
  @ <th>Events</th>
  @ <th><!-- relative commits graph --></th>
  @ </tr></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);
  output_table_sorting_javascript("statsTable");
}

/*
** WEBPAGE: stats_report
**
** Shows activity reports for the repository.
**