On Tue, Nov 24, 2020 at 10:17:35AM +0800, Wu Zhende wrote:
add two function about account
Signed-off-by: Wu Zhende wuzhende666@163.com
src/scheduler/elasticsearch_client.cr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index ec6de0d..efe304c 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -69,6 +69,28 @@ class Elasticsearch::Client return job end
- def get_account(my_email : String)
- if @client.exists({:index => "accounts", :type => "_doc", :id => my_email})
response = @client.get_source({:index => "accounts", :type => "_doc", :id => my_email})
- else
response = ""
- end
- response = JSON.parse({"_id" => my_email, "found" => false}.to_json) if response.is_a?(String)
perhaps you can define variable, use it again.
{:index => "accounts", :type => "_doc", :id => my_email}
Thanks, Liushaofei
- return response
- end
- def update_account(account_content : JSON::Any, my_email : String)
- return @client.update(
{
:index => "accounts", :type => "_doc",
:id => my_email,
:body => {:doc => account_content}
}
- )
- end
- private def create(job_content : JSON::Any, job_id : String) return @client.create( {
-- 2.23.0