public async Task <SymbolSearchResult> SearchAsync(ICollection <string> repositories, string searchTerm, string classification, int maxNumberOfItems) { Classification?parsedClassification = ClassificationEx.TryParse(classification); ElasticResponse <List <DefinitionSearchSpanModel> > results; results = await Provider.SearchByTermInDefinition(repositories, searchTerm, parsedClassification, maxNumberOfItems); //if (searchTerm.Contains(".")) //{ //} //else //{ // results = await _provider.SearchByShortNameAsync(repositories, searchTerm, parsedClassification, maxNumberOfItems); //} List <SymbolSearchResultEntry> convertedEntries = ModelConverter.ToSymbolSearchResults(results.Result); var projectRanks = ProjectRanks; convertedEntries.ForEach(symbol => symbol.Rank = projectRanks.GetOrDefault(symbol.Symbol.ProjectId)); SearchResultSorter.Sort(convertedEntries, searchTerm); return(new SymbolSearchResult { Entries = convertedEntries, Total = results.Total, QueryText = searchTerm }); }
private async Task AddProjectAsync(AnalyzedProject analyzedProject, string targetIndex) { Console.WriteLine("Updating project {0}", analyzedProject.Id); await Provider.RemoveProjectAsync(analyzedProject.Id, targetIndex); var modelProject = ModelConverter.FromObjectModel(analyzedProject); modelProject.DateUploaded = DateTime.UtcNow; await Provider.AddProjectAsync(modelProject, targetIndexName : targetIndex); }
async Task IStorage.AddProjectsAsync(IEnumerable <AnalyzedProject> projects) { foreach (var project in projects) { await AddProjectAsync(project, project.RepositoryName.ToLowerInvariant()); var modelSources = ModelConverter.FromObjectModel(project.AdditionalSourceFiles); await Provider.AddSourcesAsync(project.RepositoryName, modelSources); } }
public async Task <BoundSourceFile> GetBoundSourceFileAsync(ICollection <string> repositories, string projectId, string filePath, bool includeDefinitions = false) { var sourceFile = await Provider.GetSourceFileAsync(repositories, projectId, filePath, includeDefinitions : includeDefinitions); if (sourceFile?.Result == null) { return(null); } return(ModelConverter.ToBoundSourceFile(sourceFile.Result)); }
async Task <ProjectContents> IStorage.GetProjectContentsAsync(ICollection <string> repositories, string projectId) { var project = await Provider.GetProjectAsync(projectId); if (project == null) { return(null); } var sources = await Provider.GetSourcesForProjectAsync(repositories, projectId); return(ModelConverter.ToProjectContents(project?.Result ?? new ProjectModel(projectId, "Unknown Repository"), sources.Result)); }
public async Task <List <SymbolSearchResultEntry> > GetRelatedDefinitions( ICollection <string> repos, string definitionId, string projectId) { ElasticResponse <List <DefinitionSearchSpanModel> > results; results = await Provider.GetRelatedDefinitions(repos, definitionId, projectId); List <SymbolSearchResultEntry> convertedEntries = ModelConverter.ToSymbolSearchResults(results.Result); return(convertedEntries); }
public async Task <SymbolReferenceResult> GetReferencesToSymbolAsync(ICollection <string> repositories, Symbol symbol, int maxNumberOfItems = 100) { var symbols = await Provider.GetReferencesToSymbolAsync(repositories, symbol, maxNumberOfItems); List <SymbolReferenceEntry> entries = ModelConverter.ToSymbolReferences(symbols.Result); return(new SymbolReferenceResult { Entries = entries, Total = symbols.Total, ProjectId = symbol.ProjectId, SymbolId = symbol.Id.Value, SymbolName = symbol.ToString() }); }
public async Task UploadAsync(IRepoFile repoFile, BoundSourceFile boundSourceFile) { await Provider.AddSourcesToIndexAsync(repoFile.Repo.TargetIndex, new[] { ModelConverter.FromObjectModel(boundSourceFile) }); }
async Task <IList <GetDefinitionResult> > IStorage.GetDefinitionsAsync(ICollection <string> repositories, string projectId, string symbolId) { var result = await Provider.GetDefinitionsAsync(repositories, projectId, symbolId, DefaultNumberOfItems); return(ModelConverter.ToDefinitionResult(result.Result)); }