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