add two account functions, these func will be used by account?
it seem that about set and update account infomation.
Thanks, Shenwei
On Tue, Nov 24, 2020 at 03:10:01PM +0800, Wu Zhende wrote:
add two functions about account
- get_account
- update_account
Signed-off-by: Wu Zhende wuzhende666@163.com
src/scheduler/elasticsearch_client.cr | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index ec6de0d..7c92204 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -69,6 +69,24 @@ class Elasticsearch::Client return job end
- def get_account(my_email : String)
- query = {:index => "accounts", :type => "_doc", :id => my_email}
- response = JSON.parse({"_id" => my_email, "found" => false}.to_json)
- return response unless @client.exists(query)
- @client.get_source(query)
- 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