From 79dd0bddbd939c85f002f3a33b95ae84d0bf38cb Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 24 Jun 2013 09:36:19 -0400 Subject: Implemented commit cache for the dashboards, activity, and project pages --- src/main/java/com/gitblit/utils/ActivityUtils.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/gitblit/utils/ActivityUtils.java') diff --git a/src/main/java/com/gitblit/utils/ActivityUtils.java b/src/main/java/com/gitblit/utils/ActivityUtils.java index edeb01ad..fa74350e 100644 --- a/src/main/java/com/gitblit/utils/ActivityUtils.java +++ b/src/main/java/com/gitblit/utils/ActivityUtils.java @@ -32,9 +32,7 @@ import java.util.TimeZone; import java.util.TreeSet; import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; import com.gitblit.GitBlit; import com.gitblit.Keys; @@ -112,22 +110,19 @@ public class ActivityUtils { } else { branches.add(objectId); } - Map> allRefs = JGitUtils - .getAllRefs(repository, model.showRemoteBranches); for (String branch : branches) { String shortName = branch; if (shortName.startsWith(Constants.R_HEADS)) { shortName = shortName.substring(Constants.R_HEADS.length()); } - List commits = JGitUtils.getRevLog(repository, - branch, thresholdDate); + List commits = CommitCache.instance().getCommits(model.name, repository, branch, thresholdDate); 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); + for (RepositoryCommit commit : commits) { + Date date = commit.getCommitDate(); String dateStr = df.format(date); if (!activity.containsKey(dateStr)) { // Normalize the date to midnight @@ -140,11 +135,7 @@ public class ActivityUtils { a.excludeAuthors(authorExclusions); activity.put(dateStr, a); } - RepositoryCommit commitModel = activity.get(dateStr) - .addCommit(model.name, shortName, commit); - if (commitModel != null) { - commitModel.setRefs(allRefs.get(commit.getId())); - } + activity.get(dateStr).addCommit(commit); } } -- cgit v1.2.3