本文整理汇总了C#中IRepository.Queryable方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Queryable方法的具体用法?C# IRepository.Queryable怎么用?C# IRepository.Queryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.Queryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistributionData
protected override double[] DistributionData(IRepository repository)
{
var commits = repository.Queryable<Commit>()
.Select(c => new
{
Revision = c.Revision,
Message = c.Message
}).ToArray();
List<double> deletedToAdded = new List<double>();
double added, deleted;
foreach (var c in commits)
{
var code = repository.SelectionDSL()
.Commits()
.RevisionIs(c.Revision)
.Modifications()
.InCommits()
.CodeBlocks()
.InModifications().Fixed();
added = code.Added().CalculateLOC();
if (added > 0)
{
deleted = -code.Deleted().CalculateLOC();
deletedToAdded.Add(deleted / added);
}
}
return deletedToAdded.ToArray();
}
示例2: Calc
public override void Calc(IRepository repository)
{
base.Calc(repository);
x = new double[dates.Count()];
tdd = new double[dates.Count()];
dd = new double[dates.Count()];
string revision = null;
for (int i = 0; i < dates.Length; i++)
{
x[i] = (dates[i] - dates[0]).TotalDays;
var code = repository.SelectionDSL()
.Commits()
.DateIsLesserOrEquelThan(dates[i])
.Do(c =>
revision = repository.Queryable<Commit>().Single(cc =>
cc.OrderedNumber == c.Max(ccc => ccc.OrderedNumber)
).Revision
)
.Files()
.InDirectory(TargetDir)
.Modifications()
.InCommits()
.InFiles()
.CodeBlocks()
.InModifications();
tdd[i] = code.CalculateTraditionalDefectDensity(revision);
dd[i] = code.CalculateDefectDensity(revision);
}
}
示例3: BuildData
public override IDictionary<string, object> BuildData(IRepository repositories)
{
Dictionary<string, object> result = new Dictionary<string, object>();
var authors = repositories.Queryable<Commit>()
.Select(x => x.Author)
.Distinct().ToList();
var codeByAuthor = (from author in authors select new
{
Name = author,
AddedCode = repositories.SelectionDSL()
.Commits().AuthorIs(author)
.Files().InDirectory(TargetDir)
.Modifications().InFiles()
.CodeBlocks().InModifications().AddedInitiallyInCommits()
.Fixed(),
}).ToList();
var statByAuthor =
from a in codeByAuthor
let authorCommits = a.AddedCode.Commits().Again().Count()
let authorFixes = a.AddedCode.Commits().Again().AreBugFixes().Count()
let authorRefactorings = a.AddedCode.Commits().Again().AreRefactorings().Count()
select new
{
name = a.Name,
fixes = (double) authorFixes / authorCommits * 100,
refactorings = (double) authorRefactorings / authorCommits * 100
};
result.Add("authors", statByAuthor.OrderBy(x => x.name).ToArray());
return result;
}
示例4: BuildData
public override IDictionary<string, object> BuildData(IRepository repositories)
{
Dictionary<string, object> result = new Dictionary<string, object>();
var authors = repositories.Queryable<Commit>()
.Select(x => x.Author)
.Distinct().ToList();
var codeByAuthor = (from author in authors select new
{
Name = author,
AddedCode = repositories.SelectionDSL()
.Commits().AuthorIs(author)
.Files().InDirectory(TargetDir)
.Modifications().InFiles()
.CodeBlocks().InModifications().AddedInitiallyInCommits()
.Fixed(),
RemovedCode = repositories.SelectionDSL()
.Commits().AuthorIs(author)
.Files().InDirectory(TargetDir)
.Modifications().InCommits().InFiles()
.CodeBlocks().InModifications().Deleted()
.Fixed()
}).ToList();
var statByAuthor =
from a in codeByAuthor
select new
{
name = a.Name,
added_loc = a.AddedCode.CalculateLOC() / (a.AddedCode.CalculateLOC() - a.RemovedCode.CalculateLOC()) * 100,
removed_loc = -a.RemovedCode.CalculateLOC() / (a.AddedCode.CalculateLOC() - a.RemovedCode.CalculateLOC()) * 100
};
result.Add("authors", statByAuthor.OrderBy(x => x.name).ToArray());
return result;
}
示例5: CheckEmptyCodeBlocks
private void CheckEmptyCodeBlocks(IRepository repository, string testRevision)
{
foreach (var zeroCodeBlock in
from cb in repository.Queryable<CodeBlock>()
join m in repository.Queryable<Modification>() on cb.ModificationID equals m.ID
join f in repository.Queryable<ProjectFile>() on m.FileID equals f.ID
join c in repository.Queryable<Commit>() on m.CommitID equals c.ID
let testRevisionNumber = repository.Queryable<Commit>()
.Single(x => x.Revision == testRevision)
.OrderedNumber
where
c.OrderedNumber <= testRevisionNumber
&&
cb.Size == 0
select new { path = f.Path, revision = c.Revision }
)
{
Console.WriteLine("Empty code block in file {0} in revision {1}!",
zeroCodeBlock.path, zeroCodeBlock.revision
);
}
}
示例6: CheckDeletedCodeBlocksVsAdded
private void CheckDeletedCodeBlocksVsAdded(IRepository repository, string testRevision)
{
foreach (var codeBlockWithWrongTarget in
(
from cb in repository.Queryable<CodeBlock>()
join m in repository.Queryable<Modification>() on cb.ModificationID equals m.ID
join f in repository.Queryable<ProjectFile>() on m.FileID equals f.ID
join c in repository.Queryable<Commit>() on m.CommitID equals c.ID
let testRevisionNumber = repository.Queryable<Commit>()
.Single(x => x.Revision == testRevision)
.OrderedNumber
let addedCodeID = cb.Size < 0 ? cb.TargetCodeBlockID : cb.ID
where
c.OrderedNumber <= testRevisionNumber
group cb.Size by addedCodeID into g
select new
{
CodeSize = g.Sum(),
Path = repository.Queryable<ProjectFile>()
.Single(f => f.ID == repository.Queryable<Modification>()
.Single(m => m.ID == repository.Queryable<CodeBlock>()
.Single(cb => cb.ID == g.Key).ModificationID
).FileID
).Path,
AddedCodeSize = repository.Queryable<CodeBlock>()
.Single(cb => cb.ID == g.Key)
.Size,
Revision = repository.Queryable<Commit>()
.Single(c => c.ID == repository.Queryable<Modification>()
.Single(m => m.ID == repository.Queryable<CodeBlock>()
.Single(cb => cb.ID == g.Key).ModificationID
).CommitID
).Revision
}
).Where(x => x.CodeSize < 0)
)
{
Console.WriteLine("There are too many deleted code blocks for code block in revision {0} for file {1} for code with size {2}. Code size {3} should be greater or equal to 0",
codeBlockWithWrongTarget.Revision,
codeBlockWithWrongTarget.Path,
codeBlockWithWrongTarget.AddedCodeSize,
codeBlockWithWrongTarget.CodeSize
);
}
}
示例7: CheckCodeSizeForDeletedFiles
private void CheckCodeSizeForDeletedFiles(IRepository repository, string testRevision)
{
foreach (var codeSizeForDeletedFile in
(
from cb in repository.Queryable<CodeBlock>()
join m in repository.Queryable<Modification>() on cb.ModificationID equals m.ID
join f in repository.Queryable<ProjectFile>() on m.FileID equals f.ID
join c in repository.Queryable<Commit>() on m.CommitID equals c.ID
let testRevisionNumber = repository.Queryable<Commit>()
.Single(x => x.Revision == testRevision)
.OrderedNumber
where
c.OrderedNumber <= testRevisionNumber
&&
f.DeletedInCommitID != null
&&
repository.Queryable<Commit>()
.Single(x => x.ID == f.DeletedInCommitID)
.OrderedNumber <= testRevisionNumber
group cb by f into g
select new
{
Path = g.Key.Path,
DeletedInRevision = repository.Queryable<Commit>()
.Single(x => x.ID == g.Key.DeletedInCommitID)
.Revision,
CodeSize = g.Sum(x => x.Size)
}
).Where(x => x.CodeSize != 0)
)
{
Console.WriteLine("For file {0} deleted in revision {1} code size is not 0. {2} should be 0.",
codeSizeForDeletedFile.Path,
codeSizeForDeletedFile.DeletedInRevision,
codeSizeForDeletedFile.CodeSize
);
}
}
示例8: BuildData
public override IDictionary<string, object> BuildData(IRepository repositories)
{
Dictionary<string, object> result = new Dictionary<string, object>();
var authors = repositories.Queryable<Commit>()
.Select(x => x.Author)
.Distinct().ToList();
var codeByAuthor = (from author in authors select new
{
Name = author,
}).ToList();
var statByAuthor =
from a in codeByAuthor
select new
{
name = a.Name,
};
result.Add("authors", statByAuthor.OrderBy(x => x.name).ToArray());
List<object> monthObjs = new List<object>();
List<object> fixObjs = new List<object>();
List<object> refactObjs = new List<object>();
List<object> restObjs = new List<object>();
DateTime statFrom = repositories.Queryable<Commit>().Min(x => x.Date);
DateTime statTo = repositories.Queryable<Commit>().Max(x => x.Date);
List<DateTime> monthes = new List<DateTime>();
DateTime m = new DateTime(statFrom.Year, statFrom.Month, 1);
while (m < statTo)
{
monthes.Add(m);
m = m.AddMonths(1);
}
foreach (var month in monthes)
{
DateTime nextMonth = month.AddMonths(1);
var monthCommits = repositories.SelectionDSL()
.Commits()
.DateIsGreaterOrEquelThan(month)
.DateIsLesserThan(nextMonth)
.Fixed();
int monthFixCommitsCount = monthCommits.AreBugFixes().Count();
int monthRefactCommitsCount = monthCommits.AreRefactorings().Count();
int monthRestCommitsCount = monthCommits.Count() - monthFixCommitsCount - monthRefactCommitsCount;
foreach (var author in authors)
{
int monthAuthFixCommits = monthCommits.AuthorIs(author).AreBugFixes().Count();
int monthAuthRefactCommits = monthCommits.AuthorIs(author).AreRefactorings().Count();
int monthRestAuthCommits = monthCommits.AuthorIs(author).Count() - monthAuthFixCommits - monthAuthRefactCommits;
double monthAuthFixCommitsCount = monthFixCommitsCount == 0 ? 0 : (monthAuthFixCommits / monthFixCommitsCount * 100);
double monthAuthRefactCommitsCount = monthRefactCommitsCount == 0 ? 0 : (monthAuthRefactCommits / monthRefactCommitsCount * 100);
double monthAuthRestCommitsCount = monthRestCommitsCount == 0 ? 0 : (monthRestAuthCommits / monthRestCommitsCount * 100);
fixObjs.Add(new
{
fix = monthAuthFixCommitsCount
});
refactObjs.Add(new
{
refact = monthAuthRefactCommitsCount
});
restObjs.Add(new
{
rest = monthAuthRestCommitsCount
});
}
monthObjs.Add(new
{
month = month.Year.ToString() + "-" + String.Format("{0:00}", month.Month)
});
}
result.Add("monthes", monthObjs);
result.Add("fixes",fixObjs);
result.Add("refactorings",refactObjs);
result.Add("rests",restObjs);
return result;
}
示例9: Init
public override void Init(IRepository repository)
{
Authors = repository.Queryable<Commit>()
.Select(x => x.Author).Distinct().OrderBy(x => x)
.ToArray();
base.Init(repository);
}
示例10: CheckLinesContent
private bool CheckLinesContent(IRepository repository, IScmData scmData, string testRevision, ProjectFile file, bool resultOnly)
{
IBlame fileBlame = null;
try
{
fileBlame = scmData.Blame(testRevision, file.Path);
}
catch
{
}
if (fileBlame == null)
{
if (! resultOnly)
{
Console.WriteLine("File {0} does not exist.", file.Path);
}
return false;
}
double currentLOC = repository.SelectionDSL()
.Commits().TillRevision(testRevision)
.Files().IdIs(file.ID)
.Modifications().InCommits().InFiles()
.CodeBlocks().InModifications()
.CalculateLOC();
bool correct = currentLOC == fileBlame.Count;
if (! correct)
{
if (! resultOnly)
{
Console.WriteLine("Incorrect number of lines in file {0}. {1} should be {2}",
file.Path, currentLOC, fileBlame.Count
);
}
else
{
return false;
}
}
SmartDictionary<string, int> linesByRevision = new SmartDictionary<string, int>(x => 0);
foreach (var line in fileBlame)
{
linesByRevision[line.Value]++;
}
var codeBySourceRevision =
(
from f in repository.Queryable<ProjectFile>()
join m in repository.Queryable<Modification>() on f.ID equals m.FileID
join cb in repository.Queryable<CodeBlock>() on m.ID equals cb.ModificationID
join c in repository.Queryable<Commit>() on m.CommitID equals c.ID
let addedCodeBlock = repository.Queryable<CodeBlock>()
.Single(x => x.ID == (cb.Size < 0 ? cb.TargetCodeBlockID : cb.ID))
let codeAddedInitiallyInRevision = repository.Queryable<Commit>()
.Single(x => x.ID == addedCodeBlock.AddedInitiallyInCommitID)
.Revision
let testRevisionNumber = repository.Queryable<Commit>()
.Single(x => x.Revision == testRevision)
.OrderedNumber
where
f.ID == file.ID
&&
c.OrderedNumber <= testRevisionNumber
group cb.Size by codeAddedInitiallyInRevision into g
select new
{
FromRevision = g.Key,
CodeSize = g.Sum()
}
).Where(x => x.CodeSize != 0).ToList();
var errorCode =
(
from codeFromRevision in codeBySourceRevision
where
codeFromRevision.CodeSize != linesByRevision[codeFromRevision.FromRevision]
select new
{
SourceRevision = codeFromRevision.FromRevision,
CodeSize = codeFromRevision.CodeSize,
RealCodeSize = linesByRevision[codeFromRevision.FromRevision]
}
).ToList();
correct =
correct
&&
codeBySourceRevision.Count() == linesByRevision.Count
&&
errorCode.Count == 0;
if (! resultOnly)
{
if (codeBySourceRevision.Count() != linesByRevision.Count)
{
Console.WriteLine("Number of revisions file {0} contains code from is incorrect. {1} should be {2}",
file.Path, codeBySourceRevision.Count(), linesByRevision.Count
//.........这里部分代码省略.........
示例11: BuildData
public override IDictionary<string, object> BuildData(IRepository repositories)
{
Dictionary<string, object> result = new Dictionary<string, object>();
var authors = repositories.Queryable<Commit>()
.Select(x => x.Author)
.Distinct().ToList();
var codeByAuthor = (from author in authors
select new
{
Name = author,
}).ToList();
var statByAuthor =
from a in codeByAuthor
select new
{
name = a.Name,
};
result.Add("authors", statByAuthor.OrderBy(x => x.name).ToArray());
DateTime statFrom = repositories.Queryable<Commit>().Min(x => x.Date);
DateTime statTo = repositories.Queryable<Commit>().Max(x => x.Date);
List<object> monthObjs = new List<object>();
List<object> locObjs = new List<object>();
List<DateTime> monthes = new List<DateTime>();
DateTime m = new DateTime(statFrom.Year, statFrom.Month, 1);
while (m < statTo)
{
monthes.Add(m);
m = m.AddMonths(1);
}
foreach (var month in monthes)
{
DateTime nextMonth = month.AddMonths(1);
var totalMonthCommits = repositories.SelectionDSL()
.Commits()
.DateIsLesserThan(nextMonth)
.Fixed();
foreach (var author in authors)
{
double authorLoc = totalMonthCommits
.AuthorIs(author).Files().InDirectory(TargetDir)
.Modifications().InCommits().InFiles()
.CodeBlocks().InModifications().Fixed().CalculateLOC();
locObjs.Add(new
{
loc = authorLoc
});
}
monthObjs.Add(new
{
month = String.Format("{0:00}", month.Month) + "-" + month.Year.ToString()
});
}
result.Add("monthes", monthObjs);
result.Add("locs", locObjs);
return result;
}
示例12: Init
public override void Init(IRepository repository)
{
authorByRevision = repository.SelectionDSL()
.Commits().TillRevision(model.PredictionRelease)
.ToDictionary(x => x.Revision, x => x.Author);
int releaseRevisionOrderedNumber = repository.Queryable<Commit>()
.Single(x => x.Revision == model.PredictionRelease).OrderedNumber;
var codeByAuthorAndFile =
(
from cb in repository.Queryable<CodeBlock>()
join m in repository.Queryable<Modification>() on cb.ModificationID equals m.ID
join c in repository.Queryable<Commit>() on m.CommitID equals c.ID
join f in repository.Queryable<ProjectFile>() on m.FileID equals f.ID
where
cb.Size > 0
&&
c.OrderedNumber <= releaseRevisionOrderedNumber
group cb by new { Author = c.Author, FileID = f.ID } into g
select new
{
Author = g.Key.Author,
FileID = g.Key.FileID,
CodeSize = g.Sum(x => x.Size)
}
).ToArray();
var allFiles = model.AllFiles.Select(x => x.ID).ToArray();
var allAuthors = repository.SelectionDSL()
.Commits().TillRevision(model.PredictionRelease)
.Select(x => x.Author).Distinct().ToArray();
int numberOfFiles = allFiles.Count();
int numberOfAuthors = allAuthors.Count();
int numberOfEquations = numberOfFiles + numberOfAuthors + 1;
double[,] equations = new double[numberOfEquations,numberOfEquations];
double[] results = new double[numberOfEquations];
int equation = 0;
double locAdded = codeByAuthorAndFile.Sum(x => x.CodeSize);
for (int i = 0; i < allFiles.Length; i++)
{
double locAddedInFile = codeByAuthorAndFile
.Where(x => x.FileID == allFiles[i])
.Sum(x => x.CodeSize);
equations[numberOfEquations-1, i] = locAddedInFile / locAdded;
equations[equation, i] = 1;
if (locAddedInFile > 0)
{
double dcd = repository.SelectionDSL()
.Commits()
.TillRevision(model.PredictionRelease)
.Files()
.IdIs(allFiles[i])
.Modifications().InCommits().InFiles()
.CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease);
for (int j = 0; j < allAuthors.Length; j++)
{
double locAddedInFileByAuthor = codeByAuthorAndFile
.Where(x => x.FileID == allFiles[i] && x.Author == allAuthors[j])
.Sum(x => x.CodeSize);
equations[equation, numberOfFiles + j] = (locAddedInFileByAuthor / locAddedInFile);
}
results[equation] = dcd;
}
equation++;
}
for (int i = 0; i < allAuthors.Length; i++)
{
double locAddedByAuthor = codeByAuthorAndFile
.Where(x => x.Author == allAuthors[i])
.Sum(x => x.CodeSize);
equations[numberOfEquations-1, numberOfFiles + i] = locAddedByAuthor / locAdded;
equations[equation, numberOfFiles + i] = 1;
if (locAddedByAuthor > 0)
{
double dcd = repository.SelectionDSL()
.Commits()
.AuthorIs(allAuthors[i])
.TillRevision(model.PredictionRelease)
.Modifications().InCommits()
.CodeBlocks().InModifications().CalculateDefectCodeDensity(model.PredictionRelease);
for (int j = 0; j < allFiles.Length; j++)
{
double locAddedByAuthorInFile = codeByAuthorAndFile
.Where(x => x.Author == allAuthors[i] && x.FileID == allFiles[j])
.Sum(x => x.CodeSize);
equations[equation, j] = (locAddedByAuthorInFile / locAddedByAuthor);
}
results[equation] = dcd;
}
equation++;
}
results[numberOfEquations-1] = repository.SelectionDSL()
//.........这里部分代码省略.........
示例13: BuildData
public override IDictionary<string, object> BuildData(IRepository repository)
{
Dictionary<string,object> result = new Dictionary<string,object>();
int commits_count = repository.Queryable<Commit>().Count();
int commits_fix_count = repository.SelectionDSL().Commits().AreBugFixes().Count();
string commits_fix_percent = ((double)commits_fix_count / commits_count * 100).ToString("F02");
int commits_refactoring_count = repository.SelectionDSL().Commits().AreRefactorings().Count();
string commits_refactoring_percent = ((double)commits_refactoring_count / commits_count * 100).ToString("F02");
DateTime statfrom = repository.Queryable<Commit>().Min(x => x.Date);
DateTime statto = repository.Queryable<Commit>().Max(x => x.Date);
result.Add("stat_date", DateTime.Now.ToString());
result.Add("stat_period_from", statfrom);
result.Add("stat_period_to", statto);
result.Add("stat_period_days", (statto - statfrom).Days);
result.Add("stat_period_years", ((statto - statfrom).TotalDays / 365).ToString("F01"));
result.Add("authors_count",
repository.Queryable<Commit>().Select(x => x.Author).Distinct().Count()
);
result.Add("commits_count", commits_count);
result.Add("commits_fix_count", commits_fix_count);
result.Add("commits_fix_percent", commits_fix_percent);
result.Add("commits_refactoring_count", commits_refactoring_count);
result.Add("commits_refactoring_percent", commits_refactoring_percent);
var files = repository.SelectionDSL()
.Files().InDirectory(TargetDir)
.Fixed();
result.Add("files_current",
files.Exist().Count()
);
result.Add("files_added",
files.Count()
);
result.Add("files_removed",
files.Deleted().Count()
);
var code = repository.SelectionDSL()
.Files().InDirectory(TargetDir)
.Modifications().InFiles()
.CodeBlocks().InModifications()
.Fixed();
result.Add("loc_current",
code.CalculateLOC()
);
result.Add("loc_added",
code.Added().CalculateLOC()
);
result.Add("loc_removed",
- code.Deleted().CalculateLOC()
);
result.Add("tdd",
code.CalculateTraditionalDefectDensity().ToString("F03")
);
result.Add("dd",
code.CalculateDefectDensity().ToString("F03")
);
return result;
}
示例14: BuildData
public override IDictionary<string, object> BuildData(IRepository repository)
{
Dictionary<string,object> result = new Dictionary<string,object>();
double totalLoc = repository.SelectionDSL()
.Files().InDirectory(TargetDir)
.Modifications().InFiles()
.CodeBlocks().InModifications().CalculateLOC();
List<object> releaseObjects = new List<object>();
var releases = repository.AllReleases();
releases.Add(repository.LastRevision(), "upcoming");
DateTime statFrom = repository.Queryable<Commit>().Min(x => x.Date);
string prevRelease = null;
foreach (var release in releases)
{
var releaseCommits = repository.SelectionDSL()
.Commits()
.AfterRevision(prevRelease)
.TillRevision(release.Key)
.Fixed();
var releaseCode = releaseCommits
.Files()
.InDirectory(TargetDir)
.Modifications()
.InCommits()
.InFiles()
.CodeBlocks()
.InModifications()
.Fixed();
var totalReleaseCommits = repository.SelectionDSL()
.Commits()
.TillRevision(release.Key)
.Fixed();
var totalReleaseCode = totalReleaseCommits
.Files()
.InDirectory(TargetDir)
.Modifications()
.InCommits()
.InFiles()
.CodeBlocks()
.InModifications()
.Fixed();
DateTime releaseStatFrom = releaseCommits.Min(x => x.Date);
DateTime releaseStatTo = releaseCommits.Max(x => x.Date);
int releaseCommitsCount = releaseCommits.Count();
int releaseAuthorsCount = releaseCommits.Select(c => c.Author).Distinct().Count();
int releaseFixesCount = releaseCommits.AreBugFixes().Count();
int releaseFilesCount = repository.SelectionDSL()
.Files().ExistInRevision(release.Key).Count();
int releaseTouchedFilesCount = releaseCommits
.Files()
.ExistInRevision(release.Key)
.TouchedInCommits()
.Count();
int releaseDefectiveFilesCount = releaseCode
.DefectiveFiles(prevRelease, null)
.ExistInRevision(release.Key)
.Count();
int totalReleaseCommitsCount = totalReleaseCommits.Count();
int totalReleaseAuthorsCount = totalReleaseCommits.Select(c => c.Author).Distinct().Count();
int totalReleaseFixesCount = totalReleaseCommits.AreBugFixes().Count();
var totalReleaseLoc = totalReleaseCode.CalculateLOC();
var releaseRemainLoc = releaseCode.Added().CalculateLOC() + releaseCode.ModifiedBy().CalculateLOC();
var totalReleaseAddedLoc = totalReleaseCode.Added().CalculateLOC();
var releaseAddedLoc = releaseCode.Added().CalculateLOC();
double releaseDD = releaseCode.CalculateDefectDensity();
double totalReleaseDD = totalReleaseCode.CalculateDefectDensity();
double postReleaseDD = releaseDD - releaseCode.CalculateDefectDensity(release.Key);
releaseObjects.Add(new
{
tag = release.Value,
commits = string.Format("{0} ({1})",
releaseCommitsCount,
totalReleaseCommitsCount
),
days = string.Format("{0} ({1})",
(releaseStatTo - releaseStatFrom).Days,
(releaseStatTo - statFrom).Days
),
authors = string.Format("{0} ({1})",
releaseAuthorsCount,
totalReleaseAuthorsCount
),
files = releaseFilesCount,
files_changed = string.Format(
"{0} ({1}%)",
releaseTouchedFilesCount,
(((double)releaseTouchedFilesCount / releaseFilesCount) * 100).ToString("F02")
),
files_defective = string.Format(
"{0} ({1}%)",
//.........这里部分代码省略.........
示例15: GetDates
protected DateTime[] GetDates(IRepository repository)
{
List<DateTime> dates = new List<DateTime>();
DateTime min = repository.Queryable<Commit>().Min(c => c.Date);
DateTime max = repository.Queryable<Commit>().Max(c => c.Date);
DateTime date = min;
switch (DatePeriod)
{
case DatePeriod.DAY: date = date.StartOfDay(); break;
case DatePeriod.WEEK: date = date.StartOfWeek(); break;
case DatePeriod.MONTH: date = date.StartOfMonth(); break;
case DatePeriod.QUARTER: date = date.StartOfQuarter(); break;
case DatePeriod.YEAR: date = date.StartOfYear(); break;
default: break;
}
DateTime prevDate = date;
while (prevDate < max)
{
dates.Add(date);
prevDate = date;
switch (DatePeriod)
{
case DatePeriod.DAY: date = date.AddDays(1); break;
case DatePeriod.WEEK: date = date.AddWeeks(1); break;
case DatePeriod.MONTH: date = date.AddMonths(1); break;
case DatePeriod.QUARTER: date = date.AddQuarters(1); break;
case DatePeriod.YEAR: date = date.AddYears(1); break;
default: break;
}
}
if (dates.Count > 0 && dates.First() < min)
{
dates[0] = min;
}
if (dates.Count > 1 && dates.Last() > max)
{
dates[dates.Count-1] = max;
}
return dates.ToArray();
}