Use proper timezone to generate all metrics
| | |
| | | if (repositoryMetricsCache.hasCurrent(model.name, model.lastChange)) {
|
| | | return new ArrayList<Metric>(repositoryMetricsCache.getObject(model.name));
|
| | | }
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null, getTimezone());
|
| | | repositoryMetricsCache.updateObject(model.name, model.lastChange, metrics);
|
| | | return new ArrayList<Metric>(metrics);
|
| | | }
|
| | |
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.TimeZone;
|
| | |
|
| | | import org.eclipse.jgit.lib.Constants;
|
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | |
| | | * @param objectId
|
| | | * the branch to retrieve. If this value is null or empty all
|
| | | * branches are queried.
|
| | | * @param timezone
|
| | | * the timezone for aggregating commits
|
| | | * @return
|
| | | */
|
| | | public static List<Activity> getRecentActivity(List<RepositoryModel> models, int daysBack,
|
| | | String objectId) {
|
| | | String objectId, TimeZone timezone) {
|
| | |
|
| | | // Activity panel shows last daysBack of activity across all
|
| | | // repositories.
|
| | |
| | | // Build a map of DailyActivity from the available repositories for the
|
| | | // specified threshold date.
|
| | | DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
| | | df.setTimeZone(GitBlit.getTimezone());
|
| | | df.setTimeZone(timezone);
|
| | | Calendar cal = Calendar.getInstance();
|
| | | cal.setTimeZone(GitBlit.getTimezone());
|
| | | cal.setTimeZone(timezone);
|
| | |
|
| | | Map<String, Activity> activity = new HashMap<String, Activity>();
|
| | | for (RepositoryModel model : models) {
|
| | |
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.TimeZone;
|
| | |
|
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | |
| | | * if null or empty, HEAD is assumed.
|
| | | * @param includeTotal
|
| | | * @param dateFormat
|
| | | * @param timezone
|
| | | * @return list of metrics
|
| | | */
|
| | | public static List<Metric> getDateMetrics(Repository repository, String objectId,
|
| | | boolean includeTotal, String dateFormat) {
|
| | | boolean includeTotal, String dateFormat, TimeZone timezone) {
|
| | | Metric total = new Metric("TOTAL");
|
| | | final Map<String, Metric> metricMap = new HashMap<String, Metric>();
|
| | |
|
| | |
| | | // use specified date format
|
| | | df = new SimpleDateFormat(dateFormat);
|
| | | }
|
| | | df.setTimeZone(timezone);
|
| | |
|
| | | Iterable<RevCommit> revlog = revWalk;
|
| | | for (RevCommit rev : revlog) {
|
| | |
| | |
|
| | | // 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
|
| | |
| | | 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.getCommitCount());
|
| | | }
|
| | |
| | | add(new Label("branchTitle", objectId));
|
| | | }
|
| | | Metric metricsTotal = null;
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null);
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
|
| | | metricsTotal = metrics.remove(0);
|
| | | if (metricsTotal == null) {
|
| | | add(new Label("branchStats", ""));
|
| | |
| | | }
|
| | |
|
| | | private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
|
| | | List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E");
|
| | | List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E", getTimeZone());
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("E");
|
| | | Calendar cal = Calendar.getInstance();
|
| | |
|
| | |
| | | </div>
|
| | |
|
| | | <wicket:fragment wicket:id="commitFragment">
|
| | | <td class="date" style="width:50px; vertical-align: middle;" ><span wicket:id="time">[time of day]</span></td>
|
| | | <td class="date" style="width:60px; vertical-align: middle;text-align: right;padding-right:10px;" ><span wicket:id="time">[time of day]</span></td>
|
| | | <td style="width:10em;text-align:left;vertical-align: middle;">
|
| | | <span wicket:id="repository" class="repositorySwatch">[repository link]</span>
|
| | | </td>
|
| | |
| | | import static org.junit.Assert.assertTrue;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.TimeZone;
|
| | |
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.junit.Test;
|
| | |
| | | }
|
| | |
|
| | | private void testMetrics(Repository repository) throws Exception {
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null,
|
| | | TimeZone.getDefault());
|
| | | repository.close();
|
| | | assertTrue("No date metrics found!", metrics.size() > 0);
|
| | | }
|