コード例 #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
ファイル: SuggestIndex.cs プロジェクト: solyutor/hlcup2018
        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;
            }
        }
コード例 #4
0
        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));
 }