public async Task <PagedResult <DatasetVersionSearchResultModel> > FindDatasetsVersions(SearchFilterRequest searchFilterRequest) { SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(searchFilterRequest); ApiResponse <SearchResults <DatasetVersionSearchResultModel> > apiResponse = await PostAsync <SearchResults <DatasetVersionSearchResultModel>, SearchQueryRequest>($"datasets-version-search", request); if (apiResponse.StatusCode == HttpStatusCode.OK) { PagedResult <DatasetVersionSearchResultModel> result = new SearchPagedResult <DatasetVersionSearchResultModel>(searchFilterRequest, apiResponse.Content.TotalCount) { Items = apiResponse.Content.Results }; return(result); } return(null); }
public override IEnumerable <FilterViewModelBase> Create(Item item, SearchQueryRequest searchQueryRequest) { var result = new List <FilterViewModelBase>(); if (item is MapItem mapItem) { result.Add(this.GetQualityFilterViewModel(mapItem, searchQueryRequest)); result.Add(this.GetItemQuantityFilterViewModel(mapItem, searchQueryRequest)); result.Add(this.GetItemRarityFilterViewModel(mapItem, searchQueryRequest)); result.Add(this.GetMonsterPacksizeFilterViewModel(mapItem, searchQueryRequest)); result.Add(this.GetMapTierFilterViewModel(mapItem, searchQueryRequest)); result.Add(this.GetMapBlightedFilterViewModel(searchQueryRequest)); result.Add(this.GetMapBlightRavagedFilterViewModel(searchQueryRequest)); result.Add(this.GetCorruptedFilterViewModel(searchQueryRequest)); result.Add(this.GetIdentifiedFilterViewModel(searchQueryRequest)); } return(result); }
private void CreateShouldTakeMinValueFromQueryRequest(ItemStat itemStat, decimal?expected) { this.itemSearchOptionsMock.Setup(x => x.CurrentValue) .Returns(new ItemSearchOptions { AdvancedQueryOptions = new AdvancedQueryOptions { MinValuePercentageOffset = -0.1m } }); itemStat.Id = "item stat id"; SearchQueryRequest queryRequest = GetQueryRequestWithStatFilter(itemStat.Id, new MinMaxFilter { Min = expected }); MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, queryRequest) as MinMaxStatFilterViewModel; Assert.That(result.Min, Is.EqualTo(expected)); }
public void MapQueryItemShouldNotMapItemLevelIfThresholdIsNotReached() { const int itemLevel = 86; var item = new EquippableItem(ItemRarity.Normal) { ItemLevel = itemLevel - 1 }; this.ItemSearchOptionsMock.Setup(x => x.CurrentValue) .Returns(new ItemSearchOptions { ItemLevelThreshold = itemLevel, League = new League() }); SearchQueryRequest result = this.equippableItemToQueryRequestMapper.MapToQueryRequest(item) as SearchQueryRequest; Assert.IsNull(result.Query.Filters.MiscFilters.ItemLevel); }
public static string PrintDebug(this SearchQueryRequest searchQueryRequest) { StringBuilder sb = new StringBuilder(); sb.Append(String.Format("\n*** Search Query Request ***\nQuery: {0}\n", searchQueryRequest.QueryText)); sb.Append(String.Format("EnableStemming: {0}\n", searchQueryRequest.EnableStemming)); sb.Append(String.Format("EnablePhonetic: {0}\n", searchQueryRequest.EnablePhonetic)); sb.Append(String.Format("EnableNicknames: {0}\n", searchQueryRequest.EnableNicknames)); sb.Append(String.Format("TrimDuplicates: {0}\n", searchQueryRequest.TrimDuplicates)); sb.Append(String.Format("EnableFql: {0}\n", searchQueryRequest.EnableFql)); sb.Append(String.Format("EnableQueryRules: {0}\n", searchQueryRequest.EnableQueryRules)); sb.Append(String.Format("ProcessBestBets: {0}\n", searchQueryRequest.ProcessBestBets)); sb.Append(String.Format("ByPassResultTypes: {0}\n", searchQueryRequest.ByPassResultTypes)); sb.Append(String.Format("ProcessPersonalFavorites: {0}\n", searchQueryRequest.ProcessPersonalFavorites)); //sb.Append(String.Format("GenerateBlockRankLog: {0}\n", searchQueryRequest.GenerateBlockRankLog)); sb.Append(String.Format("IncludeRankDetail: {0}\n", searchQueryRequest.IncludeRankDetail)); sb.Append(String.Format("StartRow: {0}\n", searchQueryRequest.StartRow)); sb.Append(String.Format("RowLimit: {0}\n", searchQueryRequest.RowLimit)); sb.Append(String.Format("RowsPerPage: {0}\n", searchQueryRequest.RowsPerPage)); sb.Append(String.Format("SelectProperties: {0}\n", searchQueryRequest.SelectProperties)); //sb.Append(String.Format("GraphQuery: {0}\n", searchQueryRequest.GraphQuery)); //sb.Append(String.Format("GraphRankingModel: {0}\n", searchQueryRequest.GraphRankingModel)); sb.Append(String.Format("Refiners: {0}\n", searchQueryRequest.Refiners)); //sb.Append(String.Format("RefinementFilters: {0}\n", searchQueryRequest.RefinementFilters)); sb.Append(String.Format("HitHighlightedProperties: {0}\n", searchQueryRequest.HitHighlightedProperties)); sb.Append(String.Format("RankingModelId: {0}\n", searchQueryRequest.RankingModelId)); sb.Append(String.Format("SortList: {0}\n", searchQueryRequest.SortList)); //sb.Append(String.Format("Culture: {0}\n", searchQueryRequest.Culture)); sb.Append(String.Format("SourceId: {0}\n", searchQueryRequest.SourceId)); sb.Append(String.Format("HiddenConstraints: {0}\n", searchQueryRequest.HiddenConstraints)); //sb.Append(String.Format("ResultsUrl: {0}\n", searchQueryRequest.ResultsUrl)); //sb.Append(String.Format("QueryTag: {0}\n", searchQueryRequest.QueryTag)); //sb.Append(String.Format("CollapseSpecifiation: {0}\n", searchQueryRequest.CollapseSpecifiation)); sb.Append(String.Format("QueryTemplate: {0}\n", searchQueryRequest.QueryTemplate)); //sb.Append(String.Format("TrimDuplicatesIncludeId: {0}\n", searchQueryRequest.TrimDuplicatesIncludeId)); sb.Append(String.Format("ClientType: {0}\n", searchQueryRequest.ClientType)); //sb.Append(String.Format("PersonalizationData: {0}\n", searchQueryRequest.PersonalizationData)); sb.Append(String.Format("Accept Type: {0}\n", searchQueryRequest.AcceptType)); sb.Append(String.Format("Http Method Type: {0}\n", searchQueryRequest.HttpMethodType)); sb.Append(String.Format("HTTP URI: {0}\n", searchQueryRequest.GenerateUri())); return(sb.ToString()); }
public async Task <PagedResult <SpecificationSearchResultItem> > FindSpecifications(SearchFilterRequest filterOptions) { SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions); ApiResponse <SearchResults <SpecificationSearchResultItem> > results = await PostAsync <SearchResults <SpecificationSearchResultItem>, SearchQueryRequest>("specifications-search", request); if (results.StatusCode != HttpStatusCode.OK) { return(null); } PagedResult <SpecificationSearchResultItem> result = new SearchPagedResult <SpecificationSearchResultItem>(filterOptions, results.Content.TotalCount) { Items = results.Content.Results, Facets = results.Content.Facets, }; return(result); }
public void CreateShouldReturnResultFromItemSearchQueryRequestMapper() { var item = new EquippableItem(ItemRarity.Rare) { Name = "TestItem" }; var expected = new SearchQueryRequest { League = "Heist" }; this.itemSearchQueryRequestMapperMocks[0].Setup(x => x.CanMap(item)) .Returns(true); this.itemSearchQueryRequestMapperMocks[0].Setup(x => x.MapToQueryRequest(item)) .Returns(expected); IQueryRequest result = this.queryRequestFactory.Create(item); Assert.That(result, Is.EqualTo(expected)); }
public override bool HandleException(Exception ex, SearchQueryRequest searchQueryRequest) { switch (searchQueryRequest.AuthenticationType) { case AuthenticationType.SPO: UserNotification(); Cmdlet.SPOLegacyLogin(searchQueryRequest); break; case AuthenticationType.SPOManagement: UserNotification(); SearchSPIndexCmdlet.AdalLogin(searchQueryRequest, false); break; default: return(false); } return(true); }
public async Task <PagedResult <SpecificationDatasourceRelationshipSearchResultItem> > FindSpecificationAndRelationships(SearchFilterRequest filterOptions) { Guard.ArgumentNotNull(filterOptions, nameof(filterOptions)); SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions); ApiResponse <SearchResults <SpecificationDatasourceRelationshipSearchResultItem> > results = await PostAsync <SearchResults <SpecificationDatasourceRelationshipSearchResultItem>, SearchQueryRequest>("specifications-dataset-relationships-search", request); if (results.StatusCode != HttpStatusCode.OK) { return(null); } PagedResult <SpecificationDatasourceRelationshipSearchResultItem> result = new SearchPagedResult <SpecificationDatasourceRelationshipSearchResultItem>(filterOptions, results.Content.TotalCount) { Items = results.Content.Results }; return(result); }
public async Task <PagedResult <ProviderVersionSearchResult> > SearchMasterProviders(SearchFilterRequest filterOptions) { Guard.ArgumentNotNull(filterOptions, nameof(filterOptions)); SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions); SearchModel searchModel = new SearchModel { PageNumber = filterOptions.Page, Top = filterOptions.PageSize, SearchTerm = filterOptions.SearchTerm, IncludeFacets = filterOptions.IncludeFacets, Filters = filterOptions.Filters ?? new Dictionary <string, string[]>(), FacetCount = filterOptions.FacetCount, SearchMode = filterOptions.SearchMode == ApiClient.Models.SearchMode.All ? Common.Models.Search.SearchMode.All : Common.Models.Search.SearchMode.Any, ErrorToggle = filterOptions.ErrorToggle }; ApiResponse <ProviderVersionSearchResults> results = await SearchMasterProviders(searchModel); if (results.StatusCode == HttpStatusCode.OK) { PagedResult <ProviderVersionSearchResult> result = new SearchPagedResult <ProviderVersionSearchResult>(filterOptions, results.Content.TotalCount) { Items = results.Content.Results, Facets = results.Content.Facets.Select(x => new SearchFacet { Name = x.Name, FacetValues = x.FacetValues.Select(v => new SearchFacetValue { Name = v.Name, Count = v.Count }) }), }; return(result); } else { return(null); } }
private int GetResults(SearchQueryRequest searchQueryRequest) { int totalRows = 0; bool keepTrying = true; IQueryResultProcessor queryResultProcessor = QueryResultProcessorFactory.SelectQueryResultProcessor(ResultProcessor, this); queryResultProcessor.Configure(); // May add required properties to retrieve (e.g. rankdetail etc.) while (keepTrying) { keepTrying = false; try { var requestResponsePair = HttpRequestRunner.RunWebRequest(Up2Date(searchQueryRequest)); var queryResults = GetResultItem(requestResponsePair); totalRows = queryResults.PrimaryQueryResult.TotalRows; queryResultProcessor.Process(queryResults); } catch (RankDetailTooManyResults ex) { WriteWarning("More than 100 results in result set. Resubmitting query with filter to get RankDetail."); searchQueryRequest.QueryText += ex.QueryFilter; keepTrying = true; } catch (Exception ex) { if (!queryResultProcessor.HandleException(ex)) { throw; } } } return(totalRows); }
public void CreateShouldMapAdditionalMinMaxFilterToQuery(int?minValue, int?maxValue, int?expectedMinValue, int?expectedMaxValue) { BindableMinMaxFilterViewModel additionalFilter = new BindableMinMaxFilterViewModel(x => x.Query.Filters.MiscFilters.Quality) { Min = minValue, Max = maxValue, IsEnabled = true }; var advancedFiltersViewModel = GetAdvancedFiltersViewModel(null, new[] { additionalFilter }); SearchQueryRequest result = this.queryRequestFactory.Create(new SearchQueryRequest(), advancedFiltersViewModel) as SearchQueryRequest; Assert.NotNull(result); MinMaxFilter qualityFilter = result.Query.Filters.MiscFilters.Quality; Assert.NotNull(qualityFilter); Assert.That(qualityFilter.Min, Is.EqualTo(expectedMinValue)); Assert.That(qualityFilter.Max, Is.EqualTo(expectedMaxValue)); }
public async Task FindCalculations() { SearchFilterRequest input = new SearchFilterRequest(); SearchQueryRequest expectedRequest = SearchQueryRequest.FromSearchFilterRequest(input); SearchResults <CalculationSearchResult> expectedResults = new SearchResults <CalculationSearchResult>(); GivenTheResponse("calculations-search", expectedResults, HttpMethod.Post); ApiResponse <SearchResults <CalculationSearchResult> > apiResponse = await _client.FindCalculations(input); apiResponse?.StatusCode .Should() .Be(HttpStatusCode.OK); apiResponse .Content .Should() .BeEquivalentTo(expectedResults); AndTheRequestContentsShouldHaveBeen(expectedRequest.AsJson()); }
protected void CreateShouldReturnBindableFilterViewModelWithValueFromQueryRequest(Expression <Func <SearchQueryRequest, IFilter> > expectedBindingExpression, Item item, string text, BoolOptionFilter queryRequestFilter) { // arrange var expected = new BindableFilterViewModel(expectedBindingExpression) { Text = text, IsEnabled = queryRequestFilter.Option }; var searchQueryRequest = new SearchQueryRequest(); SetValueByExpression(expectedBindingExpression, searchQueryRequest, queryRequestFilter); // act IEnumerable <FilterViewModelBase> result = this.AdditionalFilterViewModelsFactory.Create(item, searchQueryRequest); //assert Assert.IsNotNull(result); Assert.IsNotEmpty(result); Assert.That(result, Has.One.Matches <FilterViewModelBase>(x => MatchBindableFilterViewModel(x, expected))); }
public async Task <PagedResult <TestScenarioSearchResultItem> > FindTestScenariosForProvider(SearchFilterRequest filterOptions) { Guard.ArgumentNotNull(filterOptions, nameof(filterOptions)); SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions); ApiResponse <SearchResults <TestScenarioSearchResultItem> > results = await PostAsync <SearchResults <TestScenarioSearchResultItem>, SearchQueryRequest>("testscenario-search", request); if (results.StatusCode == HttpStatusCode.OK) { PagedResult <TestScenarioSearchResultItem> result = new SearchPagedResult <TestScenarioSearchResultItem>(filterOptions, results.Content.TotalCount) { Items = results.Content.Results }; return(result); } else { return(null); } }
public void CreateShouldCreateStatFilters() { var statFilterViewModel = new StatFilterViewModel { Id = "itemStatId", Text = "Trigger Edict of Frost on Kill", IsEnabled = true }; var advancedFiltersViewModel = GetAdvancedFiltersViewModel(new[] { statFilterViewModel }, null); SearchQueryRequest result = this.queryRequestFactory.Create(new SearchQueryRequest(), advancedFiltersViewModel) as SearchQueryRequest; Assert.NotNull(result); Assert.That(result.Query.Stats, Has.Count.EqualTo(1)); StatFilters statFilters = result.Query.Stats.First(); Assert.That(statFilters.Filters, Has.Count.EqualTo(1)); StatFilter statFilter = statFilters.Filters.First(); Assert.That(statFilter.Id, Is.EqualTo(statFilterViewModel.Id)); Assert.That(statFilter.Text, Is.EqualTo(statFilterViewModel.Text)); }
private void SavePresetToFile(SearchConnection searchConnection, SearchQueryRequest searchQueryRequest) { if (!String.IsNullOrWhiteSpace(SavePreset)) { SearchPreset newPreset = new SearchPreset(); var path = GetPresetFilename(SavePreset); newPreset.Name = Path.GetFileNameWithoutExtension(path); newPreset.Path = path; if (!Path.IsPathRooted(SavePreset)) { newPreset.Path = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, newPreset.Path); } newPreset.Connection = searchConnection; newPreset.Request = SetSelectProperties(searchQueryRequest); newPreset.Save(); WriteVerbose("Configuration saved to " + newPreset.Path); } }
public async Task <PagedResult <DatasetSearchResultItem> > FindDatasets(SearchFilterRequest filterOptions) { Guard.ArgumentNotNull(filterOptions, nameof(filterOptions)); SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions); ApiResponse <SearchResults <DatasetSearchResultItem> > results = await PostAsync <SearchResults <DatasetSearchResultItem>, SearchQueryRequest>("datasets-search", request); if (results.StatusCode == HttpStatusCode.OK) { PagedResult <DatasetSearchResultItem> result = new SearchPagedResult <DatasetSearchResultItem>(filterOptions, results.Content.TotalCount) { Items = results.Content.Results, Facets = results.Content.Facets, }; return(result); } else { return(null); } }
public override bool HandleException(Exception ex, SearchQueryRequest searchQueryRequest) { if (DelegateHandler != null) { if (attempt++ < DelegateHandler.MaxAttempts) { int sleepFor = DelegateHandler.SleepBetweenAttemps(attempt); if (sleepFor > 0) { Thread.Sleep(sleepFor); } return(DelegateHandler.HandleException(ex, searchQueryRequest)); } else { RetryExhausted(ex); } } return(false); }
public async Task <ActionResult <ICollection <string> > > Search([FromBody] SearchQueryRequest request, CancellationToken cancellationToken) { if (request == null) { return(BadRequest(new { error = "NULL_REQUEST" })); } if (string.IsNullOrWhiteSpace(request.target)) { return(Ok(_searchTargets)); } if (request.target == "team") { var teams = await _teamRepository.GetAll(cancellationToken); return(Ok(teams.Select(teams => teams.Name).ToList())); } else { return(Ok(_searchTargets)); } }
public void CreateShouldSetGreaterValueAsMaxValueForStatFilter() { const int expectedValue = 65; var statFilterViewModel = new MinMaxStatFilterViewModel { Min = expectedValue, Max = 40, IsEnabled = true }; var advancedFiltersViewModel = GetAdvancedFiltersViewModel(new[] { statFilterViewModel }, null); SearchQueryRequest result = this.queryRequestFactory.Create(new SearchQueryRequest(), advancedFiltersViewModel) as SearchQueryRequest; Assert.NotNull(result); Assert.That(result.Query.Stats, Has.Count.EqualTo(1)); StatFilters statFilters = result.Query.Stats.First(); Assert.That(statFilters.Filters, Has.Count.EqualTo(1)); StatFilter statFilter = statFilters.Filters.First(); Assert.That(statFilter.Value.Min, Is.EqualTo(expectedValue)); Assert.That(statFilter.Value.Max, Is.EqualTo(expectedValue)); }
protected override void MapItemRarity(SearchQueryRequest result, Item item) { }
// PLEASE NOTE: second argument is NOT the default value! public SelectPropertiesListArgumentParser(List <string> list, SearchQueryRequest searchQueryRequest) : base(list) { this.searchQueryRequestSelectProperties = searchQueryRequest.SelectProperties; }
protected override void MapItemName(SearchQueryRequest result, Item item) { result.Query.Name = item.Name; }
protected override void MapItemType(SearchQueryRequest result, Item item) { result.Query.Type = ItemTypeFilterOptions.Prophecy; }
protected BindableMinMaxFilterViewModel GetQualityFilterViewModel(IQualityItem qualityItem, SearchQueryRequest searchQueryRequest) { return(this.CreateBindableMinMaxFilterViewModel( x => x.Query.Filters.MiscFilters.Quality, Resources.QualityColumn, qualityItem.Quality, searchQueryRequest.Query.Filters.MiscFilters.Quality)); }
public abstract IEnumerable <FilterViewModelBase> Create(Item item, SearchQueryRequest searchQueryRequest);
private static void SetAdditionalFilters(IAdvancedFiltersViewModel advancedFiltersViewModel, SearchQueryRequest searchQueryRequest) { foreach (var filterViewModel in advancedFiltersViewModel.AdditionalFilters.OfType <BindableFilterViewModel>()) { SetValueByExpression(filterViewModel.BindingExpression, searchQueryRequest, filterViewModel); } }
private static void SetStatFilters(IAdvancedFiltersViewModel advancedFiltersViewModel, SearchQueryRequest searchQueryRequest) { var enabledStatFilterViewModels = advancedFiltersViewModel.AllStatFilters.Where(f => f.IsEnabled == true); var statFilters = new StatFilters(); foreach (var enabledStatFilterViewModel in enabledStatFilterViewModels) { StatFilter statFilter = CreateStatFilter(enabledStatFilterViewModel); statFilters.Filters.Add(statFilter); } searchQueryRequest.Query.Stats.Clear(); searchQueryRequest.Query.Stats.Add(statFilters); }
private static void SetValueByExpression(Expression <Func <SearchQueryRequest, IFilter> > bindingExpression, SearchQueryRequest searchQueryRequest, BindableFilterViewModel bindableFilterViewModel) { var expressions = bindingExpression.Body.GetExpressionChain().ToList(); object parent = searchQueryRequest; foreach (MemberExpression expression in expressions) { PropertyInfo property = ((PropertyInfo)expression.Member); if (expression == expressions.Last()) { IFilter filter = GetFilter(bindableFilterViewModel); property.SetValue(parent, filter); break; } parent = property.GetValue(parent); } }