From: <jbo...@li...> - 2005-09-20 06:52:16
|
Author: aron.gombas Date: 2005-09-20 02:52:07 -0400 (Tue, 20 Sep 2005) New Revision: 1153 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java Log: Minor refactoring Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-09-20 06:42:52 UTC (rev 1152) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-09-20 06:52:07 UTC (rev 1153) @@ -144,13 +144,11 @@ public Set<String> committersLast31Days = new HashSet<String>(); /* No of commits per author. */ - public Map<String,Integer> commitsPerAuthorMap = new TreeMap<String,Integer>(); -public List<Map.Entry<String,Integer>> commitsPerAuthor;// TODO write comment + public List<Map.Entry<String,Integer>> commitsPerAuthor; public String commitsPerAuthorChartUrl; /* No of commits per file. */ - public Map<String,Integer> commitsPerFileMap = new TreeMap<String,Integer>(); -public List<Map.Entry<String,Integer>> commitsPerFile;// TODO write comment + public List<Map.Entry<String,Integer>> commitsPerFile; public String commitsPerFileChartUrl; /* No of commits per week. */ @@ -162,11 +160,7 @@ public String repoEntriesPerWeekChartUrl; /** Must be called to validate its content, after the processing was done. */ - public void validate() { - // sort maps - commitsPerAuthor = (List<Map.Entry<String, Integer>>)ChartUtils.intValuedMapToSortedList(commitsPerAuthorMap); - commitsPerFile = (List<Map.Entry<String, Integer>>)ChartUtils.intValuedMapToSortedList(commitsPerFileMap); - + public void validate() { // revert history Collections.reverse(commits); @@ -185,9 +179,6 @@ calculatedCommitsTotal += commitsPerWeek.getDataItem(i).getValue().intValue(); if(calculatedCommitsTotal != commitsTotal) throw new IllegalStateException(String.format("Calculated commits (%d) does not equal statistical commits (%d)", calculatedCommitsTotal, commitsTotal)); - // TODO check this one, too, there is still some problem (bug) with it - if(repoEntriesPerWeek.getItemCount() > 0) - System.out.println(" =============== calculated no of files: " + repoEntriesPerWeek.getDataItem(repoEntriesPerWeek.getItemCount() - 1).getValue().intValue()); } } @@ -201,6 +192,8 @@ // analyze long now = new Date().getTime(); + Map<String,Integer> commitsPerAuthorMap = new TreeMap<String,Integer>(); + Map<String,Integer> commitsPerFileMap = new TreeMap<String,Integer>(); for(SVNLogEntry logEntry : logEntries) { // skip invalid entries if(logEntry.getAuthor() == null) { @@ -236,8 +229,8 @@ } // count commits-per-author - Integer commitsPerCurrentAuthor = stats.commitsPerAuthorMap.get(logEntry.getAuthor()); - stats.commitsPerAuthorMap.put(logEntry.getAuthor(), (commitsPerCurrentAuthor == null) ? 1 : commitsPerCurrentAuthor + 1); + Integer commitsPerCurrentAuthor = commitsPerAuthorMap.get(logEntry.getAuthor()); + commitsPerAuthorMap.put(logEntry.getAuthor(), (commitsPerCurrentAuthor == null) ? 1 : commitsPerCurrentAuthor + 1); // count commits-per-week Week commitWeek = new Week(logEntry.getDate()); @@ -254,8 +247,8 @@ SVNLogEntryPath logEntryPath = (SVNLogEntryPath)changedPaths.get(it.next()); // count commits-per-file - Integer commitsPerCurrentFile = stats.commitsPerFileMap.get(logEntryPath.getPath()); - stats.commitsPerFileMap.put(logEntryPath.getPath(), (commitsPerCurrentFile == null) ? 1 : commitsPerCurrentFile + 1); + Integer commitsPerCurrentFile = commitsPerFileMap.get(logEntryPath.getPath()); + commitsPerFileMap.put(logEntryPath.getPath(), (commitsPerCurrentFile == null) ? 1 : commitsPerCurrentFile + 1); // count files-per-week TimeSeriesDataItem repoEntriesPerCurrentWeek = stats.repoEntriesPerWeek.getDataItem(commitWeek); @@ -269,6 +262,8 @@ } // validate + stats.commitsPerAuthor = ChartUtils.intValuedMapToSortedList(commitsPerAuthorMap); + stats.commitsPerFile = ChartUtils.intValuedMapToSortedList(commitsPerFileMap); stats.validate(); return stats; |