* @param latestTime streaks beginning after the survey time frame are not considered
* @param surveyTimeFrameDuration duration of the surveyTimeFrame
* @return the number of micro edit streaks within the surveyTimeFrame (very long streaks are still counted only as one)
*/
public static int countMicroEdits(Repository repository, Artifact artifact, int streakLength, int inBetweenTime, long latestTime, long surveyTimeFrameDuration) {
Artifact currentArtifact = artifact;
Artifact nextArtifact;
long currentTime = currentArtifact.getDate().getTime();
int currentStreak = 1;
int maximumStreak = 0;
String name = currentArtifact.getId().getName();
String branch = currentArtifact.getId().getBranch();
int revision = currentArtifact.getId().getRevision();
int microEditsFound = 0;
// look for micro edits as long as...
while (currentTime > latestTime - surveyTimeFrameDuration // currentTime is not before the start of surveyTimeFrame
&& revision > 0 ) { // we did not hit the bottom of the repository)
revision--;
nextArtifact = repository.getArtifact(new ArtifactIdentifier(name, revision, branch));
if (nextArtifact == null) {
continue;
}
// only test for streaks if we have already reached the surveyTimeFrame
if (currentArtifact.getDate().getTime() <= latestTime) {
// to count as micro edit, two subsequent revisions have to have the same creator and may be no longer than inBetweenTime milliseconds apart
if (currentArtifact.getCreatorName().equals(nextArtifact.getCreatorName()) && currentTime - nextArtifact.getDate().getTime() < inBetweenTime) {
currentStreak++;
if (currentStreak > maximumStreak) {
maximumStreak = currentStreak;
if (maximumStreak == streakLength) { // if streakLength hits the required maximumStreak length, then count a micro edit
microEditsFound++;