예제 #1
0
        public async Task UpdateSearchStatistics(IReadOnlyCollection <RepositoryQueryParameter> parameters, string query)
        {
            List <string> keywords = QueryStringTokenizer.GetTokens(query);

            foreach (RepositoryQueryParameter repositoryQueryParameter in parameters)
            {
                await this.statisticsService.Update(repositoryQueryParameter, keywords);
            }
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="repoParams"></param>
 /// <param name="projects"></param>
 /// <param name="elapsed"></param>
 /// <param name="queryString"></param>
 /// <param name="isRegex"></param>
 public ManifestQueryResult(IEnumerable <RepositoryInfo> repoParams, IEnumerable <Project> projects,
                            TimeSpan elapsed, string queryString, bool isRegex)
 {
     this.RepositoryQueryParameters = repoParams;
     this.Elapsed     = elapsed;
     this.IsRegex     = isRegex;
     this.QueryString = queryString;
     this.Tokens      = QueryStringTokenizer.GetTokens(queryString);
     this.Projects    = projects.ToList();
 }
예제 #3
0
        public void TestSplit_NullOrEmpty_ReturnEmpty()
        {
            string input = "";

            var result = QueryStringTokenizer.GetTokens(input);

            result.Should().BeEquivalentTo(new List <string>());

            result = QueryStringTokenizer.GetTokens(null);
            result.Should().BeEquivalentTo(new List <string>());
        }
예제 #4
0
        public void TestSplit_StringWithPhrases_WorksOK()
        {
            string input = "Find some \"subqueries with phrases\" inside -exclude";

            var result = QueryStringTokenizer.GetTokens(input);

            result.Should().BeEquivalentTo(new List <string>()
            {
                "Find",
                "some",
                "subqueries with phrases",
                "inside",
                "-exclude"
            });
        }
        public static FilterDefinition <ProjectInfo> BuildProjectsFuzzyTextFilter(string query)
        {
            var tokensUppercase = QueryStringTokenizer.GetTokens(query, true);
            FilterDefinition <ProjectInfo> filter = null;

            foreach (string token in tokensUppercase)
            {
                if (filter == null)
                {
                    filter = BuildProjectsFuzzyTextFilterForToken(token);
                }
                else
                {
                    filter = filter | BuildProjectsFuzzyTextFilterForToken(token);
                }
            }

            return(filter);
        }
        public void Read_PassQueryString_ReturnsExpectedKeysAndValues(string queryString, Dictionary <string, IList <string> > expectedResult)
        {
            var actualTokens = new Dictionary <string, IList <string> >(StringComparer.Ordinal);

            var tokenizer = new QueryStringTokenizer(queryString);

            ReadOnlyMemory <char> key, value;

            while (tokenizer.Read(out key, out value))
            {
                IList <string> values;
                if (!actualTokens.TryGetValue(key.ToString(), out values))
                {
                    values = new List <string>();
                    actualTokens.Add(key.ToString(), values);
                }

                values.Add(value.ToString());
            }

            AssertThatDictionariesContainsSameContent(expectedResult, actualTokens);
        }