當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。