@@ -882,7 +882,7 @@ public class GitBlit implements ServletContextListener { | |||
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); | |||
} |
@@ -27,6 +27,7 @@ import java.util.Date; | |||
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; | |||
@@ -60,10 +61,12 @@ public class ActivityUtils { | |||
* @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. | |||
@@ -72,9 +75,9 @@ public class ActivityUtils { | |||
// 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) { |
@@ -24,6 +24,7 @@ import java.util.Date; | |||
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; | |||
@@ -84,10 +85,11 @@ public class MetricUtils { | |||
* 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>(); | |||
@@ -130,6 +132,7 @@ public class MetricUtils { | |||
// use specified date format | |||
df = new SimpleDateFormat(dateFormat); | |||
} | |||
df.setTimeZone(timezone); | |||
Iterable<RevCommit> revlog = revWalk; | |||
for (RevCommit rev : revlog) { |
@@ -67,7 +67,8 @@ public class ActivityPage extends RootPage { | |||
// 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 | |||
@@ -173,6 +174,7 @@ public class ActivityPage extends RootPage { | |||
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()); | |||
} |
@@ -55,7 +55,7 @@ public class MetricsPage extends RepositoryPage { | |||
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", "")); | |||
@@ -135,7 +135,7 @@ public class MetricsPage extends RepositoryPage { | |||
} | |||
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(); | |||
@@ -15,7 +15,7 @@ | |||
</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> |
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.List; | |||
import java.util.TimeZone; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.junit.Test; | |||
@@ -35,7 +36,8 @@ public class MetricUtilsTest { | |||
} | |||
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); | |||
} |