Check-in [8adf0db1c8]
Not logged in

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

Overview
Comment:Re-added the 'Total Events' label to /stats_report, but did it outside the table so that the JS sorting does not hose it. Replaced a double calculation with an equivalent int one.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8adf0db1c8aa3ac217dd7459703c5ddd7ebe22f2
User & Date: stephan 2013-07-20 17:04:05
Context
2013-07-21
16:38
Expanded "search" command flags: (-limit|-n #) limits the number of results and (-all|-a) disables the "lopping off" of the bottom fraction of the results. check-in: 1064dfac12 user: stephan tags: trunk
16:29
rebase Leaf check-in: 54aef59916 user: jan.nijtmans tags: cleanX
2013-07-20
17:04
Re-added the 'Total Events' label to /stats_report, but did it outside the table so that the JS sorting does not hose it. Replaced a double calculation with an equivalent int one. check-in: 8adf0db1c8 user: stephan tags: trunk
16:43
Removed the 500px baseline for /stats_report calculations, refactored the bars to now use percentage widths. check-in: 674a24a360 user: stephan tags: trunk
Changes

Changes to src/timeline.c.

1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
....
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
....
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
....
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
....
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
....
2196
2197
2198
2199
2200
2201
2202

2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
  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 */
  int nMaxEvents  = 1;            /* for calculating length of graph bars. */

  blob_appendf(&header, "Timeline Events by year%s",
................................................................................
    }
  }
  db_reset(&query);
  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 = nCount
      ? (int)(1.0 * nCount / nMaxEvents * 100)
      : 1;
    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;
................................................................................
    }

    /*
      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>    
  }
#if 0
  rowClass = ++nRowNumber % 2;
  @ <tr class='row%d(rowClass)'>
  @   <td colspan='3'>Total events: %d(nEventTotal)</td>
  @ </tr>
#endif
  @ </tbody></table>
  db_finalize(&query);



  if( !includeMonth ){
    output_table_sorting_javascript("statsTable","tnx");
  }
}

/*
** Implements the "byuser" view for /stats_report.
................................................................................
    }
  }
  db_reset(&query);
  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 = nCount
      ? (int)(1.0 * nCount / nMaxEvents * 100)
      : 0;
    if(!nCount) continue /* arguable! Possible? */;
    rowClass = ++nRowNumber % 2;
    nEventTotal += nCount;
    @<tr class='row%d(rowClass)'>
    @ <td>
    @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
................................................................................
      }
    }
    db_reset(&stWeek);
    while( SQLITE_ROW == db_step(&stWeek) ){
      char const * zWeek = db_column_text(&stWeek,0);
      int const nCount = db_column_int(&stWeek,1);
      int const nSize = nCount
        ? (int)(1.0 * nCount / nMaxEvents * 100)
        : 0;
      total += nCount;
      cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
      cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
                 g.zTop, zYear, zWeek, nCount);
      if(zUserName && *zUserName){
        cgi_printf("&u=%t",zUserName);
................................................................................
                   "style='height:16px;width:%d%%;'></div>",
                   nSize);
      }
      cgi_printf("</td></tr>");
    }
    db_finalize(&stWeek);
    free(zDefaultYear);

    if(total){
      cgi_printf("<tr class='row%d'>", ++rowCount%2);
      cgi_printf("<td colspan='2'>Total events:</td><td>%d</td>",
                 total);
      cgi_printf("</tr>");
    }
    cgi_printf("</tbody></table>");
    output_table_sorting_javascript("statsTable","tnx");
  }
}

/*
** WEBPAGE: stats_report
**







|







 







|







 







|








<
<
<
<
<
<

<
>
>
>







 







|







 







|







 







>

<
|

<

<







1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
....
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
....
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
....
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
....
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
....
2192
2193
2194
2195
2196
2197
2198
2199
2200

2201
2202

2203

2204
2205
2206
2207
2208
2209
2210
  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 event 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 */
  int nMaxEvents  = 1;            /* for calculating length of graph bars. */

  blob_appendf(&header, "Timeline Events by year%s",
................................................................................
    }
  }
  db_reset(&query);
  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 = nCount
      ? (int)(100 * nCount / nMaxEvents)
      : 1;
    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;
................................................................................
    }

    /*
      Potential improvement: calculate the min/max event counts and
      use percent-based graph bars.
    */
  }
  db_finalize(&query);
  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>    
  }






  @ </tbody></table>

  if(nEventTotal){
    @ <br><div>Total events: %d(nEventTotal)</div>
  }
  if( !includeMonth ){
    output_table_sorting_javascript("statsTable","tnx");
  }
}

/*
** Implements the "byuser" view for /stats_report.
................................................................................
    }
  }
  db_reset(&query);
  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 = nCount
      ? (int)(100 * nCount / nMaxEvents)
      : 0;
    if(!nCount) continue /* arguable! Possible? */;
    rowClass = ++nRowNumber % 2;
    nEventTotal += nCount;
    @<tr class='row%d(rowClass)'>
    @ <td>
    @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
................................................................................
      }
    }
    db_reset(&stWeek);
    while( SQLITE_ROW == db_step(&stWeek) ){
      char const * zWeek = db_column_text(&stWeek,0);
      int const nCount = db_column_int(&stWeek,1);
      int const nSize = nCount
        ? (int)(100 * nCount / nMaxEvents)
        : 0;
      total += nCount;
      cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
      cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
                 g.zTop, zYear, zWeek, nCount);
      if(zUserName && *zUserName){
        cgi_printf("&u=%t",zUserName);
................................................................................
                   "style='height:16px;width:%d%%;'></div>",
                   nSize);
      }
      cgi_printf("</td></tr>");
    }
    db_finalize(&stWeek);
    free(zDefaultYear);
    cgi_printf("</tbody></table>");
    if(total){

      cgi_printf("<br><div>Total events: %d</div>",
                 total);

    }

    output_table_sorting_javascript("statsTable","tnx");
  }
}

/*
** WEBPAGE: stats_report
**