Click here to Skip to main content
Click here to Skip to main content

Repository Utility - Github-style Activity Chart

, 18 Jul 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Creates activity charts for SVN repositories

Chart

Introduction

The chart above shows my activity in one of the projects. It looks like Github activity chart but in fact it displays SVN repository activity. Do you want one for your SVN repository? Continue reading, if your answer is yes.

Background

SVN was my first choice for source control and I do not see a reason to change it. But of course, I used Github and I saw their activity charts and I wished to see such charts for my SVN repositories. So I decided to create a tool to visualize a repository activity.

The general structure of the solution is shown in Diagram 1.

Solution

Repository Connection

The tool gets a log history from an SVN repository. But there are many source control systems, more or less popular, with different APIs. To retrieve data from others repository types, clients should provide an implementation for IRepositoryConnection interface with a single method IList<RevisionInfo> LoadHistory(RepositoryInfo repo), where RevisionInfo is a class with common revision parameters (Number, Time, Author, Comment, FileCount) and RepositoryInfo is a container for setting needed to connect a repository (Uri or Path to storage, ProjectName, optional MinRevision and MaxRevision)

The only implementation I have by default is SvnRepositoryConnection. It is based on SharpSvn library.

Evaluation Logic

Most calculations are performed in RepositoryHistoryScanner class. Revisions descriptions are grouped by author (PeriodStats) and then by date (DaylyStats). For each author, max commit count and the longest streak are calculated. Authors stats and the best results are stored in PeriodHistory. The general structure is shown in Diagram 2.

Structure

When all revisions are grouped and the best stats are known, it's time to measure authors activity and evaluate their activity level on each day. I defined ActivityLevel enum {None, Low, Average, High, Great} for this purpose.

The evaluation is extensible and everyone can suggest an implementation for IDaylyStatsMeasure and IActivityDistribution interfaces.

At the first step, a double (non-negative) value is computed for a DaylyStats object by IDaylyStats Measure.Measure(DaylyStats daylyActivity, PeriodHistory history). At the second step, an activity level is returned by IActivityDistribution.GetLevel(double measure) method. Different measures and distributions can produce quiet different results.

I implemented 2 types of measures:

  1. RevisionsCountMeasure

    revisionsCountMeasure

  2. LeaderRevisionsCountMeasure

    leaderrevisionsCountMeasure

Both measures produce values in [0; 1] range.

Also, I added two types of distribution – Uniform and Normal. They are shown in Diagrams 3 and 4.

Uniform

StdNormal

Visual Client

To visualize authors' activity according to their activity level, written in DaylyStats, I use a DataGridView control. It contains 7 rows – one for each day of the week. Number of columns depends on length of PeriodHistory. Each cell shows authors activity using back color (white if there was not any contributions and gradations of green for higher levels). When a cell is selected, more details are shown in the bottom of the form. In column headers of grid, I draw names of months.

To use the utility, you should only specify repository location (Uri or Path to a working copy folder) and project name in configuration form. RevisionsCountMeasure and UniformActivityDistribution are selected for measurements by default. You can change them in comboboxes. If you can suggest a good implementation of IDaylyStatsMeasure or IActivityDistribution interfaces, post a comment, please. Optional settings are minimal and maximal number of revision. If necessary, input login and password to get access in Authentication form (see screenshots).

ConfigurationForm

LoginForm

Configuration can be saved in file to avoid unnecessary typing next time you use the tool.

Export charts in .png images

If the project lasts for a long period of time, then width of a chart will be greater than screen width. In this case grid chart can be scrolled horizontally, but it will more difficult to make a good screenshot. So I added a function of export of charts in to .png files. You can use this function in Activity Chart form. Click Print Chart button, select file location and save. Image will be saved and opened automatically .

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alexander Sharykin

Russian Federation Russian Federation
.NET developer
https://github.com/AlexanderSharykin

Comments and Discussions

 
QuestionZIP-File is empty PinmemberW. Kleinschmit11-Jul-14 3:37 
AnswerRe: ZIP-File is empty PinmemberAlexander Sharykin13-Jul-14 20:16 
SuggestionImages? PinmemberNathan Going3-Jul-14 5:07 
GeneralRe: Images? Pinmemberfredatcodeproject3-Jul-14 5:23 
GeneralRe: Images? PinmemberAlexander Sharykin9-Jul-14 19:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 18 Jul 2014
Article Copyright 2014 by Alexander Sharykin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid