当前位置: 首页>>代码示例>>Java>>正文


Java MetricUtils类代码示例

本文整理汇总了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;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:25,代码来源:MetricsPage.java

示例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;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:19,代码来源:MetricsPage.java

示例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));
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:23,代码来源:MetricsPage.java

示例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));

}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:33,代码来源:MetricsPage.java

示例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());
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:10,代码来源:MetricUtilsTest.java

示例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);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:7,代码来源:MetricUtilsTest.java

示例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);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:19,代码来源:GitBlit.java


注:本文中的com.gitblit.utils.MetricUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。