Fossil

Check-in [d16c09f8c1]
Login

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

Overview
Comment:Added a missing db_finalize(). Replaced a TODO text with the corresponding code. Changed timeline page header when the ym=YYYY-MM param is set.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d16c09f8c1069650e621e3244fa09453b0d48275
User & Date: stephan 2013-05-04 21:36:39.040
Context
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)
21:36
Added a missing db_finalize(). Replaced a TODO text with the corresponding code. Changed timeline page header when the ym=YYYY-MM param is set. ... (check-in: d16c09f8c1 user: stephan tags: trunk)
20:45
Fixed a C++-ism. Added a note for a potential improvement. ... (check-in: fd74734bf8 user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/timeline.c.
1348
1349
1350
1351
1352
1353
1354


1355
1356
1357
1358
1359
1360
1361
1362
    }else{
      blob_appendf(&sql, " ORDER BY event.mtime DESC");
    }
    blob_appendf(&sql, " LIMIT %d", nEntry);
    db_multi_exec("%s", blob_str(&sql));

    n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");


    if( zAfter==0 && zBefore==0 && zCirca==0 ){
      blob_appendf(&desc, "%d most recent %ss", n, zEType);
    }else{
      blob_appendf(&desc, "%d %ss", n, zEType);
    }
    if( zUses ){
      char *zFilenames = names_of_file(zUses);
      blob_appendf(&desc, " using file %s version %z%S</a>", zFilenames,







>
>
|







1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
    }else{
      blob_appendf(&sql, " ORDER BY event.mtime DESC");
    }
    blob_appendf(&sql, " LIMIT %d", nEntry);
    db_multi_exec("%s", blob_str(&sql));

    n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
    if( zYearMonth ){
      blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
    }else if( zAfter==0 && zBefore==0 && zCirca==0 ){
      blob_appendf(&desc, "%d most recent %ss", n, zEType);
    }else{
      blob_appendf(&desc, "%d %ss", n, zEType);
    }
    if( zUses ){
      char *zFilenames = names_of_file(zUses);
      blob_appendf(&desc, " using file %s version %z%S</a>", zFilenames,
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
** WEBPAGE: activity
**
** Shows an activity report for the repository.
*/
void activity_page(){
  Stmt query = empty_Stmt;
  int const nPixelsPerCommit = 2;
  int const nTimelineCount = 200;
  int nRowNumber = 0;
  int nCommitCount = 0;
  style_header("Repository Activity");

  db_prepare(&query,
              "SELECT substr(date(mtime),1,7) AS Month, "
              "count(*) AS Commits FROM event "
              "WHERE type='ci' "
              "GROUP BY Month "
              "ORDER BY Month DESC", -1);

  @ <h1>Commits by Month</h1>
  @ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'>
  @ <thead>
  @ <th>Year/Month</th>
  @ <th>Commits</th>
  @ <th><!-- relative commits graph --></th>
  @ </thead><tbody>
  while( SQLITE_ROW == db_step(&query) ){
    char const * zMonth = db_column_text(&query, 0);
    int const nCount = db_column_int(&query, 1);
    int const nSize = nPixelsPerCommit * nCount;
    char rowClass = ++nRowNumber % 2;




    nCommitCount += nCount;
    /**
     * Potential improvement: set nCount to exactly the number of
     * events for the month. Keep in mind that this query only counts
     * 'ci' events but we link to the timeline for all event types.
     */
    @<tr class='row%d(rowClass)'>
    @ <td>
    @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
    @ </td><td>%d(nCount)</td>
    @ <td>
    @ <div class='activity-graph-line' style='height:16px; width:%d(nSize)px;'>
    @ </div></td>
    @</tr>
  }
  @ </tbody></table>
  @ Total commits: %d(nCommitCount)

  style_footer();
}







<



<






<











|
>
>
>
>

<
<
<
<
<











>


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
** WEBPAGE: activity
**
** Shows an activity report for the repository.
*/
void activity_page(){
  Stmt query = empty_Stmt;
  int const nPixelsPerCommit = 2;

  int nRowNumber = 0;
  int nCommitCount = 0;
  style_header("Repository Activity");

  db_prepare(&query,
              "SELECT substr(date(mtime),1,7) AS Month, "
              "count(*) AS Commits FROM event "
              "WHERE type='ci' "
              "GROUP BY Month "
              "ORDER BY Month DESC", -1);

  @ <h1>Commits by Month</h1>
  @ <table class='activity-table-commits-by-month' border='0' cellpadding='2' cellspacing='0'>
  @ <thead>
  @ <th>Year/Month</th>
  @ <th>Commits</th>
  @ <th><!-- relative commits graph --></th>
  @ </thead><tbody>
  while( SQLITE_ROW == db_step(&query) ){
    char const * zMonth = db_column_text(&query, 0);
    int const nCount = db_column_int(&query, 1);
    int const nSize = nPixelsPerCommit * nCount;
    char const rowClass = ++nRowNumber % 2;
    int const nTimelineCount =
      db_int(200, "SELECT COUNT(*) FROM event WHERE "
             "substr(date(mtime),1,7)=%Q",
             zMonth);
    nCommitCount += nCount;





    @<tr class='row%d(rowClass)'>
    @ <td>
    @ <a href="%s(g.zTop)/timeline?ym=%s(zMonth)&n=%d(nTimelineCount)" target="_new">%s(zMonth)</a>
    @ </td><td>%d(nCount)</td>
    @ <td>
    @ <div class='activity-graph-line' style='height:16px; width:%d(nSize)px;'>
    @ </div></td>
    @</tr>
  }
  @ </tbody></table>
  @ Total commits: %d(nCommitCount)
  db_finalize(&query);
  style_footer();
}