public static IObservable<TwitterStatus> SearchTweets(this AuthenticateInfo info, string query, string geocode = null, string lang = null, string locale = null, int page = 1, SearchResultType result_type = SearchResultType.mixed, int count = 100, string until = null, long? since_id = null, long? max_id = null, bool include_entities = true) { var param = new Dictionary<string, object>() { {"q", query}, {"geocode", geocode}, {"lang", lang}, {"locale", locale}, {"result_type", result_type.ToString()}, {"count", count}, {"until", until}, {"since_id", since_id}, {"max_id", max_id}, {"include_entities", include_entities} }.Parametalize(); return info.GetOAuthClient() .SetEndpoint(ApiEndpoint.EndpointApiV1a.JoinUrl("search/tweets.json")) .SetParameters(param) .GetResponse() .UpdateRateLimitInfo(info) .ReadString() .DeserializeJson<SearchJson>() .Where(_ => _ != null) .SelectMany(s => s.results) .Where(_ => _ != null) .Select(s => s.Spawn()); }
//--- Methods --- public RankableSearchResultItem Add( uint typeId, SearchResultType type, string title, double score, DateTime modified, double?rating, int ratingCount ) { if (_ratingMidpoint == 0) { rating = rating ?? 0; } else if (rating.HasValue) { var r = rating.Value - _ratingMidpoint; rating = r > 0 ? r / (1 - _ratingMidpoint) : r / _ratingMidpoint; } var item = new RankableSearchResultItem(typeId, type, title, score, modified, rating ?? 0, ratingCount); var key = item.DetailKey; if (_dedup.Contains(key)) { _log.WarnFormat("Found duplicate entry for {0}:{1} in search results. The index is most likely corrupted and should be rebuilt", item.Type, item.TypeId); return(null); } _items.Add(item); _dedup.Add(key); return(item); }
private async void doSearch(string query, SearchResultType searchType) { Dispatcher.BeginInvoke(new Action(() => { _grid_cover.Visibility = Visibility.Visible; })).Wait(); AllMusicApiAgent agent = new AllMusicApiAgent(); IEnumerable <ISearchResult> results; if (searchType == SearchResultType.Artist) { results = await agent.Search <ArtistResult>(query, -1); } else { results = await agent.Search <AlbumResult>(query, -1); } Dispatcher.BeginInvoke(new Action(() => { var viewStyleName = searchType == SearchResultType.Artist ? "GridViewArtists" : "GridViewAlbums"; _listView_results.View = (ViewBase)Resources[viewStyleName]; _listView_results.ItemsSource = results; _grid_cover.Visibility = Visibility.Hidden; })); }
public SearchResultsViewModel(WebSearchResult res, string url) { Score = res.Score; URL = url; Type = (SearchResultType)res.Type; Title = GetTitle(res); }
public static async Task<IEnumerable<TwitterStatus>> SearchAsync( this IOAuthCredential credential, string query, string geoCode = null, string lang = null, string locale = null, SearchResultType resultType = SearchResultType.Mixed, int? count = null, DateTime? untilDate = null, long? sinceId = null, long? maxId = null) { if (credential == null) throw new ArgumentNullException("credential"); if (query == null) throw new ArgumentNullException("query"); var param = new Dictionary<string, object> { {"q", query}, {"geocode", geoCode}, {"lang", lang}, {"locale", locale}, {"result_type", resultType.ToString().ToLower()}, {"count", count}, {"until", untilDate != null ? untilDate.Value.ToString("yyyy-MM-dd") : null}, {"since_id", sinceId}, {"max_id", maxId}, }.ParametalizeForGet(); var client = credential.CreateOAuthClient(); var response = await client.GetAsync(new ApiAccess("search/tweets.json", param)); return await response.ReadAsStatusCollectionAsync(); }
private async Task <IGmtMedia> GetTags(TrackFile file, SearchResultType type) { AllMusicApiAgent agent = new AllMusicApiAgent(); IEnumerable <ISearchResult> results; if (type == SearchResultType.Album) { results = await agent.Search <AlbumResult>(file.Album, 100); } else { results = await agent.Search <ArtistResult>(file.Artist, 100); } ISearchResult mainResult = results.GetBestResult(file, Options.AlgorithmTolerance); if (mainResult == null) { return(null); } if (mainResult.ResultType == SearchResultType.Artist) { return(await agent.GetArtist(mainResult.ID)); } else { return(await agent.GetAlbum(mainResult.ID)); } }
private Yield GetItems_Helper(IEnumerable <ulong> ids, SearchResultType type, Result <IEnumerable <SearchResultItem> > result) { string query; Func <XDoc, uint> getTypeId; switch (type) { case SearchResultType.User: getTypeId = entry => entry["id.user"].AsUInt.Value; query = string.Format("id.user:({0}) ", string.Join(" ", ids.Select(x => x.ToString()).ToArray())); break; case SearchResultType.File: getTypeId = entry => entry["id.file"].AsUInt.Value; query = string.Format("id.file:({0}) ", string.Join(" ", ids.Select(x => x.ToString()).ToArray())); break; case SearchResultType.Comment: getTypeId = entry => entry["id.comment"].AsUInt.Value; query = string.Format("id.comment:({0}) ", string.Join(" ", ids.Select(x => x.ToString()).ToArray())); break; case SearchResultType.Page: getTypeId = entry => entry["id.page"].AsUInt.Value; query = string.Format("(id.page:({0}) AND type:wiki)", string.Join(" ", ids.Select(x => x.ToString()).ToArray())); break; default: result.Return(new SearchResultItem[0]); yield break; } DreamMessage luceneResult = null; yield return(_searchPlug.At("compact").With("wikiid", _wikiid).With("q", query).Get(new Result <DreamMessage>()) .Set(x => luceneResult = x)); if (!luceneResult.IsSuccessful) { throw new Exception("unable to query lucene for details"); } var documents = luceneResult.ToDocument()["document"]; var results = new List <SearchResultItem>(); foreach (var entry in documents) { try { results.Add(new SearchResultItem( getTypeId(entry), type, entry["title"].AsText, entry["score"].AsDouble ?? 0, DbUtils.ToDateTime(entry["date.edited"].AsText) )); } catch (Exception e) { // skip any item we cannot process, but log debug to see if there is a bad value pattern that's not related to stale index data _log.DebugFormat("unable to parse lucene result value because of '{0} ({1})' from: {2}", e.GetType(), e.Message, entry); } } result.Return(results.Distinct(x => x.TypeId)); }
public static async Task <IEnumerable <TwitterStatus> > SearchAsync( this IOAuthCredential credential, string query, string geoCode = null, string lang = null, string locale = null, SearchResultType resultType = SearchResultType.Mixed, int?count = null, DateTime?untilDate = null, long?sinceId = null, long?maxId = null, bool extendedTweet = true) { if (credential == null) { throw new ArgumentNullException("credential"); } if (query == null) { throw new ArgumentNullException("query"); } var param = new Dictionary <string, object> { { "q", query }, { "geocode", geoCode }, { "lang", lang }, { "locale", locale }, { "result_type", resultType.ToString().ToLower() }, { "count", count }, { "until", untilDate != null?untilDate.Value.ToString("yyyy-MM-dd") : null }, { "since_id", sinceId }, { "max_id", maxId }, { "tweet_mode", extendedTweet ? "extended" : null } }.ParametalizeForGet(); var client = credential.CreateOAuthClient(); var response = await client.GetAsync(new ApiAccess("search/tweets.json", param)); return(await response.ReadAsStatusCollectionAsync()); }
public override int GetHashCode() { int hash = 1; if (SearchResultType != global::Google.Cloud.DataCatalog.V1.SearchResultType.Unspecified) { hash ^= SearchResultType.GetHashCode(); } if (SearchResultSubtype.Length != 0) { hash ^= SearchResultSubtype.GetHashCode(); } if (RelativeResourceName.Length != 0) { hash ^= RelativeResourceName.GetHashCode(); } if (LinkedResource.Length != 0) { hash ^= LinkedResource.GetHashCode(); } if (systemCase_ == SystemOneofCase.IntegratedSystem) { hash ^= IntegratedSystem.GetHashCode(); } if (systemCase_ == SystemOneofCase.UserSpecifiedSystem) { hash ^= UserSpecifiedSystem.GetHashCode(); } hash ^= (int)systemCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// Language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes // _timeLimit: Don't search for any tweet after this time private IEnumerator SearchForTweets(string _keyWord, int?_maxTweetsToReturn = null, string _lang = null, SearchResultType _searchType = SearchResultType.recent, DateTime?_timeLimit = null) { yield return(StartCoroutine(GetTwitterApiAccessToken(twitterApiConsumerKey, twitterApiConsumerSecret))); string url = "https://api.twitter.com/1.1/search/tweets.json?q=" + _keyWord; if (_maxTweetsToReturn != null) { url += "&count=" + _maxTweetsToReturn; } if (_lang != null) { url += "&lang=" + _lang; } if (_timeLimit != null) { url += "&until=" + _timeLimit.Value.Year + _timeLimit.Value.Month + _timeLimit.Value.Day; } url += "&result_type=" + _searchType; url += "&include_entities=true"; UnityWebRequest webRequest = UnityWebRequest.Get(url); webRequest.SetRequestHeader("Authorization", "Bearer " + token.access_token); yield return(webRequest.SendWebRequest()); HandleWebRequestResult(webRequest, () => { results = JsonUtility.FromJson <SearchResults>(webRequest.downloadHandler.text); OnFinishedSearching.Raise(results.statuses.Length); }); }
/// <summary> /// Initializes a new instance of the <see cref="Search"/> class. /// </summary> /// <param name="client">the <see cref="RestSharp.RestClient"/> to use for communication</param> /// <param name="resultType">specifies which kind <see cref="SearchResultType"/> should be returned</param> public Search(RestClient client, SearchResultType resultType) { this.client = client; ResultType = resultType; Filters = new List <SearchFilter>(); Sortings = new List <SearchSort>(); }
private static void ParseInnerContent(SearchResult ret, Content content, SearchResultType filter) { SearchResultType type = ContentStaticHelpers.GetSearchResultType(content); int defaultIndex = filter == SearchResultType.All ? 1 : 0; switch (type) { case SearchResultType.Album: ret.Albums.Add(new AlbumResult(content)); break; case SearchResultType.Artist: ret.Artists.Add(new ArtistResult(content)); break; case SearchResultType.Playlist: ret.Playlists.Add(new PlaylistResult(content, defaultIndex)); break; case SearchResultType.Song: ret.Songs.Add(new SongResult(content, defaultIndex)); break; case SearchResultType.Video: ret.Videos.Add(new VideoResult(content, defaultIndex)); break; case SearchResultType.Upload: throw new Exception("We should not be handling Uploads specifically, Uploads should be handled as the type they are (Album, Artist, Song)"); default: throw new Exception($"Unsupported type when parsing generated result: {type}"); } }
public SearchResultsViewModel(WebTVSearchResult res, string url) { URL = url; Score = res.Score; Type = (SearchResultType)(res.Type + 100); Title = GetTitle(res); }
public ControlNameSearchResultViewModel(SearchResultType resultType, string controlName, HighlightedTextInfo highlightedTextInfo) { this.ResultType = resultType; this.ResultTypeText = EnumToStringConverter.Convert(this.ResultType); this.ControlName = controlName; this.HighlightedTextInfo = highlightedTextInfo; }
public IEnumerable <SearchResult> Search(string query, bool matchCasing = false, bool matchWholeWord = false) { this.cachedSearchResults = new Dictionary <int, SearchResult>(); using (this.searchOperationCancellationTokenSource = new CancellationTokenSource()) { CancellationToken token = this.searchOperationCancellationTokenSource.Token; IEnumerable <string> openedAssembliesFilePaths = this.decompilationContext.GetOpenedAssemliesPaths(); foreach (string assemblyFilePath in openedAssembliesFilePaths) { AssemblyDefinition assembly = GlobalAssemblyResolver.Instance.GetAssemblyDefinition(assemblyFilePath); IEnumerable <TypeDefinition> types = assembly.Modules.SelectMany(m => m.GetTypes()).Where(t => !t.IsCompilerGenerated()); foreach (TypeDefinition type in types) { if (token.IsCancellationRequested) { this.searchOperationCancellationTokenSource = null; yield break; } if (this.DoesMatchSearchCriteria(query, type, matchCasing, matchWholeWord)) { yield return(this.AddSearchResultToCache(SearchResultType.DeclaringType, type, type.Name, type)); } IEnumerable <IMemberDefinition> members = type.GetMembersSorted(false, LanguageFactory.GetLanguage(CSharpVersion.V7)); if (members.Count() == 0) { continue; } foreach (IMemberDefinition member in members) { if (token.IsCancellationRequested) { this.searchOperationCancellationTokenSource = null; yield break; } if (this.DoesMatchSearchCriteria(query, member.Name, matchCasing, matchWholeWord)) { SearchResultType memberSearchResultType = this.GetSearchResultTypeFromMemberDefinitionType(member); // Skip adding nested types when traversing the type members as they are added when traversing the module types if (memberSearchResultType != SearchResultType.DeclaringType) { yield return(this.AddSearchResultToCache(memberSearchResultType, type, member.Name, member)); } } if (member is EventDefinition eventDefinition && this.DoesMatchSearchCriteria(query, eventDefinition.EventType, matchCasing, matchWholeWord)) { yield return(this.AddSearchResultToCache(SearchResultType.EventType, type, this.GetFriendlyName(eventDefinition.EventType), eventDefinition)); }
public SearchResult(int id, SearchResultType type, string declaringTypeFilePath, string matchedString, object objectReference) { this.Id = id; this.Type = type; this.DeclaringTypeFilePath = declaringTypeFilePath; this.MatchedString = matchedString; this.ObjectReference = objectReference; }
public SearchResults Add(string name, SearchResultType type, string url, string?label = null) { Add(new SearchResult { Name = name, Type = type, Label = label, Url = url }); return(this); }
private static string SearchResultString(SearchResultType searchResult) { if (searchResult == SearchResultType.Recent) { return("recent"); } return(searchResult == SearchResultType.Popular ? "popular" : "mixed"); }
//--- Constructors --- public SearchResultItem(uint typeId, SearchResultType type, string title, double rank, DateTime modified) { TypeId = typeId; Type = type; Title = title; Modified = modified; Detail = null; _rank = rank; }
public SearchResult(SearchResultType resultType, string controlName, string exampleName, int firstCharIndex, int lastCharIndex) { this.ResultType = resultType; this.ControlName = controlName; this.ExampleName = exampleName; this.FirstCharIndex = firstCharIndex; this.LastCharIndex = lastCharIndex; }
public SearchModel(SearchResultType resultType, string id, ICustomersCommonViewModel parentViewModel, IViewModelsFactory <ICustomersDetailViewModel> customersDetailVmFactory) { _resultType = resultType; _id = id; _parentViewModel = parentViewModel; _customersDetailVmFactory = customersDetailVmFactory; OpenItemCommand = new DelegateCommand(RaiseOpenItemInteractionRequest); }
public SearchResult(JsonObject jsonObject) { _jsonObject = jsonObject; if (jsonObject.ContainsKey("GsearchResultClass")) { _resultType = ParseSearchResultType(((JsonString)jsonObject["GsearchResultClass"]).Value); } }
//--- Constructors --- public SearchResultItem(uint typeId, SearchResultType type, string title, double rank, DateTime modified) { TypeId = typeId; Type = type; Title = title ?? ""; Modified = modified; Detail = null; _rank = rank; }
public SearchModel(SearchResultType resultType, string id, ICustomersCommonViewModel parentViewModel, IViewModelsFactory<ICustomersDetailViewModel> customersDetailVmFactory) { _resultType = resultType; _id = id; _parentViewModel = parentViewModel; _customersDetailVmFactory = customersDetailVmFactory; OpenItemCommand = new DelegateCommand(RaiseOpenItemInteractionRequest); }
public static SearchResult FromBrowseResponse(BrowseResponse result, SearchResultType filter) { SearchResult ret = new SearchResult(); if (result.Contents == null) { // no response return(ret); } SectionListRenderer renderer = result.Contents.SectionListRenderer; if (renderer == null) { int indexToUse = filter == SearchResultType.Upload ? 1 : 0; if (result.Contents.TabbedSearchResultsRenderer != null) { renderer = result.Contents.TabbedSearchResultsRenderer.Tabs[indexToUse].TabRenderer.Content.SectionListRenderer; } else if (result.Contents.SingleColumnBrowseResultsRenderer != null) { renderer = result.Contents.SingleColumnBrowseResultsRenderer.Tabs[indexToUse].TabRenderer.Content.SectionListRenderer; } if (renderer == null) { // TODO: error ? throw ? return(ret); } } List <Content> results = renderer.Contents; //if (results.Count == 1) //{ // // no results? // return ret; //} foreach (var res in results) { if (res.MusicShelfRenderer == null) { continue; } var innerResults = res.MusicShelfRenderer.Contents; foreach (var innerContent in innerResults) { ParseInnerContent(ret, innerContent, filter); } } return(ret); }
public FleetState(FleetState orig) { Formation = orig.Formation; SearchResult = orig.SearchResult; Ships = new ShipState[] { new ShipState(orig.Ships[0]), new ShipState(orig.Ships[1]), new ShipState(orig.Ships[2]), new ShipState(orig.Ships[3]), new ShipState(orig.Ships[4]), new ShipState(orig.Ships[5]) }; }
public IEnumerable <ISearchableService> Get(SearchResultType type) { foreach (var searchable in _searchables) { if (searchable.ResultType == type) { yield return(searchable); } } }
//--- Constructors --- public RankableSearchResultItem( uint typeId, SearchResultType type, string title, double score, DateTime modified, double rating, int ratingCount ) : base(typeId, type, title, score, modified) { Rating = rating; RatingCount = ratingCount; LuceneScore = score; }
public PackageResultsPage SetSearchResult(SearchResultType type) { try { driver.ClickById(GetIdFromSearchResultType(type)); validation.StringLogger.LogWrite("Validation for Set Search Result as " + type + " is Passed"); _test.Log(Status.Pass, "Validation for Set Search Result as " + type + " is Passed"); } catch (Exception) { _test.Log(Status.Fail, "Validation for Set Search Result as " + type + " is Failed"); } return(this); }
internal static SearchResultType GetSearchType(SearchType type) { SearchResultType searchResultType = 0; if (type == SearchType.Preview) { searchResultType |= 1; } if (type == SearchType.Statistics) { searchResultType = searchResultType; } return(searchResultType); }
public SearchParameter([NotNull] string query, SearchResultType resultType = SearchResultType.Mixed, [CanBeNull] string geoCode = null, [CanBeNull] string lang = null, [CanBeNull] string locale = null, int? count = null, DateTime? untilDate = null, long? sinceId = null, long? maxId = null) { _query = query; ResultType = resultType; GeoCode = geoCode; Lang = lang; Locale = locale; Count = count; UntilDate = untilDate; SinceId = sinceId; MaxId = maxId; if (query == null) throw new ArgumentNullException(nameof(query)); }
private string GetSearchParamStringFromFilter(SearchResultType filter) { string param1 = "Eg-KAQwIA"; string param3 = "MABqChAEEAMQCRAFEAo%3D"; string parameters = ""; if (filter == SearchResultType.Upload) { parameters = "agIYAw%3D%3D"; } else { string param2 = ""; switch (filter) { case SearchResultType.Album: param2 = "BAAGAEgACgA"; break; case SearchResultType.Artist: param2 = "BAAGAAgASgA"; break; case SearchResultType.Playlist: param2 = "BAAGAAgACgB"; break; case SearchResultType.Song: param2 = "RAAGAAgACgA"; break; case SearchResultType.Video: param2 = "BABGAAgACgA"; break; case SearchResultType.Upload: param2 = "RABGAEgASgB"; // not sure if this is right, uploads should never get here due to above if clause, but the python code has this break; default: throw new Exception($"Unsupported search filter type: {filter}"); } parameters = param1 + param2 + param3; } return(parameters); }
public static SearchResultType GetSearchResultType(Content content) { int indexOfType = 1; var typeRuns = content.MusicResponsiveListItemRenderer.FlexColumns[indexOfType].MusicResponsiveListItemFlexColumnRenderer.Text.Runs; if (typeRuns == null || typeRuns.Count == 0) { // if it doesn't provide the type there, it's an Upload UploadType ut = GetUploadType(content); switch (ut) { case UploadType.Album: return(SearchResultType.Album); case UploadType.Artist: return(SearchResultType.Artist); case UploadType.Song: return(SearchResultType.Song); default: throw new Exception($"Unsupported UploadType when trying to get SearchResultType: {ut}"); } } string typeStr = typeRuns[0].Text; // assume it's an album since these can be multiple values like 'Single', 'EP', etc. SearchResultType type = SearchResultType.Album; if (!Enum.TryParse <SearchResultType>(typeStr, out type)) { // if we couldn't parse, it could be a song (uploaded or otherwise), if (typeRuns[0].NavigationEndpoint != null && typeRuns[0].NavigationEndpoint.BrowseEndpoint.BrowseId != null) { type = SearchResultType.Song; } } // sometimes the string-to-enum mistakenly results in All... assume album if (type == SearchResultType.All) { type = SearchResultType.Album; } return(type); }
public SearchResult(SearchResultType type, JToken d) { ResultType = type; Score = (int) d["score"]; MusicToken = (string)d["musicToken"]; if (ResultType == SearchResultType.Song) { Title = (string)d["songName"]; Artist = (string)d["artistName"]; } else if (ResultType == SearchResultType.Artist) { Name = (string)d["artistName"]; } }
public SearchResult(SearchResultType type, JToken d) { ResultType = type; Score = (int)d["score"]; MusicToken = (string)d["musicToken"]; if (ResultType == SearchResultType.Song) { Title = (string)d["songName"]; Artist = (string)d["artistName"]; } else if (ResultType == SearchResultType.Artist) { Name = (string)d["artistName"]; } }
/// <summary> /// dedicated API for running searches against the real-time index of recent Tweets. 6-9 days of historical data /// </summary> /// <param name="searchText">search query of 1,000 characters maximum, including operators. Queries may additionally be limited by complexity.</param> /// <param name="maxId"></param> /// <param name="sinceId"></param> /// <param name="untilDate">YYYY-MM-DD format</param> /// <param name="count">Tweets to return Default 20</param> /// <param name="searchResponseType">SearchResult.Mixed (default), SearchResult.Recent, SearchResult.Popular</param> /// <returns></returns> /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/search/tweets </remarks> public async static Task<SearchResponse> SearchFor(this ITwitterSession session, string searchText, SearchResultType searchResponseType, long maxId = 0, long sinceId = 0, string untilDate = "", int count = 20) { var parameters = new TwitterParametersCollection { {"q", searchText.TrimAndTruncate(1000).UrlEncode()}, {"result_type", SearchResultString(searchResponseType)}, }; parameters.Create(since_id:sinceId,max_id:maxId,count:count,include_entities:true); if (!string.IsNullOrWhiteSpace(untilDate)) { parameters.Add("until", untilDate); } return await session.GetAsync(TwitterApi.Resolve("/1.1/search/tweets.json"), parameters) .ContinueWith(c => c.MapToSingle<SearchResponse>()); }
public void SearchAnalytics_LogQueryPick(ulong queryId, double rank, ushort position, uint pageId, SearchResultType type, uint typeId) { Catalog.NewQuery(@"/* SearchAnalytics_LogQueryPick */ INSERT INTO query_result_log (query_id, created, result_position, result_rank, page_id, type, type_id) VALUES (?QUERYID, ?CREATED, ?POSITION, ?RANK, ?PAGEID, ?TYPE, ?TYPEID); UPDATE query_log SET last_result_id = LAST_INSERT_ID() WHERE query_id = ?QUERYID") .With("QUERYID", queryId) .With("CREATED", DateTime.UtcNow) .With("POSITION", position) .With("RANK", rank) .With("PAGEID", pageId) .With("TYPE", type) .With("TYPEID", typeId) .Execute(); }
private string GetIdFromSearchResultType(SearchResultType type) { if (type == SearchResultType.ExactMatch) { return(exactMatchSearchResultId); } if (type == SearchResultType.InExactMatch) { return(inExactMatchSearchResultId); } if (type == SearchResultType.NoMatch) { return(noMatchSearchResultId); } throw new NotImplementedException(); }
private void InitData() { _searchQuery = TestHelper.GenerateString(); _searchQueryParameter = TestHelper.GenerateString(); _searchResultType = SearchResultType.Mixed; _searchTypeParameter = TestHelper.GenerateString(); _maximumNumberOfResults = TestHelper.GenerateRandomInt(); _maximumNumberOfResultsParameter = TestHelper.GenerateString(); _sinceId = TestHelper.GenerateRandomLong(); _sinceIdParameter = TestHelper.GenerateString(); _maxId = TestHelper.GenerateRandomLong(); _maxIdParameter = TestHelper.GenerateString(); _since = DateTime.Now.AddMinutes(TestHelper.GenerateRandomInt()); _sinceParameter = TestHelper.GenerateString(); _until = DateTime.Now.AddMinutes(TestHelper.GenerateRandomInt()); _untilParameter = TestHelper.GenerateString(); _locale = TestHelper.GenerateString(); _localeParameter = TestHelper.GenerateString(); _lang = Language.Afrikaans; _languageParameter = TestHelper.GenerateString(); _geoCode = A.Fake<IGeoCode>(); _geoCodeParameter = TestHelper.GenerateString(); _tweetSearchParameters = A.Fake<ITweetSearchParameters>(); _tweetSearchParameters.SearchQuery = _searchQuery; _tweetSearchParameters.SearchType = _searchResultType; _tweetSearchParameters.MaximumNumberOfResults = _maximumNumberOfResults; _tweetSearchParameters.SinceId = _sinceId; _tweetSearchParameters.MaxId = _maxId; _tweetSearchParameters.Since = _since; _tweetSearchParameters.Until = _until; _tweetSearchParameters.Locale = _locale; _tweetSearchParameters.Lang = _lang; _tweetSearchParameters.GeoCode = _geoCode; }
public ActionResult SearchSite(string query, PostsSearchSortBy? sort, TimeFilter? time, SearchResultType? resultType, int? pageNumber, int? pageSize) { if (sort == null) sort = PostsSearchSortBy.Relevance; if (time == null) time = TimeFilter.All; if (pageNumber == null || pageNumber < 1) pageNumber = 1; if (pageSize == null) pageSize = 25; if (pageSize > 100) pageSize = 100; if (pageSize < 1) pageSize = 1; var model = new SearchResultsModel(); model.Query = query; model.SortBy = sort.Value; model.TimeFilter = time.Value; model.ResultType = resultType; if (!string.IsNullOrEmpty(model.Query)) { SeekedList<Guid> postIds = null; SeekedList<Guid> subIds = null; switch (resultType) { case null: postIds = _postDao.QueryPosts(query, model.LimitingToSub != null ? model.LimitingToSub.Sub.Id : (Guid?)null, sort.Value, time.Value, ((pageNumber - 1) * pageSize), pageSize); subIds = _subDao.GetAllSubs(model.Query, SubsSortBy.Relevance, ((pageNumber - 1) * pageSize), pageSize); break; case SearchResultType.Post: postIds = _postDao.QueryPosts(query, model.LimitingToSub != null ? model.LimitingToSub.Sub.Id : (Guid?)null, sort.Value, time.Value, ((pageNumber - 1) * pageSize), pageSize); break; case SearchResultType.Sub: subIds = _subDao.GetAllSubs(model.Query, SubsSortBy.Relevance, ((pageNumber - 1) * pageSize), pageSize); break; default: throw new Exception("unknown result type"); } if (postIds != null) model.Posts = new PagedList<PostWrapped>(_postWrapper.Wrap(postIds, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, postIds.HasMore); if (subIds != null) model.Subs = new PagedList<SubWrapped>(_subWrapper.Wrap(subIds, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, subIds.HasMore); } return View("Search", model); }
public Result<IEnumerable<SearchResultItem>> GetItems(IEnumerable<ulong> ids, SearchResultType type, Result<IEnumerable<SearchResultItem>> result) { throw new NotImplementedException(); }
public void TrackQueryResultPick(ulong queryId, double rank, ushort position, uint pageId, SearchResultType type, uint? typeId) { _instance.TrackQueryResultPick(queryId, rank, position, pageId, type, typeId); }
public FleetState(FleetState orig) { Formation = orig.Formation; SearchResult = orig.SearchResult; Ships = new ShipState[] { new ShipState(orig.Ships[0]),new ShipState(orig.Ships[1]), new ShipState(orig.Ships[2]),new ShipState(orig.Ships[3]), new ShipState(orig.Ships[4]),new ShipState(orig.Ships[5]) }; }
public string GenerateSearchTypeParameter(SearchResultType searchType) { return string.Format(Resources.SearchParameter_ResultType, searchType.ToString().ToLowerInvariant()); }
public void SearchAnalytics_LogQueryPick(ulong queryId, double rank, ushort position, uint pageId, SearchResultType type, uint typeId) { _next.SearchAnalytics_LogQueryPick(queryId, rank, position, pageId, type, typeId); }
protected SearchDataContainer(SearchData[] results, SearchResultType type, int start, int count, long total) : base(results, start, count, total) { mType = type; }
private static string SearchResultString(SearchResultType searchResult) { if (searchResult == SearchResultType.Recent) return "recent"; return searchResult == SearchResultType.Popular ? "popular" : "mixed"; }