本文整理汇总了Java中com.gitblit.utils.MetricUtils类的典型用法代码示例。如果您正苦于以下问题:Java MetricUtils类的具体用法?Java MetricUtils怎么用?Java MetricUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricUtils类属于com.gitblit.utils包,在下文中一共展示了MetricUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDayOfWeekMetrics
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E", getTimeZone());
SimpleDateFormat sdf = new SimpleDateFormat("E");
Calendar cal = Calendar.getInstance();
List<Metric> sorted = new ArrayList<Metric>();
int firstDayOfWeek = cal.getFirstDayOfWeek();
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
// rewind date to first day of week
cal.add(Calendar.DATE, firstDayOfWeek - dayOfWeek);
for (int i = 0; i < 7; i++) {
String day = sdf.format(cal.getTime());
for (Metric metric : list) {
if (metric.name.equals(day)) {
sorted.add(metric);
list.remove(metric);
break;
}
}
cal.add(Calendar.DATE, 1);
}
return sorted;
}
示例2: getAuthorMetrics
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
private List<Metric> getAuthorMetrics(Repository repository, String objectId) {
List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);
Collections.sort(authors, new Comparator<Metric>() {
@Override
public int compare(Metric o1, Metric o2) {
if (o1.count > o2.count) {
return -1;
} else if (o1.count < o2.count) {
return 1;
}
return 0;
}
});
if (authors.size() > 10) {
return authors.subList(0, 9);
}
return authors;
}
示例3: MetricsPage
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
public MetricsPage(PageParameters params) {
super(params);
Repository r = getRepository();
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 {
add(new Label("branchStats",
MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
metricsTotal.tag, getTimeUtils().duration(metricsTotal.duration))));
}
insertLinePlot("commitsChart", metrics);
insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
insertPieChart("authorsChart", getAuthorMetrics(r, objectId));
}
示例4: MetricsPage
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
public MetricsPage(PageParameters params) {
super(params);
Repository r = getRepository();
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 {
add(new Label("branchStats",
MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
metricsTotal.tag, getTimeUtils().duration(metricsTotal.duration))));
}
Charts charts = new Flotr2Charts();
add(WicketUtils.newBlankImage("commitsChart"));
add(WicketUtils.newBlankImage("dayOfWeekChart"));
add(WicketUtils.newBlankImage("authorsChart"));
createLineChart(charts, "commitsChart", metrics);
createBarChart(charts, "dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
createPieChart(charts, "authorsChart", getAuthorMetrics(r, objectId));
add(new HeaderContributor(charts));
}
示例5: testAuthorMetrics
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
@Test
public void testAuthorMetrics() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);
List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);
repository.close();
assertEquals("No author metrics found!", 9, byEmail.size());
assertEquals("No author metrics found!", 8, byName.size());
}
示例6: testMetrics
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
private void testMetrics(Repository repository) throws Exception {
List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null,
TimeZone.getDefault());
repository.close();
assertTrue("No date metrics found!", metrics.size() > 0);
}
示例7: getRepositoryDefaultMetrics
import com.gitblit.utils.MetricUtils; //导入依赖的package包/类
/**
* Returns the metrics for the default branch of the specified repository.
* This method builds a metrics cache. The cache is updated if the
* repository is updated. A new copy of the metrics list is returned on each
* call so that modifications to the list are non-destructive.
*
* @param model
* @param repository
* @return a new array list of metrics
*/
public List<Metric> getRepositoryDefaultMetrics(RepositoryModel model, Repository repository) {
if (repositoryMetricsCache.hasCurrent(model.name, model.lastChange)) {
return new ArrayList<Metric>(repositoryMetricsCache.getObject(model.name));
}
List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null, getTimezone());
repositoryMetricsCache.updateObject(model.name, model.lastChange, metrics);
return new ArrayList<Metric>(metrics);
}