private static void Run() { var mongo = new MongoRepository(); var repository = new RepositoryRetriever(); while (true) { var repositoryUrl = mongo.GetUrl(); if (repositoryUrl == null) { Thread.Sleep(1000); continue; } WriteToConsole(string.Format("{0} found", repositoryUrl.Url)); WriteToConsole("Cloning Repository"); repository.AddRepository(repositoryUrl); WriteToConsole("Generating Versions"); GenerateAllVersions(repositoryUrl); WriteToConsole("Calculating Metrics"); CalculateMetrics(repositoryUrl); //WriteToConsole("Removing Url"); //mongo.DeleteUrl(repositoryUrl); WriteToConsole("Complete"); } }
public ActionResult GetProjectTree(string repositoryUrl) { var commits = new MongoRepository().GetCommits().Where(x => x.RepositoryUrl == repositoryUrl); var result = commits.OrderByDescending(x => x.Date).First().Modules.OrderBy(x => x.Name).Select(module => new { label =HttpUtility.HtmlEncode(module.Name), open = false, inode = true, node = HttpUtility.HtmlEncode(module.Name), branch = module.Namespaces.OrderBy(x => x.Name).Select(namespaces => new { label = HttpUtility.HtmlEncode(namespaces.Name), open = false, inode = true, node = HttpUtility.HtmlEncode(module.Name + ">" + namespaces.Name), branch = namespaces.Types.OrderBy(x => x.Name).Select(type => new { label = HttpUtility.HtmlEncode(type.Name), open = false, inode = true, node = HttpUtility.HtmlEncode(module.Name + ">" + namespaces.Name + ">" + type.Name), branch = type.Members.OrderBy(x => x.Name).Select(member => new { label = HttpUtility.HtmlEncode(member.Name), open = false, inode = false, node = HttpUtility.HtmlEncode(module.Name + ">" + namespaces.Name + ">" + type.Name + ">" + member.Name) }) }) }) }); return Json(result, JsonRequestBehavior.AllowGet); }
private static void GenerateAllVersions(RepositoryUrl repositoryUrl) { var mongo = new MongoRepository(); var commits = mongo.GetCommits().Where(x => x.RepositoryUrl.Equals(repositoryUrl.Url)); commits.ToList().ForEach(x => GenerateVersion(repositoryUrl, x.SHA)); }
public ActionResult GetNodeMetrics(string repositoryUrl, string node) { var mongo = new MongoRepository(); var pieces = HttpUtility.HtmlDecode(node).Split('>'); var commits = mongo.GetCommits().Where(x => x.RepositoryUrl == repositoryUrl).OrderBy(x => x.Date); if (pieces.Length == 1) { var result = commits.Select(commit => ExtractModuleInfo(commit, pieces[0])); return Json(result, JsonRequestBehavior.AllowGet); } if (pieces.Length == 2) { var result = commits.Select(commit => ExtractNamespaceInfo(commit, pieces[0], pieces[1])); return Json(result, JsonRequestBehavior.AllowGet); } if (pieces.Length == 3) { var result = commits.Select(commit => ExtractTypeInfo(commit, pieces[0], pieces[1], pieces[2])); return Json(result, JsonRequestBehavior.AllowGet); } if (pieces.Length == 4) { var result = commits.Select(commit => ExtractMemberInfo(commit, pieces[0], pieces[1], pieces[2], pieces[3])); return Json(result, JsonRequestBehavior.AllowGet); } return null; }
public ActionResult Detail(string repositoryUrl) { var project = new MongoRepository().GetProjects().First(x => x.RepositoryUrl == repositoryUrl); var viewModel = new RepositoryDetailViewModel(); viewModel.RepositoryName = project.RepositoryName; viewModel.RepositoryAuthor = project.RepositoryAuthor; viewModel.RepositoryUrl = project.RepositoryUrl; return View(viewModel); }
private static void CalculateMetrics(RepositoryUrl repositoryUrl) { var mongo = new MongoRepository(); var commits = mongo.GetCommits().Where(x => x.RepositoryUrl.Equals(repositoryUrl.Url)).ToList(); commits.ForEach(x => { //try //{ var solution = new Solution(repositoryUrl, x.SHA); solution.Build(); solution.CalculateMetrics(); solution.SaveMetrics(); WriteToConsole(x.SHA + "- OK"); //} //catch (Exception ex) //{ // WriteToConsole(x.SHA + "- ERROR - " + ex.Message); //} }); }
public void SaveMetrics() { var modules = GetCompiledDlls().Select(GetMetricsForDll).ToList(); var mongo = new MongoRepository(); mongo.SaveMetrics(_repositoryUrl, _commit, modules); }
public ActionResult GraphJson2(string repositoryUrl) { var commit = new MongoRepository().GetCommits().Where(x => x.RepositoryUrl == "https://github.com/JeremySkinner/FluentValidation.git").OrderByDescending(x => x.Date).First(); var data = new { name = "FluentValidation", _children = commit.Modules.Select(module => new { name = module.Name, _children = module.Namespaces.Select(namespaceEl => new { name = "", _children = namespaceEl.Types.Select(type => new { name = "", size = type.PowerMetrics == null || type.PowerMetrics.LinesOfCode == 0 ? 1 : type.PowerMetrics.LinesOfCode }) }) }) }; return Json(data, JsonRequestBehavior.AllowGet); }