Romeo David commited on
Commit
d2415b0
·
1 Parent(s): e20eb12

Refactor data_field function to include sorting by timestamp for improved data retrieval

Browse files
Files changed (1) hide show
  1. helper/data_field.py +3 -3
helper/data_field.py CHANGED
@@ -5,9 +5,9 @@ def data_field(data_src):
5
  myclient = MongoClient(mongodb_uri)
6
  mydb = myclient.get_database()
7
  mycol = mydb["df_data"]
8
- x = mycol.find_one({"data_field": data_src})
9
- x = x["result"]["question"]
10
- #st.write(x)
11
  return x
12
 
13
  def get_analyst_response(data_src):
 
5
  myclient = MongoClient(mongodb_uri)
6
  mydb = myclient.get_database()
7
  mycol = mydb["df_data"]
8
+ x = mycol.find_one({"data_field": data_src},
9
+ sort=[('timestamp', -1)])
10
+ x = x["result"]
11
  return x
12
 
13
  def get_analyst_response(data_src):