use of com.gitblit.wicket.panels.DigestsPanel in project gitblit by gitblit.
the class DashboardPage method addActivity.
protected void addActivity(UserModel user, Collection<RepositoryModel> repositories, String feedTitle, int daysBack) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1 * daysBack);
Date minimumDate = c.getTime();
TimeZone timezone = getTimeZone();
// create daily commit digest feed
List<DailyLogEntry> digests = new ArrayList<DailyLogEntry>();
for (RepositoryModel model : repositories) {
if (model.isCollectingGarbage) {
continue;
}
if (model.hasCommits && model.lastChange.after(minimumDate)) {
Repository repository = app().repositories().getRepository(model.name);
List<DailyLogEntry> entries = RefLogUtils.getDailyLogByRef(model.name, repository, minimumDate, timezone);
digests.addAll(entries);
repository.close();
}
}
Fragment activityFragment = new Fragment("activity", "activityFragment", this);
add(activityFragment);
activityFragment.add(new Label("feedTitle", feedTitle));
if (digests.size() == 0) {
// quiet or no starred repositories
if (repositories.size() == 0) {
if (UserModel.ANONYMOUS.equals(user)) {
if (daysBack == 1) {
activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
} else {
activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
}
} else {
activityFragment.add(new LinkPanel("digests", null, getString("gb.findSomeRepositories"), RepositoriesPage.class));
}
} else {
if (daysBack == 1) {
activityFragment.add(new Label("digests", getString("gb.noActivityToday")));
} else {
activityFragment.add(new Label("digests", MessageFormat.format(getString("gb.noActivity"), daysBack)));
}
}
} else {
// show daily commit digest feed
Collections.sort(digests);
DigestsPanel digestsPanel = new DigestsPanel("digests", digests);
activityFragment.add(digestsPanel);
}
// add the nifty charts
if (!ArrayUtils.isEmpty(digests)) {
// aggregate author exclusions
Set<String> authorExclusions = new TreeSet<String>();
for (String author : app().settings().getStrings(Keys.web.metricAuthorExclusions)) {
authorExclusions.add(author.toLowerCase());
}
for (RepositoryModel model : repositories) {
if (!ArrayUtils.isEmpty(model.metricAuthorExclusions)) {
for (String author : model.metricAuthorExclusions) {
authorExclusions.add(author.toLowerCase());
}
}
}
addCharts(activityFragment, digests, authorExclusions, daysBack);
} else {
activityFragment.add(new Label("charts").setVisible(false));
activityFragment.add(new Label("feedheader").setVisible(false));
}
}
Aggregations