Author: aron.gombas Date: 2005-12-21 10:13:55 -0500 (Wed, 21 Dec 2005) New Revision: 1917 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring.properties trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_fr.properties trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_hu.properties trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_pl.properties trunk/labs/kosmos/web-portlet/pages/svn_monitoring_repository_details.jsp Log: New SVN stat: files-per-file-type Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/model/SvnRepository.java 2005-12-21 15:13:55 UTC (rev 1917) @@ -45,6 +45,8 @@ /** Number of committers over the last 31 days (about one month). */ private int committersLast31Days; + /** URL of the files-per-file-type chart image. */ + private String filesPerFileTypeChartUrl; /** URL of the commits-per-author chart image. */ private String commitsPerAuthorChartUrl; /** URL of the commits-per-file chart image. */ @@ -61,6 +63,8 @@ /** Total size of files. */ private int totalFileSize; + /** Files-per-file-type sorted by files in descending order. */ + private List<Map.Entry<String,Integer>> filesPerFileType; /** Commits-per-author sorted by commits in descending order. */ private List<Map.Entry<String,Integer>> commitsPerAuthor; /** Commits-per-file sorted by commits in descending order. */ @@ -78,9 +82,9 @@ Date createdDate, List<ScmRepositoryChange> commits, int commitsTotal, int commitsToday, int commitsLast7Days, int commitsLast31Days, int committersTotal, int committersToday, int committersLast7Days, int committersLast31Days, - String commitsPerAuthorChartUrl, String commitsPerFileChartUrl, String commitsPerWeekChartUrl, String repoEntriesPerWeekChartUrl, + String filesPerFileTypeChartUrl, String commitsPerAuthorChartUrl, String commitsPerFileChartUrl, String commitsPerWeekChartUrl, String repoEntriesPerWeekChartUrl, int dirs, int files, int totalFileSize, - List<Map.Entry<String,Integer>> commitsPerAuthor, List<Map.Entry<String,Integer>> commitsPerFile) { + List<Map.Entry<String,Integer>> filesPerFileType, List<Map.Entry<String,Integer>> commitsPerAuthor, List<Map.Entry<String,Integer>> commitsPerFile) { super(location + revision + commits.get(0).getDate()); this.location = location; @@ -99,6 +103,7 @@ this.committersLast7Days = committersLast7Days; this.committersLast31Days = committersLast31Days; + this.filesPerFileTypeChartUrl = filesPerFileTypeChartUrl; this.commitsPerAuthorChartUrl = commitsPerAuthorChartUrl; this.commitsPerFileChartUrl = commitsPerFileChartUrl; this.commitsPerWeekChartUrl = commitsPerWeekChartUrl; @@ -108,6 +113,7 @@ this.files = files; this.totalFileSize = totalFileSize; + this.filesPerFileType = filesPerFileType; this.commitsPerAuthor = commitsPerAuthor; this.commitsPerFile = commitsPerFile; } @@ -159,8 +165,12 @@ public int getCommittersLast31Days() { return committersLast31Days; } - - public String getCommitsPerAuthorChartUrl() { + + public String getFilesPerFileTypeChartUrl() { + return filesPerFileTypeChartUrl; + } + + public String getCommitsPerAuthorChartUrl() { return commitsPerAuthorChartUrl; } @@ -188,6 +198,10 @@ return totalFileSize; } + public List<Map.Entry<String,Integer>> getFilesPerFileType() { + return filesPerFileType; + } + public List<Map.Entry<String,Integer>> getCommitsPerAuthor() { return commitsPerAuthor; } 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-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-12-21 15:13:55 UTC (rev 1917) @@ -30,6 +30,7 @@ import java.util.Set; import java.util.TreeMap; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jfree.data.time.TimeSeries; @@ -110,7 +111,7 @@ SvnRepositoryLogStats logStats = analyzeLog(repo); SvnRepositoryContentStats contentStats = analyzeContent(repo); - generateCharts(repo, logStats); + generateCharts(repo, logStats, contentStats); disconnect(repo); @@ -120,9 +121,9 @@ logStats.createdDate, trimList(logStats.commits), logStats.commitsTotal, logStats.commitsToday, logStats.commitsLast7Days, logStats.commitsLast31Days, logStats.committersTotal.size(), logStats.committersToday.size(), logStats.committersLast7Days.size(), logStats.committersLast31Days.size(), - logStats.commitsPerAuthorChartUrl, logStats.commitsPerFileChartUrl, logStats.commitsPerWeekChartUrl, logStats.repoEntriesPerWeekChartUrl, + contentStats.filesPerFileTypeChartUrl, logStats.commitsPerAuthorChartUrl, logStats.commitsPerFileChartUrl, logStats.commitsPerWeekChartUrl, logStats.repoEntriesPerWeekChartUrl, contentStats.dirs, contentStats.files, contentStats.totalSize, - trimList(logStats.commitsPerAuthor), trimList(logStats.commitsPerFile)); + trimList(contentStats.filesPerFileType), trimList(logStats.commitsPerAuthor), trimList(logStats.commitsPerFile)); log.debug(String.format("Adding %s...", repository)); repositories.add(repository); } catch (Exception ex) { @@ -183,6 +184,10 @@ public Set<String> committersLast7Days = new HashSet<String>(); public Set<String> committersLast31Days = new HashSet<String>(); + /* No of repository entries per week. */ + public TimeSeries repoEntriesPerWeek = new TimeSeries("", Week.class); + public String repoEntriesPerWeekChartUrl; + /* No of commits per author. */ public List<Map.Entry<String,Integer>> commitsPerAuthor; public String commitsPerAuthorChartUrl; @@ -195,10 +200,6 @@ public TimeSeries commitsPerWeek = new TimeSeries("", Week.class); public String commitsPerWeekChartUrl; - /* No of repository entries per week. */ - public TimeSeries repoEntriesPerWeek = new TimeSeries("", Week.class); - public String repoEntriesPerWeekChartUrl; - /** Must be called to validate its content, after the processing was done. */ public void validate() { // revert history @@ -286,10 +287,6 @@ for(Iterator it = changedPaths.keySet().iterator(); it.hasNext();) { SVNLogEntryPath logEntryPath = (SVNLogEntryPath)changedPaths.get(it.next()); char type = logEntryPath.getType(); - - // skip copied branches - //if(logEntryPath.getCopyPath() != null) - // continue; // update repo entry counters int repoEntryAdder = 0; @@ -330,62 +327,89 @@ /** Wraps the stats retrieved from the log of a SVN repository. */ private class SvnRepositoryContentStats { + /** No of dirs. */ public int dirs; + /** No of files. */ public int files; + /** Total filesize. */ public int totalSize; + + /* No of files per file-type. */ + public List<Map.Entry<String,Integer>> filesPerFileType; + public String filesPerFileTypeChartUrl; } /** Analyzes the repository content and returns its stats. */ + @SuppressWarnings("unchecked") protected SvnRepositoryContentStats analyzeContent(SVNRepository repository) throws SVNException { SvnRepositoryContentStats stats = new SvnRepositoryContentStats(); + Map<String,Integer> filesPerFileTypeMap = new TreeMap<String,Integer>(); log.info(String.format("Analyzing content of \"%s\" repository...", repository.getLocation().toString())); stats.dirs = 1; // starting root dir - traverseRepository(repository, "", stats); + traverseRepository(repository, "", stats, filesPerFileTypeMap); log.info(String.format("%d repo-entries processed.", stats.dirs + stats.files)); + + // validate + stats.filesPerFileType = ChartUtils.intValuedMapToSortedList(filesPerFileTypeMap); return stats; } /** Recursively traverses the given SVN repository tree and updates the stats passed. */ @SuppressWarnings("unchecked") - protected void traverseRepository(SVNRepository repository, String path, SvnRepositoryContentStats stats) throws SVNException { - Collection<SVNDirEntry> entries = (Collection<SVNDirEntry>)repository.getDir(path, -1, null, (Collection)null); - + protected void traverseRepository(SVNRepository repository, String path, SvnRepositoryContentStats stats, Map<String,Integer> filesPerFileTypeMap) throws SVNException { + Collection<SVNDirEntry> entries = (Collection<SVNDirEntry>)repository.getDir(path, -1, null, (Collection)null); + for(SVNDirEntry entry : entries) { log.debug(String.format("Traversing \"/%s%s\"...", path.equals("") ? "" : path + "/", entry.getName())); if (entry.getKind() == SVNNodeKind.DIR) { + // update stats stats.dirs++; + // traverse recursively - traverseRepository(repository, path.equals("") ? entry.getName() : path + "/" + entry.getName(), stats); + traverseRepository(repository, path.equals("") ? entry.getName() : path + "/" + entry.getName(), stats, filesPerFileTypeMap); } else if (entry.getKind() == SVNNodeKind.FILE){ + // update stats stats.files++; stats.totalSize += entry.size(); + + // count file-types + String fileType = StringUtils.substringAfterLast(entry.getName(), "."); + if(!StringUtils.isEmpty(fileType)) { + fileType = fileType.toLowerCase(); + Integer filesPerCurrentType = filesPerFileTypeMap.get(fileType); + filesPerFileTypeMap.put(fileType, (filesPerCurrentType == null) ? 1 : filesPerCurrentType + 1); + } } } } /** Generates and saves the chart images on the server, and sets the URLs to the stats. */ - protected void generateCharts(SVNRepository repository, SvnRepositoryLogStats stats) throws IOException { + protected void generateCharts(SVNRepository repository, SvnRepositoryLogStats logStats, SvnRepositoryContentStats contentStats) throws IOException { String prefix = ScrapingUtils.removeUserInfoFromUrl(repository.getLocation().toString()); - // generate charts + // generate charts ByteArrayOutputStream out = new ByteArrayOutputStream(); - ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerAuthor, ChartUtils.MAX_ITEMS)), out); - stats.commitsPerAuthorChartUrl = storeFile(prefix + "_commits_per_author.png", new ByteArrayInputStream(out.toByteArray())); + ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(contentStats.filesPerFileType, ChartUtils.MAX_ITEMS)), out); + contentStats.filesPerFileTypeChartUrl = storeFile(prefix + "_files_per_file_type.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); - ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(stats.commitsPerFile, ChartUtils.MAX_ITEMS)), out); - stats.commitsPerFileChartUrl = storeFile(prefix + "_commits_per_file.png", new ByteArrayInputStream(out.toByteArray())); + ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(logStats.commitsPerAuthor, ChartUtils.MAX_ITEMS)), out); + logStats.commitsPerAuthorChartUrl = storeFile(prefix + "_commits_per_author.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); - ChartUtils.writeChartAsPng(ChartUtils.generateTimeBarChart(stats.commitsPerWeek), out); - stats.commitsPerWeekChartUrl = storeFile(prefix + "_commits_per_week.png", new ByteArrayInputStream(out.toByteArray())); + ChartUtils.writeChartAsPng(ChartUtils.generatePieChart(ChartUtils.collectionToPieDataset(logStats.commitsPerFile, ChartUtils.MAX_ITEMS)), out); + logStats.commitsPerFileChartUrl = storeFile(prefix + "_commits_per_file.png", new ByteArrayInputStream(out.toByteArray())); out.reset(); - ChartUtils.writeChartAsPng(ChartUtils.generateTimeLineChart(stats.repoEntriesPerWeek), out); - stats.repoEntriesPerWeekChartUrl = storeFile(prefix + "_files_per_week.png", new ByteArrayInputStream(out.toByteArray())); + ChartUtils.writeChartAsPng(ChartUtils.generateTimeBarChart(logStats.commitsPerWeek), out); + logStats.commitsPerWeekChartUrl = storeFile(prefix + "_commits_per_week.png", new ByteArrayInputStream(out.toByteArray())); + + out.reset(); + ChartUtils.writeChartAsPng(ChartUtils.generateTimeLineChart(logStats.repoEntriesPerWeek), out); + logStats.repoEntriesPerWeekChartUrl = storeFile(prefix + "_files_per_week.png", new ByteArrayInputStream(out.toByteArray())); } } } Modified: trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring.properties =================================================================== --- trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring.properties 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring.properties 2005-12-21 15:13:55 UTC (rev 1917) @@ -17,6 +17,7 @@ svnrepository.totalRepositoryEntries=Total Repository Entries svnrepository.totalFileSize=Total File Size svnrepository.repositoryEntryHistory=Repository Entry History +svnrepository.filesPerFileType=Files Per File Type svnrepository.mostActiveCommitters=Most Active Committers svnrepository.mostActiveFiles=Most Active Files Modified: trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_fr.properties =================================================================== --- trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_fr.properties 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_fr.properties 2005-12-21 15:13:55 UTC (rev 1917) @@ -17,6 +17,7 @@ svnrepository.totalRepositoryEntries=Nombre total des entr\u00e9es dans le d\u00e9p\u00f4t svnrepository.totalFileSize=Taille totale des fichiers svnrepository.repositoryEntryHistory=Historique des entr\u00e9es dans le d\u00e9p\u00f4t +svnrepository.filesPerFileType=fr_Files Per File Type svnrepository.mostActiveCommitters=Les auteurs les plus actifs svnrepository.mostActiveFiles=Les fichiers les plus actifs Modified: trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_hu.properties =================================================================== --- trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_hu.properties 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_hu.properties 2005-12-21 15:13:55 UTC (rev 1917) @@ -17,6 +17,7 @@ svnrepository.totalRepositoryEntries=Bejegyzk szesen svnrepository.totalFileSize=Fok szmte svnrepository.repositoryEntryHistory=Bejegyzk az Idggvn +svnrepository.filesPerFileType=Fok KiterjesztSzerint svnrepository.mostActiveCommitters=Legaktbb Fejlesztsvnrepository.mostActiveFiles=Legaktbb Fok Modified: trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_pl.properties =================================================================== --- trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_pl.properties 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/web-portlet/WEB-INF/classes/hu/midori/kosmos/portlet/svn/svn_monitoring_pl.properties 2005-12-21 15:13:55 UTC (rev 1917) @@ -17,6 +17,7 @@ svnrepository.totalRepositoryEntries=Ca\u0142kowita liczba pozycji svnrepository.totalFileSize=Suma rozmiar\u00f3w plik\u00f3w svnrepository.repositoryEntryHistory=Historia pozycji +svnrepository.filesPerFileType=pl_Files Per File Type svnrepository.mostActiveCommitters=Najbardziej aktywni autorzy svnrepository.mostActiveFiles=Najbardziej aktywne pliki Modified: trunk/labs/kosmos/web-portlet/pages/svn_monitoring_repository_details.jsp =================================================================== --- trunk/labs/kosmos/web-portlet/pages/svn_monitoring_repository_details.jsp 2005-12-21 12:43:30 UTC (rev 1916) +++ trunk/labs/kosmos/web-portlet/pages/svn_monitoring_repository_details.jsp 2005-12-21 15:13:55 UTC (rev 1917) @@ -7,23 +7,54 @@ <tr class="portlet-section-body"> <td><fmt:message key="svnrepository.dirs"/>:</td> <td><fmt:formatNumber value="${repository.dirs}"/></td> + <td/> </tr> <tr class="portlet-section-alternate"> <td><fmt:message key="svnrepository.files"/>:</td> <td><fmt:formatNumber value="${repository.files}"/></td> + <td/> </tr> <tr class="portlet-section-body"> <td><fmt:message key="svnrepository.totalRepositoryEntries"/>:</td> <td><fmt:formatNumber value="${repository.dirs + repository.files}"/></td> + <td/> </tr> <tr class="portlet-section-alternate"> <td><fmt:message key="svnrepository.totalFileSize"/>:</td> <td><fmt:formatNumber value="${repository.totalFileSize}"/> B</td> + <td/> </tr> <tr class="portlet-section-body"> <td><fmt:message key="svnrepository.repositoryEntryHistory"/>:</td> <td><img src="<c:out value="${repository.repoEntriesPerWeekChartUrl}"/>" title="<fmt:message key="svnrepository.repositoryEntryHistory"/>"/></td> + <td/> </tr> + <tr class="portlet-section-alternate"> + <td><fmt:message key="svnrepository.filesPerFileType"/>:</td> + <td><img src="<c:out value="${repository.filesPerFileTypeChartUrl}"/>" title="<fmt:message key="svnrepository.filesPerFileType"/>"/></td> + <td> + <c:set var="listSize" value="${fn:length(repository.filesPerFileType)}"/> + <c:set var="listIndex" value="0"/> + <%@include file="includes/table_expander.jsp" %> + + <table> + <c:forEach var="item" items="${repository.filesPerFileType}" varStatus="status"> + <c:choose> + <c:when test="${status.index < 10}"> + <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" class="portlet-section-body"> + </c:when> + <c:otherwise> + <tr id="row-<portlet:namespace/>-0-<c:out value="${status.index}"/>" style="display: none" class="portlet-section-body"> + </c:otherwise> + </c:choose> + <td><c:out value="${1 + status.index}"/></td> + <td><c:out value="${item.key}"/></td> + <td><c:out value="${item.value}"/></td> + </tr> + </c:forEach> + </table> + </td> + </tr> <%@include file="includes/table_footer.jsp"%> </table> |