From 06ae63123c94038b90153f4847de2c57c0193db8 Mon Sep 17 00:00:00 2001
From: Rafael Cavazin <rafaelcavazin@gmail.com>
Date: Sun, 27 Jan 2013 09:46:50 -0500
Subject: [PATCH] updating current development

---
 src/com/gitblit/utils/ActivityUtils.java |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/com/gitblit/utils/ActivityUtils.java b/src/com/gitblit/utils/ActivityUtils.java
index 61b6242..732fdeb 100644
--- a/src/com/gitblit/utils/ActivityUtils.java
+++ b/src/com/gitblit/utils/ActivityUtils.java
@@ -27,6 +27,7 @@
 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;
@@ -35,9 +36,9 @@
 
 import com.gitblit.GitBlit;
 import com.gitblit.models.Activity;
-import com.gitblit.models.Activity.RepositoryCommit;
 import com.gitblit.models.GravatarProfile;
 import com.gitblit.models.RefModel;
+import com.gitblit.models.RepositoryCommit;
 import com.gitblit.models.RepositoryModel;
 import com.google.gson.reflect.TypeToken;
 
@@ -60,10 +61,12 @@
 	 * @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,13 +75,20 @@
 		// 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) {
+			if (model.maxActivityCommits == -1) {
+				// skip this repository
+				continue;
+			}
 			if (model.hasCommits && model.lastChange.after(thresholdDate)) {
+				if (model.isCollectingGarbage) {
+					continue;
+				}
 				Repository repository = GitBlit.self()
 						.getRepository(model.name);
 				List<String> branches = new ArrayList<String>();
@@ -91,7 +101,7 @@
 					branches.add(objectId);
 				}
 				Map<ObjectId, List<RefModel>> allRefs = JGitUtils
-						.getAllRefs(repository);
+						.getAllRefs(repository, model.showRemoteBranches);
 
 				for (String branch : branches) {
 					String shortName = branch;
@@ -100,7 +110,11 @@
 					}
 					List<RevCommit> commits = JGitUtils.getRevLog(repository,
 							branch, thresholdDate);
-					for (RevCommit commit : commits) {
+					if (model.maxActivityCommits > 0 && commits.size() > model.maxActivityCommits) {
+						// trim commits to maximum count
+						commits = commits.subList(0,  model.maxActivityCommits);
+					}
+					for (RevCommit commit : commits) {						
 						Date date = JGitUtils.getCommitDate(commit);
 						String dateStr = df.format(date);
 						if (!activity.containsKey(dateStr)) {
@@ -148,16 +162,16 @@
 	 * @param email
 	 *            address to query Gravatar
 	 * @param width
-	 *            size of thumbnail. if width <= 0, the defalt of 60 is used.
+	 *            size of thumbnail. if width <= 0, the default of 50 is used.
 	 * @return
 	 */
 	public static String getGravatarThumbnailUrl(String email, int width) {
 		if (width <= 0) {
-			width = 60;
+			width = 50;
 		}
 		String emailHash = StringUtils.getMD5(email);
 		String url = MessageFormat.format(
-				"http://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
+				"https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
 		return url;
 	}
 
@@ -171,7 +185,7 @@
 	 * @throws IOException
 	 */
 	public static GravatarProfile getGravatarProfile(String hash) throws IOException {
-		String url = MessageFormat.format("http://www.gravatar.com/{0}.json", hash);
+		String url = MessageFormat.format("https://www.gravatar.com/{0}.json", hash);
 		// Gravatar has a complex json structure
 		Type profileType = new TypeToken<Map<String, List<GravatarProfile>>>() {
 		}.getType();

--
Gitblit v1.9.1