예제 #1
0
        public SuggestEmailResponse QueryEmail(string email)
        {
            var request = new RestRequest(EMAIL_RESOURCE, Method.POST);
            var query   = new SuggestQuery(email);

            return(Execute <SuggestEmailResponse>(request, query));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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)));
        }
예제 #5
0
 public DbBookSuggestProcessor(SuggestQuery query) : base(query)
 {
 }
예제 #6
0
 public async Task <BookSuggestResult> SuggestAsync(SuggestQuery query)
 => await _books.SuggestAsync(query);
예제 #7
0
 public static bool ValidateSuggestQuery(SuggestQuery query)
 {
     return(ValidateRecommendQuery(query));
 }