Changeset 556


Ignore:
Timestamp:
Jan 16, 2008, 2:35:00 PM (14 years ago)
Author:
Peter Johansson
Message:

Fixing statistics bugs and links on first page

Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r538 r556  
    8686    is.close();
    8787  }
    88   else
    89     config.load();
    9088 
    9189  // write configuration
     
    171169                                   +tree->name()+"'");
    172170    print_css("svndigest.css");
    173     const Stats& classic = stats["classic"];
    174     print_main_page(tree->name(), tree->log(), classic, tree->url());
     171    print_main_page(tree->name(), tree->log(), stats, tree->url());
    175172    // create structure StatsType/Author/LineType
    176173    for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
  • trunk/lib/Configuration.cc

    r523 r556  
    263263  Configuration& Configuration::instance(void)
    264264  {
    265     if (!instance_)
     265    if (!instance_){
    266266      instance_ = new Configuration;
     267      instance_->load();
     268    }
    267269    return *instance_;
    268270  }
     
    412414      translate(word, *iter);
    413415    }
    414 
    415416  }
    416417
  • trunk/lib/Configuration.h

    r523 r556  
    5858
    5959    ///
    60     /// @brief load deafult configuration
    61     ///
    62     void load(void);
    63 
    64     ///
    6560    /// throw if stream is not a valid config
    6661    ///
     
    9186    // assignment not implemented because assignment is always self-assignment
    9287    Configuration& operator=(const Configuration&);
     88    // destructor not implemented
     89    ~Configuration(void);
    9390
    9491    friend std::ostream& operator<<(std::ostream&, const Configuration&);
     
    10097    bool equal_false(const std::string&) const;
    10198    bool equal_true(const std::string&) const;
     99    ///
     100    /// @brief load deafult configuration
     101    ///
     102    void load(void);
     103
    102104    void set_default(void);
    103105    /**
  • trunk/lib/LineTypeParser.cc

    r552 r556  
    5252        // check if line is end of copyright statement, i.e. contains
    5353        // no alphanumerical character (except in copyright_prefix).
     54        post_copyright_ = true;
    5455        for (size_t i=0; i<line.size()&&post_copyright_; ++i)
    5556          if (isalnum(line[i]) &&
  • trunk/lib/Stats.cc

    r552 r556  
    8888      std::vector<u_int>& other = other_stats()[*iter];
    8989      accumulate(other);
     90      std::vector<u_int>& copyright = copyright_stats()[*iter];
     91      accumulate(copyright);
    9092    }
    9193  }
     
    98100    add_author(user);
    99101
    100     // Peter remove repeat
     102    // FIXME: Peter, remove repeat
    101103    std::vector<u_int>& code = code_stats()[user];
    102104    if (code.size() < rev+1){
     
    134136    else if (lt == LineTypeParser::other)
    135137      other[rev]+=n;
     138
     139    std::vector<u_int>& copy = copyright_stats()[user];
     140    if (copy.size() < rev+1){
     141      copy.reserve(revision() + 1);
     142      copy.insert(copy.end(), rev - copy.size(), 0);
     143      if (lt == LineTypeParser::copyright)
     144        copy.push_back(n);
     145      else
     146        copy.push_back(0);
     147    }
     148    else if (lt == LineTypeParser::copyright)
     149      copy[rev]+=n;
    136150  }
    137151
  • trunk/lib/first_page.cc

    r546 r556  
    5151
    5252  void print_main_page(const std::string& dir, const SVNlog& log,
    53                        const Stats& stats, std::string url)
     53                       const StatsCollection& stats, std::string url)
    5454  {
    5555    std::string filename="index.html";
     
    6969      latest_commit.push_back(log.latest_commit(*i));
    7070
    71     print_summary_plot(os, stats);
     71    print_summary_plot(os, stats["classic"]);
    7272    print_general_information(os, log, authors.size(), url);
    7373    sort(latest_commit.begin(), latest_commit.end(), GreaterRevision());
    74     print_authors(os, latest_commit, stats);
    75     print_recent_logs(os, log);
     74    print_authors(os, latest_commit, stats["classic"]);
     75    print_recent_logs(os, log, stats);
    7676    os << "<hr width=100% />";
    7777    print_footer(os);
     
    130130       <<"</tr>";
    131131
    132     std::string timefmt("%b %d %H:%M:%S %Y");
     132    std::string timefmt("%Y %b %d %H:%M:%S");
    133133    using namespace std;
    134134    for (vector<Commitment>::const_iterator i=lc.begin(); i!=lc.end(); ++i) {
     
    158158
    159159
    160   void print_recent_logs(std::ostream& os, const SVNlog& log)
     160  void print_recent_logs(std::ostream& os, const SVNlog& log,
     161                         const StatsCollection& stats)
    161162  {
    162163    os << "<div class=\"main\">\n"
     
    172173    assert(log.author().size()==log.message().size());
    173174    assert(log.author().size()==log.revision().size());
    174     os << "<tr><td>Author</td><td>Date</td><td>Rev</td><td>Message</td></tr>\n";
     175    os << "<tr><td>Author</td><td>Date</td><td>Rev</td><td>Added</td>"
     176       << "<td>Removed</td><td>Message</td></tr>\n";
    175177    HtmlStream hs(os);
    176     std::string timefmt("%b %d %H:%M:%S %Y");
     178    std::string timefmt("%Y %b %d %H:%M:%S");
    177179    const size_t maxlength = 80;
    178180    const Configuration& conf = Configuration::instance();
     
    187189      os << "</td>";
    188190      os << "<td>";
     191      int added = stats["add"](LineTypeParser::total, "all", *r) -
     192        stats["add"](LineTypeParser::total, "all", *r - 1);
     193      os << added;
     194      os << "</td>";
     195      os << "<td>";
     196      os << added - (stats["blame"](LineTypeParser::total, "all", *r) -
     197                     stats["blame"](LineTypeParser::total, "all", *r - 1));
     198      os << "</td>";
     199      os << "<td>";
    189200      std::string mess = *m;
    190201      // replace newlines with space
  • trunk/lib/first_page.h

    r519 r556  
    3434  class Commitment;
    3535  class Stats;
     36  class StatsCollection;
    3637  class SVNlog;
    3738
     
    4950  /// @brief print main page
    5051  ///
    51   void print_main_page(const std::string&, const SVNlog&, const Stats&,
    52                        std::string url);
     52  void print_main_page(const std::string&, const SVNlog&,
     53                       const StatsCollection&, std::string url);
    5354   
    54   void print_recent_logs(std::ostream&, const SVNlog& log);
     55  void print_recent_logs(std::ostream&, const SVNlog& log,
     56                         const StatsCollection&);
    5557   
    5658  void print_summary_plot(std::ostream&, const Stats& stats);
  • trunk/lib/html_utility.cc

    r550 r556  
    7878                    const std::string& stats)
    7979  {
     80    os << "<!-- Generated by " << PACKAGE_STRING << "-->\n";
    8081    os << "<!DOCTYPE html\n"
    8182       << "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
     
    146147    if (item_local=="none")
    147148      item_local = "total";
     149    if (item_local=="main")
     150      item_local = "total";
    148151
    149152    if (stats=="classic")
  • trunk/test/Makefile.am

    r547 r556  
    44
    55# Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2008 Peter Johansson
    67#
    78# This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    2223# 02111-1307, USA.
    2324
    24 check_PROGRAMS = date gnuplot_pipe parser trac utility_test
     25check_PROGRAMS = config_test date gnuplot_pipe parser trac utility_test
     26
     27# these tests are only for developers since we do not distribute test repository
     28if HAVE_SVN_WC
     29check_PROGRAMS += stats_test
     30endif
    2531
    2632TESTS = $(check_PROGRAMS)
     
    3440AM_CPPFLAGS = -I@top_srcdir@/lib
    3541
     42config_test_SOURCES = config_test.cc
    3643date_SOURCES = date.cc
    3744gnuplot_pipe_SOURCES = gnuplot_pipe.cc
    3845parser_SOURCES = parser.cc
     46stats_test_SOURCES = stats_test.cc
    3947trac_SOURCES = trac.cc
    4048utility_test_SOURCES = utility_test.cc
    4149
    42 rootdir = $(abs_srcdir)/toy_project
     50toy_project = toy_project
     51
     52# some tests need the test repo to be checked out
     53stats_test_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
     54
     55rootdir = $(abs_srcdir)/$(toy_project)
    4356targetdir = $(abs_builddir)/generated_output
    4457repodir = $(abs_srcdir)/repo/trunk
     
    6073  @echo creating $@
    6174
    62 test_repo.sh: test_repo.sh.in Makefile
     75test_repo.sh: test_repo.sh.in Makefile $(toy_project)
    6376  @$(do_subst) < $< > $@
    6477  @chmod +x $@
    6578  @echo creating $@
    6679
     80$(toy_project):
     81  echo Checking out test repository && \
     82  svn checkout file://$(repodir) $(toy_project);
     83
    6784clean-local:
    6885  rm -rf *.png *.tmp *~ check_repo_status.sh test_repo.sh \
    6986  $(targetdir) 
    70 
  • trunk/test/parser.cc

    r552 r556  
    4343{
    4444  using namespace theplu::svndigest;
    45   os << "Testing: " << file << std::endl;
    4645  LineTypeParser parser(file);
    4746  std::ifstream is(file.c_str());
  • trunk/test/test_repo.sh.in

    r540 r556  
    2121# 02111-1307, USA.
    2222
    23 # test repository does not exist and need to be checked out
    24 if [ ! -d %rootdir% ]; then
    25     repodir=`cd "%abs_srcdir%" && pwd`;
    26     repodir=$repodir"/repo/trunk";
    27     svn checkout file://$repodir %rootdir%;
    28 fi
    29 
    3023svn update %rootdir% > /dev/null;
    3124
Note: See TracChangeset for help on using the changeset viewer.