Package com.gitblit.models

Examples of com.gitblit.models.Metric


    if (user == null) {
      user = UserModel.ANONYMOUS;
    }

    List<Metric> metrics = null;
    Metric metricsTotal = null;
    if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
      metrics = app().repositories().getRepositoryDefaultMetrics(model, r);
      metricsTotal = metrics.remove(0);
    }
View Full Code Here


      // aggregate author metrics
      for (Map.Entry<String, Metric> entry : activity.getAuthorMetrics().entrySet()) {
        String author = entry.getKey();
        if (!authorMetrics.containsKey(author)) {
          authorMetrics.put(author, new Metric(author));
        }
        authorMetrics.get(author).count += entry.getValue().count;
      }

      // aggregate repository metrics
      for (Map.Entry<String, Metric> entry : activity.getRepositoryMetrics().entrySet()) {
        String repository = StringUtils.stripDotGit(entry.getKey());
        if (!repositoryMetrics.containsKey(repository)) {
          repositoryMetrics.put(repository, new Metric(repository));
        }
        repositoryMetrics.get(repository).count += entry.getValue().count;
      }
    }
View Full Code Here

    for (RefLogEntry change : recentChanges) {

      // aggregate repository metrics
      String repository = StringUtils.stripDotGit(change.repository);
      if (!repositoryMetrics.containsKey(repository)) {
        repositoryMetrics.put(repository, new Metric(repository));
      }
      repositoryMetrics.get(repository).count += 1;

      for (RepositoryCommit commit : change.getCommits()) {
        totalCommits++;
        String author = StringUtils.removeNewlines(commit.getAuthorIdent().getName());
        String authorName = author.toLowerCase();
        String authorEmail = StringUtils.removeNewlines(commit.getAuthorIdent().getEmailAddress()).toLowerCase();
        if (!authorExclusions.contains(authorName) && !authorExclusions.contains(authorEmail)) {
          if (!authorMetrics.containsKey(author)) {
            authorMetrics.put(author, new Metric(author));
          }
          authorMetrics.get(author).count += 1;
        }
      }
    }
View Full Code Here

    if (StringUtils.isEmpty(objectId)) {
      add(new Label("branchTitle", getRepositoryModel().HEAD));
    } else {
      add(new Label("branchTitle", objectId));
    }
    Metric metricsTotal = null;
    List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
    metricsTotal = metrics.remove(0);
    if (metricsTotal == null) {
      add(new Label("branchStats", ""));
    } else {
View Full Code Here

   * @param timezone
   * @return list of metrics
   */
  public static List<Metric> getDateMetrics(Repository repository, String objectId,
      boolean includeTotal, String dateFormat, TimeZone timezone) {
    Metric total = new Metric("TOTAL");
    final Map<String, Metric> metricMap = new HashMap<String, Metric>();

    if (JGitUtils.hasCommits(repository)) {
      final List<RefModel> tags = JGitUtils.getTags(repository, true, -1);
      final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();
      for (RefModel tag : tags) {
        tagMap.put(tag.getReferencedObjectId(), tag);
      }
      RevWalk revWalk = null;
      try {
        // resolve branch
        ObjectId branchObject;
        if (StringUtils.isEmpty(objectId)) {
          branchObject = JGitUtils.getDefaultBranch(repository);
        } else {
          branchObject = repository.resolve(objectId);
        }

        revWalk = new RevWalk(repository);
        RevCommit lastCommit = revWalk.parseCommit(branchObject);
        revWalk.markStart(lastCommit);

        DateFormat df;
        if (StringUtils.isEmpty(dateFormat)) {
          // dynamically determine date format
          RevCommit firstCommit = JGitUtils.getFirstCommit(repository,
              branchObject.getName());
          int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime())
              / (60 * 60 * 24);
          total.duration = diffDays;
          if (diffDays <= 365) {
            // Days
            df = new SimpleDateFormat("yyyy-MM-dd");
          } else {
            // Months
            df = new SimpleDateFormat("yyyy-MM");
          }
        } else {
          // use specified date format
          df = new SimpleDateFormat(dateFormat);
        }
        df.setTimeZone(timezone);

        Iterable<RevCommit> revlog = revWalk;
        for (RevCommit rev : revlog) {
          Date d = JGitUtils.getCommitDate(rev);
          String p = df.format(d);
          if (!metricMap.containsKey(p)) {
            metricMap.put(p, new Metric(p));
          }
          Metric m = metricMap.get(p);
          m.count++;
          total.count++;
          if (tagMap.containsKey(rev.getId())) {
            m.tag++;
            total.tag++;
View Full Code Here

              p = rev.getAuthorIdent().getEmailAddress().toLowerCase();
            }
          }
          p = p.replace('\n',' ').replace('\r'' ').trim();
          if (!metricMap.containsKey(p)) {
            metricMap.put(p, new Metric(p));
          }
          Metric m = metricMap.get(p);
          m.count++;
        }
      } catch (Throwable t) {
        error(t, repository, "{0} failed to mine log history for author metrics of {1}",
            objectId);
View Full Code Here

    if (StringUtils.isEmpty(objectId)) {
      add(new Label("branchTitle", getRepositoryModel().HEAD));
    } else {
      add(new Label("branchTitle", objectId));
    }
    Metric metricsTotal = null;
    List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
    metricsTotal = metrics.remove(0);
    if (metricsTotal == null) {
      add(new Label("branchStats", ""));
    } else {
View Full Code Here

      // aggregate author metrics
      for (Map.Entry<String, Metric> entry : activity.getAuthorMetrics().entrySet()) {
        String author = entry.getKey();
        if (!authorMetrics.containsKey(author)) {
          authorMetrics.put(author, new Metric(author));
        }
        authorMetrics.get(author).count += entry.getValue().count;
      }

      // aggregate repository metrics
      for (Map.Entry<String, Metric> entry : activity.getRepositoryMetrics().entrySet()) {
        String repository = StringUtils.stripDotGit(entry.getKey());
        if (!repositoryMetrics.containsKey(repository)) {
          repositoryMetrics.put(repository, new Metric(repository));
        }
        repositoryMetrics.get(repository).count += entry.getValue().count;
      }
    }
View Full Code Here

    if (user == null) {
      user = UserModel.ANONYMOUS;
    }

    List<Metric> metrics = null;
    Metric metricsTotal = null;
    if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
      metrics = app().repositories().getRepositoryDefaultMetrics(model, r);
      metricsTotal = metrics.remove(0);
    }
View Full Code Here

    if (user == null) {
      user = UserModel.ANONYMOUS;
    }

    List<Metric> metrics = null;
    Metric metricsTotal = null;
    if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) {
      metrics = app().repositories().getRepositoryDefaultMetrics(model, r);
      metricsTotal = metrics.remove(0);
    }
View Full Code Here

TOP

Related Classes of com.gitblit.models.Metric

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.