import pymongo
import pandas as pd
import numpy as np


limit = "{'wf_created_at': {'$gte': '@start_date', '$lt': '@end_date'}}"
query = "{'order_id':1,'@key':1}"

'''
instructions : query from mongoDB which should assign a defined list

Params : 
    limit - limit dict
    query - qurey dict which contains keys that should be query
'''
def querymongo(start_time_period, end_time_period, limit, query):    
    myclient = pymongo.MongoClient("mongodb://rc_dp_feature_user:qgrcdpfeature_2019@172.20.1.150:20000/?authSource=rc_dp_feature_pro")
    mydb = myclient["rc_dp_feature_pro"]
    mycol = mydb["rc_feature_analysis_timing_v2"]
    # all data 
    #x = mycol.find()

    # approval data
    #x = mycol.find({"wf_audit_result":"1"})

    # gt greater than, lt less than. e = equals
    x = mycol.find(eval(limit),eval(query)) 
    myclient.close()
    return pd.DataFrame(list(x))
