public SuggestEmailResponse QueryEmail(string email) { var request = new RestRequest(EMAIL_RESOURCE, Method.POST); var query = new SuggestQuery(email); return(Execute <SuggestEmailResponse>(request, query)); }
private T Execute <T>(RestRequest request, SuggestQuery query) where T : new() { request.AddHeader("Authorization", "Token " + this.token); request.AddHeader("Content-Type", contentType.Name); request.AddHeader("Accept", contentType.Name); request.RequestFormat = contentType.Format; request.AddJsonBody(query); var response = client.Execute <T>(request); if (response.ErrorException != null) { throw response.ErrorException; } return(response.Data); }
private static void IndexSuggest(Account account, SuggestQuery query) { if (account == null || account.likes == null || account.likes.Count < 40) { return; } query.Reset(); var result = query.ExecuteWithoutIndex(account); if (result.Count == 0) { suggestions[account.id] = HList <uint> .Empty; } else { var clone = new HList <uint>(result.Count); clone.AddRange(result.Select(x => x.id)); suggestions[account.id] = clone; } }
public IEnumerable <Suggestion> SuggestQuery(SuggestQuery query) { var account = AccountContext.Accounts.FirstOrDefault(s => s.Id == query.AccountId); if (account == null) { return(null); } IQueryable <Account> accountsQuery = AccountContext.Accounts; accountsQuery = AddQueryItems(accountsQuery, query); accountsQuery = accountsQuery.Where(s => s.Sex == account.Sex); var allLikes = accountsQuery.Select(a => new { Account = a, Similarity = GetSimilarity(account, a), }) .OrderByDescending(s => s.Similarity) .SelectMany(s => s.Account.LikeIds.OrderByDescending(f => f)) .Where(s => !account.LikeIds.Contains(s)) .Take(query.Limit).ToArray(); return(AccountContext.Accounts.Where(a => allLikes.Contains(a.Id)).Select(a => new Suggestion(a))); }
public DbBookSuggestProcessor(SuggestQuery query) : base(query) { }
public async Task <BookSuggestResult> SuggestAsync(SuggestQuery query) => await _books.SuggestAsync(query);
public static bool ValidateSuggestQuery(SuggestQuery query) { return(ValidateRecommendQuery(query)); }