| | |
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import org.apache.wicket.Application;
|
| | | import org.apache.wicket.PageParameters;
|
| | | import org.apache.wicket.behavior.HeaderContributor;
|
| | | import org.apache.wicket.markup.html.basic.Label;
|
| | |
| | | import com.gitblit.models.Metric;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.utils.ActivityUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.PageRegistration;
|
| | | import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
|
| | | import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration;
|
| | |
| | |
|
| | | // determine repositories to view and retrieve the activity
|
| | | List<RepositoryModel> models = getRepositories(params);
|
| | | List<Activity> recentActivity = ActivityUtils.getRecentActivity(models, daysBack, objectId);
|
| | | List<Activity> recentActivity = ActivityUtils.getRecentActivity(models, |
| | | daysBack, objectId, getTimeZone());
|
| | |
|
| | | if (recentActivity.size() == 0) {
|
| | | // no activity, skip graphs and activity panel
|
| | |
| | | int totalCommits = 0;
|
| | | Set<String> uniqueAuthors = new HashSet<String>();
|
| | | for (Activity activity : recentActivity) {
|
| | | totalCommits += activity.commits.size();
|
| | | totalCommits += activity.getCommitCount();
|
| | | uniqueAuthors.addAll(activity.getAuthorMetrics().keySet());
|
| | | }
|
| | | int totalAuthors = uniqueAuthors.size();
|
| | |
| | |
|
| | | PageParameters currentParameters = getPageParameters();
|
| | | int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 14);
|
| | | if (currentParameters.containsKey("db")) {
|
| | | daysBack = currentParameters.getInt("db");
|
| | | }
|
| | | if (daysBack < 1) {
|
| | | daysBack = 14;
|
| | | if (currentParameters != null && !currentParameters.containsKey("db")) {
|
| | | currentParameters.put("db", daysBack);
|
| | | }
|
| | |
|
| | | // preserve time filter options on repository choices
|
| | | filters.menuItems.addAll(getRepositoryFilterItems(new PageParameters("db=" + daysBack)));
|
| | | |
| | | filters.menuItems.addAll(getRepositoryFilterItems(currentParameters));
|
| | |
|
| | | // preserve repository filter options on time choices
|
| | | filters.menuItems.addAll(getTimeFilterItems(currentParameters));
|
| | |
|
| | |
| | |
|
| | | // aggregate repository metrics
|
| | | for (Map.Entry<String, Metric> entry : activity.getRepositoryMetrics().entrySet()) {
|
| | | String repository = entry.getKey();
|
| | | String repository = StringUtils.stripDotGit(entry.getKey());
|
| | | if (!repositoryMetrics.containsKey(repository)) {
|
| | | repositoryMetrics.put(repository, new Metric(repository));
|
| | | }
|
| | |
| | | GoogleChart chart = new GoogleLineChart("chartDaily", getString("gb.dailyActivity"), "day",
|
| | | getString("gb.commits"));
|
| | | SimpleDateFormat df = new SimpleDateFormat("MMM dd");
|
| | | df.setTimeZone(getTimeZone());
|
| | | for (Activity metric : recentActivity) {
|
| | | chart.addValue(df.format(metric.startDate), metric.commits.size());
|
| | | chart.addValue(df.format(metric.startDate), metric.getCommitCount());
|
| | | }
|
| | | chart.setWidth(w);
|
| | | chart.setHeight(h);
|
| | |
| | | charts.addChart(chart);
|
| | |
|
| | | return charts;
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void onBeforeRender() {
|
| | | if (GitBlit.isDebugMode()) {
|
| | | // strip Wicket tags in debug mode for jQuery DOM traversal
|
| | | Application.get().getMarkupSettings().setStripWicketTags(true);
|
| | | }
|
| | | super.onBeforeRender();
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void onAfterRender() {
|
| | | if (GitBlit.isDebugMode()) {
|
| | | // restore Wicket debug tags
|
| | | Application.get().getMarkupSettings().setStripWicketTags(false);
|
| | | }
|
| | | super.onAfterRender();
|
| | | }
|
| | | }
|