From 6e6f9fe4d0c42a40ba7981606fb526391be23f6d Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 16 Nov 2011 22:43:37 -0500
Subject: [PATCH] Working draft of the aggregate activity page

---
 src/com/gitblit/utils/JGitUtils.java |   63 ++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 80147d4..99c2d0a 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -62,6 +62,7 @@
 import org.eclipse.jgit.revwalk.RevSort;
 import org.eclipse.jgit.revwalk.RevTree;
 import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter;
 import org.eclipse.jgit.revwalk.filter.RevFilter;
 import org.eclipse.jgit.storage.file.FileRepository;
 import org.eclipse.jgit.transport.CredentialsProvider;
@@ -824,6 +825,45 @@
 	}
 
 	/**
+	 * Returns a list of commits since the minimum date starting from the
+	 * specified object id.
+	 * 
+	 * @param repository
+	 * @param objectId
+	 *            if unspecified, HEAD is assumed.
+	 * @param minimumDate
+	 * @return list of commits
+	 */
+	public static List<RevCommit> getRevLog(Repository repository, String objectId, Date minimumDate) {
+		List<RevCommit> list = new ArrayList<RevCommit>();
+		if (!hasCommits(repository)) {
+			return list;
+		}
+		try {
+			// resolve branch
+			ObjectId branchObject;
+			if (StringUtils.isEmpty(objectId)) {
+				branchObject = getDefaultBranch(repository);
+			} else {
+				branchObject = repository.resolve(objectId);
+			}
+
+			RevWalk rw = new RevWalk(repository);
+			rw.markStart(rw.parseCommit(branchObject));
+			rw.setRevFilter(CommitTimeRevFilter.after(minimumDate));
+			Iterable<RevCommit> revlog = rw;
+			for (RevCommit rev : revlog) {
+				list.add(rev);
+			}
+			rw.dispose();
+		} catch (Throwable t) {
+			error(t, repository, "{0} failed to get {1} revlog for minimum date {2}", objectId,
+					minimumDate);
+		}
+		return list;
+	}
+
+	/**
 	 * Returns a list of commits starting from HEAD and working backwards.
 	 * 
 	 * @param repository
@@ -925,27 +965,6 @@
 	}
 
 	/**
-	 * Enumeration of the search types.
-	 */
-	public static enum SearchType {
-		AUTHOR, COMMITTER, COMMIT;
-
-		public static SearchType forName(String name) {
-			for (SearchType type : values()) {
-				if (type.name().equalsIgnoreCase(name)) {
-					return type;
-				}
-			}
-			return COMMIT;
-		}
-
-		@Override
-		public String toString() {
-			return name().toLowerCase();
-		}
-	}
-
-	/**
 	 * Search the commit history for a case-insensitive match to the value.
 	 * Search results require a specified SearchType of AUTHOR, COMMITTER, or
 	 * COMMIT. Results may be paginated using offset and maxCount. If the
@@ -963,7 +982,7 @@
 	 * @return matching list of commits
 	 */
 	public static List<RevCommit> searchRevlogs(Repository repository, String objectId,
-			String value, final SearchType type, int offset, int maxCount) {
+			String value, final com.gitblit.Constants.SearchType type, int offset, int maxCount) {
 		final String lcValue = value.toLowerCase();
 		List<RevCommit> list = new ArrayList<RevCommit>();
 		if (maxCount == 0) {

--
Gitblit v1.9.1